1set(LIBC_INCLUDE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 2set(LIBC_INCLUDE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) 3 4include(LLVMLibCHeaderRules) 5 6# The GPU build wants to install files in the compiler's resource directory. 7if(LIBC_TARGET_OS_IS_GPU) 8 include(GetClangResourceDir) 9endif() 10 11add_subdirectory(llvm-libc-macros) 12add_subdirectory(llvm-libc-types) 13 14add_header( 15 llvm_libc_common_h 16 HDR 17 __llvm-libc-common.h 18) 19 20# TODO: Can we simplify this macro expansion? 21# https://github.com/llvm/llvm-project/issues/117254 22macro(add_header_macro TARGET_NAME YAML_FILE DEF_FILE GEN_HDR DEPENDS) 23 add_gen_header( 24 ${TARGET_NAME} 25 YAML_FILE ${YAML_FILE} 26 DEF_FILE ${DEF_FILE} 27 GEN_HDR ${GEN_HDR} 28 ${DEPENDS} 29 ${ARGN} 30 ) 31endmacro() 32 33add_header_macro( 34 ctype 35 ../libc/newhdrgen/yaml/ctype.yaml 36 ctype.h.def 37 ctype.h 38 DEPENDS 39 .llvm_libc_common_h 40 .llvm-libc-types.locale_t 41) 42 43add_header_macro( 44 dirent 45 ../libc/newhdrgen/yaml/dirent.yaml 46 dirent.h.def 47 dirent.h 48 DEPENDS 49 .llvm_libc_common_h 50 .llvm-libc-types.ino_t 51 .llvm-libc-types.DIR 52 .llvm-libc-types.struct_dirent 53) 54 55add_header_macro( 56 fcntl 57 ../libc/newhdrgen/yaml/fcntl.yaml 58 fcntl.h.def 59 fcntl.h 60 DEPENDS 61 .llvm-libc-macros.fcntl_macros 62 .llvm-libc-types.mode_t 63 .llvm-libc-types.struct_flock 64 .llvm-libc-types.struct_flock64 65 .llvm-libc-types.off64_t 66 .llvm-libc-types.pid_t 67 .llvm-libc-types.off_t 68 .llvm_libc_common_h 69) 70 71add_header_macro( 72 dlfcn 73 ../libc/newhdrgen/yaml/dlfcn.yaml 74 dlfcn.h.def 75 dlfcn.h 76 DEPENDS 77 .llvm-libc-macros.dlfcn_macros 78 .llvm_libc_common_h 79) 80 81add_header_macro( 82 features 83 ../libc/newhdrgen/yaml/features.yaml 84 features.h.def 85 features.h 86 DEPENDS 87 .llvm_libc_common_h 88 .llvm-libc-macros.features_macros 89) 90 91add_header_macro( 92 fenv 93 ../libc/newhdrgen/yaml/fenv.yaml 94 fenv.h.def 95 fenv.h 96 DEPENDS 97 .llvm_libc_common_h 98 .llvm-libc-macros.fenv_macros 99 .llvm-libc-types.fenv_t 100 .llvm-libc-types.fexcept_t 101) 102 103add_header_macro( 104 inttypes 105 ../libc/newhdrgen/yaml/inttypes.yaml 106 inttypes.h.def 107 inttypes.h 108 DEPENDS 109 .llvm_libc_common_h 110 .llvm-libc-types.imaxdiv_t 111 .llvm-libc-macros.inttypes_macros 112) 113 114add_header_macro( 115 float 116 ../libc/newhdrgen/yaml/float.yaml 117 float.h.def 118 float.h 119 DEPENDS 120 .llvm-libc-macros.float_macros 121) 122 123add_header_macro( 124 stdint 125 ../libc/newhdrgen/yaml/stdint.yaml 126 stdint.h.def 127 stdint.h 128 DEPENDS 129 .llvm-libc-macros.stdint_macros 130) 131 132add_header_macro( 133 limits 134 ../libc/newhdrgen/yaml/limits.yaml 135 limits.h.def 136 limits.h 137 DEPENDS 138 .llvm-libc-macros.limits_macros 139) 140 141add_header_macro( 142 malloc 143 ../libc/newhdrgen/yaml/malloc.yaml 144 malloc.h.def 145 malloc.h 146 DEPENDS 147 .llvm_libc_common_h 148 .llvm-libc-macros.malloc_macros 149) 150 151add_header_macro( 152 math 153 ../libc/newhdrgen/yaml/math.yaml 154 math.h.def 155 math.h 156 DEPENDS 157 .llvm_libc_common_h 158 .llvm-libc-macros.float16_macros 159 .llvm-libc-macros.math_macros 160 .llvm-libc-macros.math_function_macros 161 .llvm-libc-types.double_t 162 .llvm-libc-types.float_t 163 .llvm-libc-types.float128 164) 165 166add_header_macro( 167 stdfix 168 ../libc/newhdrgen/yaml/stdfix.yaml 169 stdfix.h.def 170 stdfix.h 171 DEPENDS 172 .llvm-libc-macros.stdfix_macros 173 .llvm-libc-types.stdfix-types 174) 175 176# TODO: This should be conditional on POSIX networking being included. 177file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/arpa) 178 179add_header_macro( 180 arpa_inet 181 ../libc/newhdrgen/yaml/arpa/inet.yaml 182 arpa/inet.h.def 183 arpa/inet.h 184 DEPENDS 185 .llvm_libc_common_h 186) 187 188add_header_macro( 189 assert 190 ../libc/newhdrgen/yaml/assert.yaml 191 assert.h.def 192 assert.h 193 DEPENDS 194 .llvm_libc_common_h 195 .llvm-libc-macros.assert_macros 196) 197 198add_header_macro( 199 complex 200 ../libc/newhdrgen/yaml/complex.yaml 201 complex.h.def 202 complex.h 203 DEPENDS 204 .llvm_libc_common_h 205 .llvm-libc-macros.complex_macros 206) 207 208add_header_macro( 209 setjmp 210 ../libc/newhdrgen/yaml/setjmp.yaml 211 setjmp.h.def 212 setjmp.h 213 DEPENDS 214 .llvm_libc_common_h 215 .llvm-libc-types.jmp_buf 216) 217 218add_header_macro( 219 string 220 ../libc/newhdrgen/yaml/string.yaml 221 string.h.def 222 string.h 223 DEPENDS 224 .llvm_libc_common_h 225 .llvm-libc-macros.null_macro 226 .llvm-libc-types.size_t 227) 228 229add_header_macro( 230 strings 231 ../libc/newhdrgen/yaml/strings.yaml 232 strings.h.def 233 strings.h 234 DEPENDS 235 .llvm_libc_common_h 236 .llvm-libc-types.size_t 237) 238 239add_header_macro( 240 search 241 ../libc/newhdrgen/yaml/search.yaml 242 search.h.def 243 search.h 244 DEPENDS 245 .llvm_libc_common_h 246 .llvm-libc-types.ACTION 247 .llvm-libc-types.ENTRY 248 .llvm-libc-types.struct_hsearch_data 249 .llvm-libc-types.size_t 250 .llvm-libc-types.__lsearchcompare_t 251) 252 253add_header_macro( 254 time 255 ../libc/newhdrgen/yaml/time.yaml 256 time.h.def 257 time.h 258 DEPENDS 259 .llvm_libc_common_h 260 .llvm-libc-macros.time_macros 261 .llvm-libc-types.clock_t 262 .llvm-libc-types.time_t 263 .llvm-libc-types.struct_tm 264 .llvm-libc-types.struct_timespec 265 .llvm-libc-types.struct_timeval 266 .llvm-libc-types.clockid_t 267) 268 269add_header_macro( 270 threads 271 ../libc/newhdrgen/yaml/threads.yaml 272 threads.h.def 273 threads.h 274 DEPENDS 275 .llvm_libc_common_h 276 .llvm-libc-types.__call_once_func_t 277 .llvm-libc-types.once_flag 278 .llvm-libc-types.cnd_t 279 .llvm-libc-types.mtx_t 280 .llvm-libc-types.thrd_t 281 .llvm-libc-types.thrd_start_t 282 .llvm-libc-types.tss_t 283 .llvm-libc-types.tss_dtor_t 284) 285 286add_header_macro( 287 errno 288 ../libc/newhdrgen/yaml/errno.yaml 289 errno.h.def 290 errno.h 291 DEPENDS 292 .llvm-libc-macros.generic_error_number_macros 293 .llvm-libc-macros.error_number_macros 294) 295 296add_header_macro( 297 signal 298 ../libc/newhdrgen/yaml/signal.yaml 299 signal.h.def 300 signal.h 301 DEPENDS 302 .llvm-libc-macros.signal_macros 303 .llvm-libc-types.sig_atomic_t 304 .llvm-libc-types.sigset_t 305 .llvm-libc-types.struct_sigaction 306 .llvm-libc-types.union_sigval 307 .llvm-libc-types.siginfo_t 308 .llvm-libc-types.stack_t 309 .llvm-libc-types.pid_t 310) 311 312add_header_macro( 313 stdbit 314 ../libc/newhdrgen/yaml/stdbit.yaml 315 stdbit.h.def 316 stdbit.h 317 DEPENDS 318 .llvm_libc_common_h 319 .llvm-libc-macros.stdbit_macros 320) 321 322add_header_macro( 323 stdckdint 324 ../libc/newhdrgen/yaml/stdckdint.yaml 325 stdckdint.h.def 326 stdckdint.h 327 DEPENDS 328 .llvm_libc_common_h 329 .llvm-libc-macros.stdckdint_macros 330) 331 332add_header_macro( 333 stdio 334 ../libc/newhdrgen/yaml/stdio.yaml 335 stdio.h.def 336 stdio.h 337 DEPENDS 338 .llvm-libc-macros.file_seek_macros 339 .llvm-libc-macros.stdio_macros 340 .llvm-libc-types.FILE 341 .llvm-libc-types.cookie_io_functions_t 342 .llvm-libc-types.off_t 343 .llvm-libc-types.size_t 344 .llvm-libc-types.ssize_t 345 .llvm_libc_common_h 346) 347 348add_header_macro( 349 stdlib 350 ../libc/newhdrgen/yaml/stdlib.yaml 351 stdlib.h.def 352 stdlib.h 353 DEPENDS 354 .llvm_libc_common_h 355 .llvm-libc-macros.stdlib_macros 356 .llvm-libc-types.div_t 357 .llvm-libc-types.ldiv_t 358 .llvm-libc-types.lldiv_t 359 .llvm-libc-types.size_t 360 .llvm-libc-types.__bsearchcompare_t 361 .llvm-libc-types.__qsortcompare_t 362 .llvm-libc-types.__qsortrcompare_t 363 .llvm-libc-types.__atexithandler_t 364 .llvm-libc-types.locale_t 365) 366 367add_header_macro( 368 unistd 369 ../libc/newhdrgen/yaml/unistd.yaml 370 unistd.h.def 371 unistd.h 372 DEPENDS 373 .llvm_libc_common_h 374 .llvm-libc-macros.file_seek_macros 375 .llvm-libc-macros.unistd_macros 376 .llvm-libc-types.__exec_argv_t 377 .llvm-libc-types.__exec_envp_t 378 .llvm-libc-types.off_t 379 .llvm-libc-types.pid_t 380 .llvm-libc-types.size_t 381 .llvm-libc-types.ssize_t 382 .llvm-libc-types.uid_t 383 .llvm-libc-types.__getoptargv_t 384) 385 386add_header_macro( 387 pthread 388 ../libc/newhdrgen/yaml/pthread.yaml 389 pthread.h.def 390 pthread.h 391 DEPENDS 392 .llvm_libc_common_h 393 .llvm-libc-types.__atfork_callback_t 394 .llvm-libc-types.__pthread_once_func_t 395 .llvm-libc-types.__pthread_start_t 396 .llvm-libc-types.__pthread_tss_dtor_t 397 .llvm-libc-types.pthread_attr_t 398 .llvm-libc-types.pthread_condattr_t 399 .llvm-libc-types.pthread_key_t 400 .llvm-libc-types.pthread_mutex_t 401 .llvm-libc-types.pthread_mutexattr_t 402 .llvm-libc-types.pthread_once_t 403 .llvm-libc-types.pthread_rwlock_t 404 .llvm-libc-types.pthread_rwlockattr_t 405 .llvm-libc-types.pthread_spinlock_t 406 .llvm-libc-types.pthread_t 407) 408 409add_header_macro( 410 sched 411 ../libc/newhdrgen/yaml/sched.yaml 412 sched.h.def 413 sched.h 414 DEPENDS 415 .llvm_libc_common_h 416 .llvm-libc-macros.sched_macros 417 .llvm-libc-types.cpu_set_t 418 .llvm-libc-types.pid_t 419 .llvm-libc-types.size_t 420 .llvm-libc-types.struct_sched_param 421 # Needed according to posix standard 422 .llvm-libc-types.time_t 423 .llvm-libc-types.struct_timespec 424) 425 426add_header_macro( 427 spawn 428 ../libc/newhdrgen/yaml/spawn.yaml 429 spawn.h.def 430 spawn.h 431 DEPENDS 432 .llvm_libc_common_h 433 .llvm-libc-types.mode_t 434 .llvm-libc-types.pid_t 435 .llvm-libc-types.posix_spawnattr_t 436 .llvm-libc-types.posix_spawn_file_actions_t 437) 438 439add_header_macro( 440 link 441 ../libc/newhdrgen/yaml/link.yaml 442 link.h.def 443 link.h 444 DEPENDS 445 .llvm_libc_common_h 446 .llvm-libc-macros.link_macros 447) 448 449add_header_macro( 450 elf 451 ../libc/newhdrgen/yaml/elf.yaml 452 elf.h.def 453 elf.h 454 DEPENDS 455 .llvm-libc-macros.elf_macros 456) 457 458# TODO: Not all platforms will have a include/sys directory. Add the sys 459# directory and the targets for sys/*.h files conditional to the OS requiring 460# them. 461file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/sys) 462 463add_header_macro( 464 sys_auxv 465 ../libc/newhdrgen/yaml/sys/auxv.yaml 466 sys/auxv.h.def 467 sys/auxv.h 468 DEPENDS 469 .llvm_libc_common_h 470 .llvm-libc-macros.sys_auxv_macros 471) 472 473add_header_macro( 474 sys_epoll 475 ../libc/newhdrgen/yaml/sys/epoll.yaml 476 sys/epoll.h.def 477 sys/epoll.h 478 DEPENDS 479 .llvm_libc_common_h 480 .llvm-libc-types.struct_epoll_event 481 .llvm-libc-types.struct_epoll_data 482 .llvm-libc-types.sigset_t 483 .llvm-libc-macros.sys_epoll_macros 484) 485 486add_header_macro( 487 sys_ioctl 488 ../libc/newhdrgen/yaml/sys/ioctl.yaml 489 sys/ioctl.h.def 490 sys/ioctl.h 491 DEPENDS 492 .llvm_libc_common_h 493 .llvm-libc-macros.sys_ioctl_macros 494) 495 496add_header_macro( 497 sys_mman 498 ../libc/newhdrgen/yaml/sys/mman.yaml 499 sys/mman.h.def 500 sys/mman.h 501 DEPENDS 502 .llvm_libc_common_h 503 .llvm-libc-macros.sys_mman_macros 504 .llvm-libc-types.off_t 505 .llvm-libc-types.size_t 506 .llvm-libc-types.ssize_t 507) 508 509add_header_macro( 510 sys_prctl 511 ../libc/newhdrgen/yaml/sys/prctl.yaml 512 sys/prctl.h.def 513 sys/prctl.h 514 DEPENDS 515 .llvm_libc_common_h 516) 517 518add_header( 519 sys_queue 520 HDR 521 sys/queue.h 522 DEPENDS 523 .llvm-libc-macros.sys_queue_macros 524) 525 526add_header_macro( 527 sys_random 528 ../libc/newhdrgen/yaml/sys/random.yaml 529 sys/random.h.def 530 sys/random.h 531 DEPENDS 532 .llvm_libc_common_h 533 .llvm-libc-macros.sys_random_macros 534 .llvm-libc-types.size_t 535 .llvm-libc-types.ssize_t 536) 537 538add_header_macro( 539 sys_resource 540 ../libc/newhdrgen/yaml/sys/resource.yaml 541 sys/resource.h.def 542 sys/resource.h 543 DEPENDS 544 .llvm_libc_common_h 545 .llvm-libc-macros.sys_resource_macros 546 .llvm-libc-types.rlim_t 547 .llvm-libc-types.struct_rlimit 548) 549 550add_header_macro( 551 sys_stat 552 ../libc/newhdrgen/yaml/sys/stat.yaml 553 sys/stat.h.def 554 sys/stat.h 555 DEPENDS 556 .llvm_libc_common_h 557 .llvm-libc-macros.sys_stat_macros 558 .llvm-libc-types.mode_t 559 .llvm-libc-types.dev_t 560 .llvm-libc-types.ino_t 561 .llvm-libc-types.nlink_t 562 .llvm-libc-types.uid_t 563 .llvm-libc-types.gid_t 564 .llvm-libc-types.off_t 565 .llvm-libc-types.struct_timespec 566 .llvm-libc-types.struct_timeval 567 .llvm-libc-types.blksize_t 568 .llvm-libc-types.blkcnt_t 569 .llvm-libc-types.struct_stat 570) 571 572add_header_macro( 573 sys_select 574 ../libc/newhdrgen/yaml/sys/select.yaml 575 sys/select.h.def 576 sys/select.h 577 DEPENDS 578 .llvm_libc_common_h 579 .llvm-libc-macros.sys_select_macros 580 .llvm-libc-types.fd_set 581 .llvm-libc-types.sigset_t 582 .llvm-libc-types.suseconds_t 583 .llvm-libc-types.time_t 584 .llvm-libc-types.struct_timespec 585 .llvm-libc-types.struct_timeval 586) 587 588add_header_macro( 589 sys_sendfile 590 ../libc/newhdrgen/yaml/sys/sendfile.yaml 591 sys/sendfile.h.def 592 sys/sendfile.h 593 DEPENDS 594 .llvm_libc_common_h 595 .llvm-libc-types.off_t 596 .llvm-libc-types.size_t 597 .llvm-libc-types.ssize_t 598) 599 600add_header_macro( 601 sys_socket 602 ../libc/newhdrgen/yaml/sys/socket.yaml 603 sys/socket.h.def 604 sys/socket.h 605 DEPENDS 606 .llvm_libc_common_h 607 .llvm-libc-macros.sys_socket_macros 608 .llvm-libc-types.sa_family_t 609 .llvm-libc-types.socklen_t 610 .llvm-libc-types.struct_iovec 611 .llvm-libc-types.struct_msghdr 612 .llvm-libc-types.struct_sockaddr 613 .llvm-libc-types.struct_sockaddr_un 614) 615 616add_header_macro( 617 sys_statvfs 618 ../libc/newhdrgen/yaml/sys/statvfs.yaml 619 sys/statvfs.h.def 620 sys/statvfs.h 621 DEPENDS 622 .llvm_libc_common_h 623 .llvm-libc-types.struct_statvfs 624) 625 626add_header_macro( 627 sys_syscall 628 ../libc/newhdrgen/yaml/sys/syscall.yaml 629 sys/syscall.h.def 630 sys/syscall.h 631 DEPENDS 632) 633 634add_header_macro( 635 sys_time 636 ../libc/newhdrgen/yaml/sys/time.yaml 637 sys/time.h.def 638 sys/time.h 639 DEPENDS 640 .llvm_libc_common_h 641 .llvm-libc-types.struct_timeval 642 .llvm-libc-macros.sys_time_macros 643) 644 645add_header_macro( 646 sys_types 647 ../libc/newhdrgen/yaml/sys/types.yaml 648 sys/types.h.def 649 sys/types.h 650 DEPENDS 651 .llvm_libc_common_h 652 .llvm-libc-types.blkcnt_t 653 .llvm-libc-types.blksize_t 654 .llvm-libc-types.clockid_t 655 .llvm-libc-types.dev_t 656 .llvm-libc-types.gid_t 657 .llvm-libc-types.ino_t 658 .llvm-libc-types.mode_t 659 .llvm-libc-types.nlink_t 660 .llvm-libc-types.off_t 661 .llvm-libc-types.pid_t 662 .llvm-libc-types.pthread_attr_t 663 .llvm-libc-types.pthread_key_t 664 .llvm-libc-types.pthread_mutex_t 665 .llvm-libc-types.pthread_mutexattr_t 666 .llvm-libc-types.pthread_once_t 667 .llvm-libc-types.pthread_t 668 .llvm-libc-types.size_t 669 .llvm-libc-types.ssize_t 670 .llvm-libc-types.suseconds_t 671 .llvm-libc-types.time_t 672 .llvm-libc-types.uid_t 673) 674 675add_header_macro( 676 sys_utsname 677 ../libc/newhdrgen/yaml/sys/utsname.yaml 678 sys/utsname.h.def 679 sys/utsname.h 680 DEPENDS 681 .llvm_libc_common_h 682 .llvm-libc-types.struct_utsname 683) 684 685add_header_macro( 686 sys_wait 687 ../libc/newhdrgen/yaml/sys/wait.yaml 688 sys/wait.h.def 689 sys/wait.h 690 DEPENDS 691 .llvm_libc_common_h 692 .llvm-libc-macros.sys_wait_macros 693 .llvm-libc-types.pid_t 694 .llvm-libc-types.struct_rusage 695 .llvm-libc-types.siginfo_t 696) 697 698add_header_macro( 699 termios 700 ../libc/newhdrgen/yaml/termios.yaml 701 termios.h.def 702 termios.h 703 DEPENDS 704 .llvm_libc_common_h 705 .llvm-libc-macros.termios_macros 706 .llvm-libc-types.cc_t 707 .llvm-libc-types.pid_t 708 .llvm-libc-types.speed_t 709 .llvm-libc-types.struct_termios 710 .llvm-libc-types.tcflag_t 711) 712 713add_header_macro( 714 uchar 715 ../libc/newhdrgen/yaml/uchar.yaml 716 uchar.h.def 717 uchar.h 718 DEPENDS 719 .llvm_libc_common_h 720 .llvm-libc-types.mbstate_t 721 .llvm-libc-types.char8_t 722 .llvm-libc-types.char16_t 723 .llvm-libc-types.char32_t 724) 725 726add_header_macro( 727 wchar 728 ../libc/newhdrgen/yaml/wchar.yaml 729 wchar.h.def 730 wchar.h 731 DEPENDS 732 .llvm_libc_common_h 733 .llvm-libc-macros.wchar_macros 734 .llvm-libc-types.mbstate_t 735 .llvm-libc-types.size_t 736 .llvm-libc-types.wint_t 737 .llvm-libc-types.wchar_t 738) 739 740add_header_macro( 741 locale 742 ../libc/newhdrgen/yaml/locale.yaml 743 locale.h.def 744 locale.h 745 DEPENDS 746 .llvm_libc_common_h 747 .llvm-libc-macros.locale_macros 748 .llvm-libc-types.locale_t 749 .llvm-libc-types.struct_lconv 750) 751 752if(LIBC_TARGET_OS_IS_GPU) 753 file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/gpu) 754 755 add_header_macro( 756 gpu_rpc 757 ../libc/newhdrgen/yaml/gpu/rpc.yaml 758 gpu/rpc.h.def 759 gpu/rpc.h 760 DEPENDS 761 .llvm_libc_common_h 762 ) 763endif() 764 765if(NOT LLVM_LIBC_FULL_BUILD) 766 # We don't install headers in non-fullbuild mode. 767 return() 768endif() 769 770function(get_all_install_header_targets out_var) 771 set(all_deps ${ARGN}) 772 foreach(target IN LISTS ARGN) 773 get_target_property(deps ${target} DEPS) 774 if(NOT deps) 775 continue() 776 endif() 777 list(APPEND all_deps ${deps}) 778 get_all_install_header_targets(nested_deps ${deps}) 779 list(APPEND all_deps ${nested_deps}) 780 endforeach() 781 list(REMOVE_DUPLICATES all_deps) 782 set(${out_var} ${all_deps} PARENT_SCOPE) 783endfunction(get_all_install_header_targets) 784 785get_all_install_header_targets(all_install_header_targets ${TARGET_PUBLIC_HEADERS}) 786add_library(libc-headers INTERFACE) 787add_dependencies(libc-headers ${all_install_header_targets}) 788target_include_directories(libc-headers SYSTEM INTERFACE ${LIBC_INCLUDE_DIR}) 789 790foreach(target IN LISTS all_install_header_targets) 791 get_target_property(header_file ${target} HEADER_FILE_PATH) 792 if(NOT header_file) 793 message(FATAL_ERROR "Installable header file '${target}' does not have the " 794 "HEADER_FILE_PATH property set.") 795 endif() 796 file(RELATIVE_PATH relative_path ${LIBC_INCLUDE_DIR} ${header_file}) 797 get_filename_component(nested_dir ${relative_path} DIRECTORY) 798 install(FILES ${header_file} 799 DESTINATION ${LIBC_INSTALL_INCLUDE_DIR}/${nested_dir} 800 COMPONENT libc-headers) 801 # The GPU optionally provides the supported declarations externally so 802 # offloading languages like CUDA and OpenMP know what is supported by libc. We 803 # install these in the compiler's resource directory at a preset location. 804 if(LIBC_TARGET_OS_IS_GPU AND PACKAGE_VERSION) 805 get_target_property(decls_file ${target} DECLS_FILE_PATH) 806 if(NOT decls_file) 807 continue() 808 endif() 809 get_clang_resource_dir(resource_dir SUBDIR include) 810 file(RELATIVE_PATH relative_path ${LIBC_INCLUDE_DIR} ${decls_file}) 811 get_filename_component(nested_dir ${relative_path} DIRECTORY) 812 set(install_dir 813 ${CMAKE_INSTALL_PREFIX}/${resource_dir}/llvm_libc_wrappers/${nested_dir}) 814 install(FILES ${decls_file} 815 DESTINATION ${install_dir} 816 COMPONENT libc-headers) 817 endif() 818endforeach() 819 820if(LLVM_LIBC_FULL_BUILD) 821 add_custom_target(install-libc-headers 822 DEPENDS libc-headers 823 COMMAND "${CMAKE_COMMAND}" 824 -DCMAKE_INSTALL_COMPONENT=libc-headers 825 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake") 826 # Stripping is a no-op for headers 827 add_custom_target(install-libc-headers-stripped DEPENDS install-libc-headers) 828endif() 829