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_bitcode_entrypoint_library(
49 set_target_properties(
52 OUTPUT_NAME ${archive_1}.bc
54 list(APPEND added_bitcode_targets ${archive_1}bitcode)
59 TARGETS ${added_archive_targets}
60 ARCHIVE DESTINATION ${LIBC_INSTALL_LIBRARY_DIR}
64 foreach(file ${added_bitcode_targets})
65 install(FILES $<TARGET_FILE:${file}>
66 DESTINATION ${LIBC_INSTALL_LIBRARY_DIR}
67 RENAME $<TARGET_PROPERTY:${file},OUTPUT_NAME>
72 if(NOT LIBC_TARGET_OS_IS_BAREMETAL)
73 # For now we will disable libc-startup installation for baremetal. The
74 # correct way to do it would be to make a hookable startup for baremetal
75 # and install it as part of the libc installation.
76 set(startup_target "libc-startup")
79 if(LLVM_LIBC_FULL_BUILD)
80 set(header_install_target install-libc-headers)
83 add_custom_target(install-libc
84 DEPENDS ${added_archive_targets}
85 ${added_bitcode_targets}
87 ${header_install_target}
88 COMMAND "${CMAKE_COMMAND}"
89 -DCMAKE_INSTALL_COMPONENT=libc
90 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
91 add_custom_target(install-libc-stripped
92 DEPENDS ${added_archive_targets}
93 ${added_bitcode_targets}
95 ${header_install_target}
96 COMMAND "${CMAKE_COMMAND}"
97 -DCMAKE_INSTALL_COMPONENT=libc
98 -DCMAKE_INSTALL_DO_STRIP=1
99 -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")