|
| 1 | +#=============================================================================== |
| 2 | +# Define targets for linking against the selected C library |
| 3 | +# |
| 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 | +#=============================================================================== |
| 10 | + |
| 11 | +# Link against a system-provided libc |
| 12 | +if (LIBCXX_LIBC STREQUAL "system") |
| 13 | + add_library(libcxx-libc-headers INTERFACE) |
| 14 | + |
| 15 | + add_library(libcxx-libc-static INTERFACE) |
| 16 | + add_library(libcxx-libc-shared INTERFACE) |
| 17 | + |
| 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") |
| 24 | + endif() |
| 25 | + |
| 26 | + add_library(libcxx-libc-static INTERFACE) |
| 27 | + if (TARGET libc) |
| 28 | + target_link_libraries(libcxx-libc-static INTERFACE libc) |
| 29 | + endif() |
| 30 | + if (TARGET libm) |
| 31 | + target_link_libraries(libcxx-libc-static INTERFACE libm) |
| 32 | + endif() |
| 33 | + if (CXX_SUPPORTS_NOLIBC_FLAG) |
| 34 | + target_link_options(libcxx-libc-static INTERFACE "-nolibc") |
| 35 | + endif() |
| 36 | + |
| 37 | + # TODO: There's no support for building LLVM libc as a shared library yet. |
| 38 | + add_library(libcxx-libc-shared INTERFACE) |
| 39 | +endif() |
0 commit comments