1 #===============================================================================
2 # Define targets for linking against the selected C library
4 # After including this file, the following targets are defined:
5 # - libcxx-libc-headers: An interface target that allows getting access to the
6 # headers of the selected C library.
7 # - libcxx-libc-shared: A target representing the selected shared C library.
8 # - libcxx-libc-static: A target representing the selected static C library.
9 #===============================================================================
11 # Link against a system-provided libc
12 if (LIBCXX_LIBC STREQUAL "system")
13 add_library(libcxx-libc-headers INTERFACE)
15 add_library(libcxx-libc-static INTERFACE)
16 add_library(libcxx-libc-shared INTERFACE)
18 # Link against the in-tree LLVM libc
19 elseif (LIBCXX_LIBC STREQUAL "llvm-libc")
20 add_library(libcxx-libc-headers INTERFACE)
21 target_link_libraries(libcxx-libc-headers INTERFACE libc-headers)
22 if(CXX_SUPPORTS_NOSTDLIBINC_FLAG)
23 target_compile_options(libcxx-libc-headers INTERFACE "-nostdlibinc")
26 add_library(libcxx-libc-static INTERFACE)
28 target_link_libraries(libcxx-libc-static INTERFACE libc)
31 target_link_libraries(libcxx-libc-static INTERFACE libm)
33 if (CXX_SUPPORTS_NOLIBC_FLAG)
34 target_link_options(libcxx-libc-static INTERFACE "-nolibc")
37 # TODO: There's no support for building LLVM libc as a shared library yet.
38 add_library(libcxx-libc-shared INTERFACE)