[mlir][python] Update minimal version of pybind11 to 2.10. (#117314)
[llvm-project.git] / libc / lib / CMakeLists.txt
blobce0b07fb6cb49c1692000b2426d88447025a6d63
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)
9 else()
10   list(APPEND libc_archive_names llvmlibc)
11   list(APPEND libc_archive_targets libc)
12   list(APPEND libc_archive_entrypoint_lists TARGET_LLVMLIBC_ENTRYPOINTS)
13 endif()
15 set(added_archive_targets "")
16 foreach(archive IN ZIP_LISTS
17         libc_archive_names libc_archive_targets libc_archive_entrypoint_lists)
18   if(NOT ${archive_2})
19     # If an entrypoint list is missing, then skip adding targets for it.
20     continue()
21   endif()
22   add_entrypoint_library(
23     ${archive_1}
24     DEPENDS
25       ${${archive_2}}
26   )
27   set_target_properties(
28     ${archive_1}
29     PROPERTIES
30       ARCHIVE_OUTPUT_NAME ${archive_0}
31   )
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)
36     endif()
37   endif()
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(
44       ${archive_1}bitcode
45       ${archive_1}
46       DEPENDS
47         ${${archive_2}}
48     )
49     set_target_properties(
50       ${archive_1}bitcode
51       PROPERTIES
52         OUTPUT_NAME ${archive_1}.bc
53     )
54     list(APPEND added_bitcode_targets ${archive_1}bitcode)
55   endif()
56 endforeach()
58 install(
59   TARGETS ${added_archive_targets}
60   ARCHIVE DESTINATION ${LIBC_INSTALL_LIBRARY_DIR}
61   COMPONENT libc
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>
68           COMPONENT libc
69   )
70 endforeach()
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")
77 endif()
79 if(LLVM_LIBC_FULL_BUILD)
80   set(header_install_target install-libc-headers)
81 endif()
83 add_custom_target(install-libc
84                   DEPENDS ${added_archive_targets}
85                           ${added_bitcode_targets}
86                           ${startup_target}
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}
94                           ${startup_target}
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")