1 set(libc_archive_targets "")
2 set(libc_archive_names "")
3 set(libc_archive_entrypoint_lists "")
4 if(LLVM_LIBC_FULL_BUILD)
5 list(APPEND libc_archive_names c m)
6 list(APPEND libc_archive_targets libc libm)
7 list(APPEND libc_archive_entrypoint_lists
8 TARGET_LIBC_ENTRYPOINTS TARGET_LIBM_ENTRYPOINTS)
10 list(APPEND libc_archive_names llvmlibc)
11 list(APPEND libc_archive_targets libc)
12 list(APPEND libc_archive_entrypoint_lists TARGET_LLVMLIBC_ENTRYPOINTS)
15 set(added_archive_targets "")
16 foreach(archive IN ZIP_LISTS
17 libc_archive_names libc_archive_targets libc_archive_entrypoint_lists)
19 # If an entrypoint list is missing, then skip adding targets for it.
22 add_entrypoint_library(
27 set_target_properties(
30 ARCHIVE_OUTPUT_NAME ${archive_0}
32 if(LLVM_LIBC_FULL_BUILD)
33 target_link_libraries(${archive_1} PUBLIC libc-headers)
34 if(TARGET libc-startup)
35 add_dependencies(${archive_1} libc-startup)
38 list(APPEND added_archive_targets ${archive_1})
40 # Add the offloading version of the library for offloading languages. These
41 # are installed in the standard search path separate from the other libraries.
42 if(LIBC_TARGET_OS_IS_GPU)
43 add_gpu_entrypoint_library(
49 set_target_properties(
52 ARCHIVE_OUTPUT_NAME ${archive_0}gpu-${LIBC_TARGET_ARCHITECTURE}
53 ARCHIVE_OUTPUT_DIRECTORY ${LLVM_LIBRARY_OUTPUT_INTDIR}
55 list(APPEND added_gpu_archive_targets ${archive_1}gpu)
57 add_bitcode_entrypoint_library(
63 set_target_properties(
66 OUTPUT_NAME ${archive_1}.bc
68 add_dependencies(${archive_1}gpu ${archive_1}bitcode)
69 list(APPEND added_gpu_bitcode_targets ${archive_1}bitcode)
74 TARGETS ${added_archive_targets}
75 ARCHIVE DESTINATION ${LIBC_INSTALL_LIBRARY_DIR}
79 if(LIBC_TARGET_OS_IS_GPU)
80 set(gpu_install_dir lib${LLVM_LIBDIR_SUFFIX})
81 if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
82 set(gpu_install_dir lib${LLVM_LIBDIR_SUFFIX}/${LLVM_HOST_TRIPLE})
85 TARGETS ${added_gpu_archive_targets}
86 ARCHIVE DESTINATION ${gpu_install_dir}
89 foreach(file ${added_gpu_bitcode_targets})
90 install(FILES $<TARGET_PROPERTY:${file},TARGET_OBJECT>
91 DESTINATION ${LIBC_INSTALL_LIBRARY_DIR}
92 RENAME $<TARGET_PROPERTY:${file},OUTPUT_NAME>
98 if(NOT LIBC_TARGET_OS_IS_BAREMETAL)
99 # For now we will disable libc-startup installation for baremetal. The
100 # correct way to do it would be to make a hookable startup for baremetal
101 # and install it as part of the libc installation.
102 set(startup_target "libc-startup")
105 if(LLVM_LIBC_FULL_BUILD)
106 set(header_install_target install-libc-headers)
109 add_custom_target(install-libc
110 DEPENDS ${added_archive_targets}
112 ${header_install_target}
113 COMMAND "${CMAKE_COMMAND}"
114 -DCMAKE_INSTALL_COMPONENT=libc
115 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
116 add_custom_target(install-libc-stripped
117 DEPENDS ${added_archive_targets}
119 ${header_install_target}
120 COMMAND "${CMAKE_COMMAND}"
121 -DCMAKE_INSTALL_COMPONENT=libc
122 -DCMAKE_INSTALL_DO_STRIP=1
123 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")