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