[docs] Fix build-docs.sh
[llvm-project.git] / clang / lib / Headers / CMakeLists.txt
blob6e2060991b921571ef14f4782ab8b8db2884a167
1 # core_files list contains the headers shared by all platforms.
2 # Please consider adding new platform specific headers
3 # to platform specific lists below.
4 set(core_files
5   builtins.h
6   float.h
7   inttypes.h
8   iso646.h
9   limits.h
10   module.modulemap
11   stdalign.h
12   stdarg.h
13   stdatomic.h
14   stdbool.h
15   stddef.h
16   __stddef_max_align_t.h
17   stdint.h
18   stdnoreturn.h
19   tgmath.h
20   unwind.h
21   varargs.h
22   )
24 set(arm_common_files
25   # Headers shared by Arm and AArch64
26   arm_acle.h
27   )
29 set(arm_only_files
30   arm_cmse.h
31   armintr.h
32   )
34 set(aarch64_only_files
35   arm64intr.h
36   )
38 set(cuda_files
39   __clang_cuda_builtin_vars.h
40   __clang_cuda_math.h
41   __clang_cuda_cmath.h
42   __clang_cuda_complex_builtins.h
43   __clang_cuda_device_functions.h
44   __clang_cuda_intrinsics.h
45   __clang_cuda_texture_intrinsics.h
46   __clang_cuda_libdevice_declares.h
47   __clang_cuda_math_forward_declares.h
48   __clang_cuda_runtime_wrapper.h
49   )
51 set(hexagon_files
52   hexagon_circ_brev_intrinsics.h
53   hexagon_protos.h
54   hexagon_types.h
55   hvx_hexagon_protos.h
56   )
58 set(hip_files
59   __clang_hip_libdevice_declares.h
60   __clang_hip_cmath.h
61   __clang_hip_math.h
62   __clang_hip_runtime_wrapper.h
63   )
65 set(hlsl_files
66   hlsl.h
67   hlsl/hlsl_basic_types.h
68   hlsl/hlsl_intrinsics.h
69   )
71 set(mips_msa_files
72   msa.h
73   )
75 set(opencl_files
76   opencl-c.h
77   opencl-c-base.h
78   )
80 set(ppc_files
81   altivec.h
82   )
84 set(ppc_htm_files
85   htmintrin.h
86   htmxlintrin.h
87   )
89 set(systemz_files
90   s390intrin.h
91   vecintrin.h
92   )
94 set(ve_files
95   velintrin.h
96   velintrin_gen.h
97   velintrin_approx.h
98   )
100 set(webassembly_files
101   wasm_simd128.h
102   )
104 set(x86_files
105 # Intrinsics
106   adxintrin.h
107   ammintrin.h
108   amxintrin.h
109   avx2intrin.h
110   avx512bf16intrin.h
111   avx512bitalgintrin.h
112   avx512bwintrin.h
113   avx512cdintrin.h
114   avx512dqintrin.h
115   avx512erintrin.h
116   avx512fintrin.h
117   avx512fp16intrin.h
118   avx512ifmaintrin.h
119   avx512ifmavlintrin.h
120   avx512pfintrin.h
121   avx512vbmi2intrin.h
122   avx512vbmiintrin.h
123   avx512vbmivlintrin.h
124   avx512vlbf16intrin.h
125   avx512vlbitalgintrin.h
126   avx512vlbwintrin.h
127   avx512vlcdintrin.h
128   avx512vldqintrin.h
129   avx512vlfp16intrin.h
130   avx512vlintrin.h
131   avx512vlvbmi2intrin.h
132   avx512vlvnniintrin.h
133   avx512vlvp2intersectintrin.h
134   avx512vnniintrin.h
135   avx512vp2intersectintrin.h
136   avx512vpopcntdqintrin.h
137   avx512vpopcntdqvlintrin.h
138   avxintrin.h
139   avxvnniintrin.h
140   bmi2intrin.h
141   bmiintrin.h
142   cetintrin.h
143   cldemoteintrin.h
144   clflushoptintrin.h
145   clwbintrin.h
146   clzerointrin.h
147   crc32intrin.h
148   emmintrin.h
149   enqcmdintrin.h
150   f16cintrin.h
151   fma4intrin.h
152   fmaintrin.h
153   fxsrintrin.h
154   gfniintrin.h
155   hresetintrin.h
156   ia32intrin.h
157   immintrin.h
158   invpcidintrin.h
159   keylockerintrin.h
160   lwpintrin.h
161   lzcntintrin.h
162   mm3dnow.h
163   mmintrin.h
164   movdirintrin.h
165   mwaitxintrin.h
166   nmmintrin.h
167   pconfigintrin.h
168   pkuintrin.h
169   pmmintrin.h
170   popcntintrin.h
171   prfchwintrin.h
172   ptwriteintrin.h
173   rdpruintrin.h
174   rdseedintrin.h
175   rtmintrin.h
176   serializeintrin.h
177   sgxintrin.h
178   shaintrin.h
179   smmintrin.h
180   tbmintrin.h
181   tmmintrin.h
182   tsxldtrkintrin.h
183   uintrintrin.h
184   vaesintrin.h
185   vpclmulqdqintrin.h
186   waitpkgintrin.h
187   wbnoinvdintrin.h
188   __wmmintrin_aes.h
189   wmmintrin.h
190   __wmmintrin_pclmul.h
191   x86gprintrin.h
192   x86intrin.h
193   xmmintrin.h
194   xopintrin.h
195   xsavecintrin.h
196   xsaveintrin.h
197   xsaveoptintrin.h
198   xsavesintrin.h
199   xtestintrin.h
200 # others
201   cet.h
202   cpuid.h
203   )
205 set(windows_only_files
206   intrin.h
207   vadefs.h
210 set(utility_files
211   mm_malloc.h
214 set(files
215   ${core_files}
216   ${arm_common_files}
217   ${arm_only_files}
218   ${aarch64_only_files}
219   ${cuda_files}
220   ${hexagon_files}
221   ${hip_files}
222   ${hlsl_files}
223   ${mips_msa_files}
224   ${opencl_files}
225   ${ppc_files}
226   ${ppc_htm_files}
227   ${systemz_files}
228   ${ve_files}
229   ${x86_files}
230   ${webassembly_files}
231   ${windows_only_files}
232   ${utility_files}
233   )
235 set(cuda_wrapper_files
236   cuda_wrappers/algorithm
237   cuda_wrappers/complex
238   cuda_wrappers/new
241 set(ppc_wrapper_files
242   ppc_wrappers/mmintrin.h
243   ppc_wrappers/xmmintrin.h
244   ppc_wrappers/mm_malloc.h
245   ppc_wrappers/emmintrin.h
246   ppc_wrappers/pmmintrin.h
247   ppc_wrappers/tmmintrin.h
248   ppc_wrappers/smmintrin.h
249   ppc_wrappers/bmiintrin.h
250   ppc_wrappers/bmi2intrin.h
251   ppc_wrappers/immintrin.h
252   ppc_wrappers/x86intrin.h
253   ppc_wrappers/x86gprintrin.h
256 set(openmp_wrapper_files
257   openmp_wrappers/math.h
258   openmp_wrappers/cmath
259   openmp_wrappers/complex.h
260   openmp_wrappers/complex
261   openmp_wrappers/__clang_openmp_device_functions.h
262   openmp_wrappers/complex_cmath.h
263   openmp_wrappers/new
266 set(output_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include)
267 set(out_files)
268 set(generated_files)
270 set(arm_common_generated_files)
271 set(arm_only_generated_files)
272 set(aarch64_only_generated_files)
273 set(riscv_generated_files)
275 function(copy_header_to_output_dir src_dir file)
276   set(src ${src_dir}/${file})
277   set(dst ${output_dir}/${file})
278   add_custom_command(OUTPUT ${dst}
279     DEPENDS ${src}
280     COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
281     COMMENT "Copying clang's ${file}...")
282   list(APPEND out_files ${dst})
283   set(out_files ${out_files} PARENT_SCOPE)
284 endfunction(copy_header_to_output_dir)
286 function(clang_generate_header td_option td_file out_file)
287   clang_tablegen(${out_file} ${td_option}
288   -I ${CLANG_SOURCE_DIR}/include/clang/Basic/
289   SOURCE ${CLANG_SOURCE_DIR}/include/clang/Basic/${td_file})
291   copy_header_to_output_dir(${CMAKE_CURRENT_BINARY_DIR} ${out_file})
292   set(out_files ${out_files} PARENT_SCOPE)
293   list(APPEND generated_files "${CMAKE_CURRENT_BINARY_DIR}/${out_file}")
294   set(generated_files ${generated_files} PARENT_SCOPE)
295 endfunction(clang_generate_header)
298 # Copy header files from the source directory to the build directory
299 foreach( f ${files} ${cuda_wrapper_files} ${ppc_wrapper_files} ${openmp_wrapper_files})
300   copy_header_to_output_dir(${CMAKE_CURRENT_SOURCE_DIR} ${f})
301 endforeach( f )
303 # Generate header files and copy them to the build directory
304 if(ARM IN_LIST LLVM_TARGETS_TO_BUILD OR AArch64 IN_LIST LLVM_TARGETS_TO_BUILD)
305   # Generate arm_neon.h
306   clang_generate_header(-gen-arm-neon arm_neon.td arm_neon.h)
307   # Generate arm_fp16.h
308   clang_generate_header(-gen-arm-fp16 arm_fp16.td arm_fp16.h)
309   # Generate arm_sve.h
310   clang_generate_header(-gen-arm-sve-header arm_sve.td arm_sve.h)
311   # Generate arm_bf16.h
312   clang_generate_header(-gen-arm-bf16 arm_bf16.td arm_bf16.h)
313   # Generate arm_mve.h
314   clang_generate_header(-gen-arm-mve-header arm_mve.td arm_mve.h)
315   # Generate arm_cde.h
316   clang_generate_header(-gen-arm-cde-header arm_cde.td arm_cde.h)
317   # Copy arm_neon_sve_bridge.h
318   copy_header_to_output_dir(${CMAKE_CURRENT_SOURCE_DIR}
319     arm_neon_sve_bridge.h
320   )
322   # Add headers to target specific lists
323   list(APPEND arm_common_generated_files
324     "${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h"
325     "${CMAKE_CURRENT_BINARY_DIR}/arm_fp16.h"
326     )
328   list(APPEND arm_only_generated_files
329     "${CMAKE_CURRENT_BINARY_DIR}/arm_mve.h"
330     "${CMAKE_CURRENT_BINARY_DIR}/arm_cde.h"
331     )
333   list(APPEND aarch64_only_generated_files
334     "${CMAKE_CURRENT_BINARY_DIR}/arm_sve.h"
335     "${CMAKE_CURRENT_BINARY_DIR}/arm_bf16.h"
336     "${output_dir}/arm_neon_sve_bridge.h"
337     )
338 endif()
339 if(RISCV IN_LIST LLVM_TARGETS_TO_BUILD)
340   # Generate riscv_vector.h
341   clang_generate_header(-gen-riscv-vector-header riscv_vector.td riscv_vector.h)
342   list(APPEND riscv_generated_files
343     "${CMAKE_CURRENT_BINARY_DIR}/riscv_vector.h"
344     )
345 endif()
348 # Check if the generated headers are included in a target specific lists
349 # Currently, all generated headers are target specific.
350 set(all_target_specific_generated_files
351   ${arm_common_generated_files}
352   ${arm_only_generated_files}
353   ${aarch64_only_generated_files}
354   ${riscv_generated_files})
355 foreach( f ${generated_files} )
356   if (NOT ${f} IN_LIST all_target_specific_generated_files)
357     message(WARNING "${f} is a generated header but it is not included in any "
358                     "target specific header lists! The resource-headers "
359                     "distribtion target will be incorrect!")
360   endif()
361 endforeach( f )
363 function(add_header_target target_name file_list)
364   add_custom_target(${target_name} DEPENDS ${file_list})
365   set_target_properties(${target_name} PROPERTIES
366     FOLDER "Misc"
367     RUNTIME_OUTPUT_DIRECTORY "${output_dir}")
368 endfunction()
370 # The catch-all clang-resource-headers target
371 add_custom_target("clang-resource-headers" ALL DEPENDS ${out_files})
372 set_target_properties("clang-resource-headers" PROPERTIES
373   FOLDER "Misc"
374   RUNTIME_OUTPUT_DIRECTORY "${output_dir}")
375 add_dependencies("clang-resource-headers"
376                  "core-resource-headers"
377                  "arm-common-resource-headers"
378                  "arm-resource-headers"
379                  "aarch64-resource-headers"
380                  "cuda-resource-headers"
381                  "hexagon-resource-headers"
382                  "hip-resource-headers"
383                  "hlsl-resource-headers"
384                  "mips-resource-headers"
385                  "ppc-resource-headers"
386                  "ppc-htm-resource-headers"
387                  "riscv-resource-headers"
388                  "systemz-resource-headers"
389                  "ve-resource-headers"
390                  "webassembly-resource-headers"
391                  "x86-resource-headers"
392                  "opencl-resource-headers"
393                  "openmp-resource-headers"
394                  "windows-resource-headers"
395                  "utility-resource-headers")
397 # Core/common headers
398 add_header_target("core-resource-headers" ${core_files})
399 add_header_target("arm-common-resource-headers" "${arm_common_files};${arm_common_generated_files}")
401 # Architecture/platform specific targets
402 add_header_target("arm-resource-headers" "${arm_only_files};${arm_only_generated_files}")
403 add_header_target("aarch64-resource-headers" "${aarch64_only_files};${aarch64_only_generated_files}")
404 add_header_target("cuda-resource-headers" "${cuda_files};${cuda_wrapper_files}")
405 add_header_target("hexagon-resource-headers" "${hexagon_files}")
406 add_header_target("hip-resource-headers" "${hip_files}")
407 add_header_target("mips-resource-headers" "${mips_msa_files}")
408 add_header_target("ppc-resource-headers" "${ppc_files};${ppc_wrapper_files}")
409 add_header_target("ppc-htm-resource-headers" "${ppc_htm_files}")
410 add_header_target("riscv-resource-headers" "${riscv_generated_files}")
411 add_header_target("systemz-resource-headers" "${systemz_files}")
412 add_header_target("ve-resource-headers" "${ve_files}")
413 add_header_target("webassembly-resource-headers" "${webassembly_files}")
414 add_header_target("x86-resource-headers" "${x86_files}")
416 # Other header groupings
417 add_header_target("hlsl-resource-headers" ${hlsl_files})
418 add_header_target("opencl-resource-headers" ${opencl_files})
419 add_header_target("openmp-resource-headers" ${openmp_wrapper_files})
420 add_header_target("windows-resource-headers" ${windows_only_files})
421 add_header_target("utility-resource-headers" ${utility_files})
423 set(header_install_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
425 #############################################################
426 # Install rules for the catch-all clang-resource-headers target
427 install(
428   FILES ${files} ${generated_files}
429   DESTINATION ${header_install_dir}
430   COMPONENT clang-resource-headers)
432 install(
433   FILES ${cuda_wrapper_files}
434   DESTINATION ${header_install_dir}/cuda_wrappers
435   COMPONENT clang-resource-headers)
437 install(
438   FILES ${ppc_wrapper_files}
439   DESTINATION ${header_install_dir}/ppc_wrappers
440   COMPONENT clang-resource-headers)
442 install(
443   FILES ${openmp_wrapper_files}
444   DESTINATION ${header_install_dir}/openmp_wrappers
445   COMPONENT clang-resource-headers)
447 #############################################################
448 # Install rules for separate header lists
449 install(
450   FILES ${core_files}
451   DESTINATION ${header_install_dir}
452   EXCLUDE_FROM_ALL
453   COMPONENT core-resource-headers)
455 install(
456   FILES ${arm_common_files} ${arm_common_generated_files}
457   DESTINATION ${header_install_dir}
458   EXCLUDE_FROM_ALL
459   COMPONENT arm-common-resource-headers)
461 install(
462   FILES ${arm_only_files} ${arm_only_generated_files}
463   DESTINATION ${header_install_dir}
464   EXCLUDE_FROM_ALL
465   COMPONENT arm-resource-headers)
467 install(
468   FILES ${aarch64_only_files} ${aarch64_only_generated_files}
469   DESTINATION ${header_install_dir}
470   EXCLUDE_FROM_ALL
471   COMPONENT aarch64-resource-headers)
473 install(
474   FILES ${cuda_wrapper_files}
475   DESTINATION ${header_install_dir}/cuda_wrappers
476   EXCLUDE_FROM_ALL
477   COMPONENT cuda-resource-headers)
479 install(
480   FILES ${cuda_files}
481   DESTINATION ${header_install_dir}
482   EXCLUDE_FROM_ALL
483   COMPONENT cuda-resource-headers)
485 install(
486   FILES ${hexagon_files}
487   DESTINATION ${header_install_dir}
488   EXCLUDE_FROM_ALL
489   COMPONENT hexagon-resource-headers)
491 install(
492   FILES ${hip_files}
493   DESTINATION ${header_install_dir}
494   EXCLUDE_FROM_ALL
495   COMPONENT hip-resource-headers)
497 install(
498   FILES ${mips_msa_files}
499   DESTINATION ${header_install_dir}
500   EXCLUDE_FROM_ALL
501   COMPONENT mips-resource-headers)
503 install(
504   FILES ${ppc_wrapper_files}
505   DESTINATION ${header_install_dir}/ppc_wrappers
506   EXCLUDE_FROM_ALL
507   COMPONENT ppc-resource-headers)
509 install(
510   FILES ${ppc_files}
511   DESTINATION ${header_install_dir}
512   EXCLUDE_FROM_ALL
513   COMPONENT ppc-resource-headers)
515 install(
516   FILES ${ppc_htm_files}
517   DESTINATION ${header_install_dir}
518   EXCLUDE_FROM_ALL
519   COMPONENT ppc-htm-resource-headers)
521 install(
522   FILES ${riscv_generated_files}
523   DESTINATION ${header_install_dir}
524   EXCLUDE_FROM_ALL
525   COMPONENT riscv-resource-headers)
527 install(
528   FILES ${systemz_files}
529   DESTINATION ${header_install_dir}
530   EXCLUDE_FROM_ALL
531   COMPONENT systemz-resource-headers)
533 install(
534   FILES ${ve_files}
535   DESTINATION ${header_install_dir}
536   EXCLUDE_FROM_ALL
537   COMPONENT ve-resource-headers)
539 install(
540   FILES ${webassembly_files}
541   DESTINATION ${header_install_dir}
542   EXCLUDE_FROM_ALL
543   COMPONENT webassembly-resource-headers)
545 install(
546   FILES ${x86_files}
547   DESTINATION ${header_install_dir}
548   EXCLUDE_FROM_ALL
549   COMPONENT x86-resource-headers)
551 install(
552   FILES ${hlsl_files}
553   DESTINATION ${header_install_dir}
554   EXCLUDE_FROM_ALL
555   COMPONENT hlsl-resource-headers)
557 install(
558   FILES ${opencl_files}
559   DESTINATION ${header_install_dir}
560   EXCLUDE_FROM_ALL
561   COMPONENT opencl-resource-headers)
563 install(
564   FILES ${openmp_wrapper_files}
565   DESTINATION ${header_install_dir}/openmp_wrappers
566   EXCLUDE_FROM_ALL
567   COMPONENT openmp-resource-headers)
569 install(
570   FILES ${utility_files}
571   DESTINATION ${header_install_dir}
572   EXCLUDE_FROM_ALL
573   COMPONENT utility-resource-headers)
575 install(
576   FILES ${windows_only_files}
577   DESTINATION ${header_install_dir}
578   EXCLUDE_FROM_ALL
579   COMPONENT windows-resource-headers)
580 #############################################################
582 if (NOT LLVM_ENABLE_IDE)
583   add_llvm_install_targets(install-clang-resource-headers
584                            DEPENDS clang-resource-headers
585                            COMPONENT clang-resource-headers)
587   add_llvm_install_targets(install-core-resource-headers
588                            DEPENDS core-resource-headers
589                            COMPONENT core-resource-headers)
590   add_llvm_install_targets(install-arm-common-resource-headers
591                            DEPENDS arm-common-resource-headers
592                            COMPONENT arm-common-resource-headers)
593   add_llvm_install_targets(install-arm-resource-headers
594                            DEPENDS arm-resource-headers
595                            COMPONENT arm-resource-headers)
596   add_llvm_install_targets(install-aarch64-resource-headers
597                            DEPENDS aarch64-resource-headers
598                            COMPONENT aarch64-resource-headers)
599   add_llvm_install_targets(install-cuda-resource-headers
600                            DEPENDS cuda-resource-headers
601                            COMPONENT cuda-resource-headers)
602   add_llvm_install_targets(install-hexagon-resource-headers
603                            DEPENDS hexagon-resource-headers
604                            COMPONENT hexagon-resource-headers)
605   add_llvm_install_targets(install-hip-resource-headers
606                            DEPENDS hip-resource-headers
607                            COMPONENT hip-resource-headers)
608   add_llvm_install_targets(install-mips-resource-headers
609                            DEPENDS mips-resource-headers
610                            COMPONENT mips-resource-headers)
611   add_llvm_install_targets(install-ppc-resource-headers
612                            DEPENDS ppc-resource-headers
613                            COMPONENT ppc-resource-headers)
614   add_llvm_install_targets(install-ppc-htm-resource-headers
615                            DEPENDS ppc-htm-resource-headers
616                            COMPONENT ppc-htm-resource-headers)
617   add_llvm_install_targets(install-riscv-resource-headers
618                            DEPENDS riscv-resource-headers
619                            COMPONENT riscv-resource-headers)
620   add_llvm_install_targets(install-systemz-resource-headers
621                            DEPENDS systemz-resource-headers
622                            COMPONENT systemz-resource-headers)
623   add_llvm_install_targets(install-ve-resource-headers
624                            DEPENDS ve-resource-headers
625                            COMPONENT ve-resource-headers)
626   add_llvm_install_targets(install-x86-resource-headers
627                            DEPENDS x86-resource-headers
628                            COMPONENT x86-resource-headers)
629   add_llvm_install_targets(install-webassembly-resource-headers
630                            DEPENDS webassembly-resource-headers
631                            COMPONENT webassembly-resource-headers)
633   add_llvm_install_targets(install-hlsl-resource-headers
634                            DEPENDS hlsl-resource-headers
635                            COMPONENT hlsl-resource-headers)
636   add_llvm_install_targets(install-opencl-resource-headers
637                            DEPENDS opencl-resource-headers
638                            COMPONENT opencl-resource-headers)
639   add_llvm_install_targets(install-openmp-resource-headers
640                            DEPENDS openmp-resource-headers
641                            COMPONENT openmp-resource-headers)
642   add_llvm_install_targets(install-windows-resource-headers
643                            DEPENDS windows-resource-headers
644                            COMPONENT windows-resource-headers)
645   add_llvm_install_targets(install-utility-resource-headers
646                            DEPENDS utility-resource-headers
647                            COMPONENT utility-resource-headers)
648 endif()