|
| 1 | +#===-- cmake/modules/HandleLibs.cmake --------------------------------------===# |
| 2 | +# |
| 3 | +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | +# See https://llvm.org/LICENSE.txt for license information. |
| 5 | +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | +# |
| 7 | +#===------------------------------------------------------------------------===# |
| 8 | + |
| 9 | +# Select the C library to use for building flang-rt. |
| 10 | +if (FLANG_RT_LIBC_PROVIDER STREQUAL "system") |
| 11 | + add_library(flang-rt-libc-headers INTERFACE) |
| 12 | + add_library(flang-rt-libc-static INTERFACE) |
| 13 | + add_library(flang-rt-libc-shared INTERFACE) |
| 14 | +elseif (FLANG_RT_LIBC_PROVIDER STREQUAL "llvm") |
| 15 | + add_library(flang-rt-libc-headers INTERFACE) |
| 16 | + target_link_libraries(flang-rt-libc-headers INTERFACE libc-headers) |
| 17 | + if (FLANG_RT_HAS_NOSTDLIBINC_FLAG) |
| 18 | + target_compile_options(flang-rt-libc-headers INTERFACE $<$<COMPILE_LANGUAGE:CXX,C>:-nostdlibinc>) |
| 19 | + endif () |
| 20 | + |
| 21 | + add_library(flang-rt-libc-static INTERFACE) |
| 22 | + if (TARGET libc) |
| 23 | + target_link_libraries(flang-rt-libc-static INTERFACE libc) |
| 24 | + endif () |
| 25 | + if (TARGET libm) |
| 26 | + target_link_libraries(flang-rt-libc-static INTERFACE libm) |
| 27 | + endif () |
| 28 | + if (FLANG_RT_HAS_NOSTDLIB_FLAG) |
| 29 | + target_compile_options(flang-rt-libc-headers INTERFACE $<$<COMPILE_LANGUAGE:CXX,C>:-nostdlib>) |
| 30 | + endif () |
| 31 | + |
| 32 | + # TODO: There's no support for building LLVM libc as a shared library yet. |
| 33 | + add_library(flang-rt-libc-shared INTERFACE) |
| 34 | +endif () |
| 35 | + |
| 36 | +# Select the C++ library to use for building flang-rt. |
| 37 | +if (FLANG_RT_LIBCXX_PROVIDER STREQUAL "system") |
| 38 | + add_library(flang-rt-libcxx-headers INTERFACE) |
| 39 | +elseif (FLANG_RT_LIBCXX_PROVIDER STREQUAL "llvm") |
| 40 | + add_library(flang-rt-libcxx-headers INTERFACE) |
| 41 | + target_link_libraries(flang-rt-libcxx-headers INTERFACE cxx-headers) |
| 42 | + |
| 43 | + if (CXX_SUPPORTS_NOSTDINCXX_FLAG) |
| 44 | + target_compile_options(flang-rt-libc-headers INTERFACE $<$<COMPILE_LANGUAGE:CXX,C>:-nostdinc++>) |
| 45 | + endif () |
| 46 | + |
| 47 | + if (FLANG_RT_HAS_STDLIB_FLAG) |
| 48 | + target_compile_options(flang-rt-libc-headers INTERFACE $<$<COMPILE_LANGUAGE:CXX,C>:-stdlib=libc++>) |
| 49 | + endif () |
| 50 | +endif () |
0 commit comments