diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-10-21 08:10:34 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-10-21 08:10:34 +0800 |
| commit | bbfffc8ce49b9afe854f0799513ab6b7891d6dab (patch) | |
| tree | d1b2a1cc8166270764b627960fa193b60e9b3271 /rcc/cmake/modules/HandleRCCStdlib.cmake | |
| parent | 49de843452f161ee42cb8f4ff4780ccc02ae3a7a (diff) | |
| download | rcc-project-bbfffc8ce49b9afe854f0799513ab6b7891d6dab.tar.gz rcc-project-bbfffc8ce49b9afe854f0799513ab6b7891d6dab.tar.xz | |
[CMake] Add RCC platform configuration checks
Diffstat (limited to 'rcc/cmake/modules/HandleRCCStdlib.cmake')
| -rw-r--r-- | rcc/cmake/modules/HandleRCCStdlib.cmake | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/rcc/cmake/modules/HandleRCCStdlib.cmake b/rcc/cmake/modules/HandleRCCStdlib.cmake new file mode 100644 index 0000000..5dcaf2e --- /dev/null +++ b/rcc/cmake/modules/HandleRCCStdlib.cmake @@ -0,0 +1,54 @@ +# This CMake module is responsible for setting the standard library to libc++ +# if the user has requested it. + +include(DetermineGCCCompatible) + +if(NOT DEFINED RCC_STDLIB_HANDLED) + set(RCC_STDLIB_HANDLED ON) + + function(append value) + foreach(variable ${ARGN}) + set(${variable} "${${variable}} ${value}" PARENT_SCOPE) + endforeach(variable) + endfunction() + + include(CheckCXXCompilerFlag) + include(CheckLinkerFlag) + set(RCC_LIBCXX_USED 0) + if(RCC_ENABLE_LIBCXX) + if(RCC_COMPILER_IS_GCC_COMPATIBLE) + check_cxx_compiler_flag("-stdlib=libc++" CXX_COMPILER_SUPPORTS_STDLIB) + check_linker_flag(CXX "-stdlib=libc++" CXX_LINKER_SUPPORTS_STDLIB) + if(CXX_COMPILER_SUPPORTS_STDLIB AND CXX_LINKER_SUPPORTS_STDLIB) + append("-stdlib=libc++" + CMAKE_CXX_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS + CMAKE_MODULE_LINKER_FLAGS) + set(RCC_LIBCXX_USED 1) + else() + message(WARNING "Can't specify libc++ with '-stdlib='") + endif() + else() + message(WARNING "Not sure how to specify libc++ for this compiler") + endif() + endif() + + if(RCC_STATIC_LINK_CXX_STDLIB) + if(RCC_COMPILER_IS_GCC_COMPATIBLE) + check_cxx_compiler_flag("-static-libstdc++" + CXX_COMPILER_SUPPORTS_STATIC_STDLIB) + check_linker_flag(CXX "-static-libstdc++" CXX_LINKER_SUPPORTS_STATIC_STDLIB) + if(CXX_COMPILER_SUPPORTS_STATIC_STDLIB AND + CXX_LINKER_SUPPORTS_STATIC_STDLIB) + append("-static-libstdc++" + CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS + CMAKE_MODULE_LINKER_FLAGS) + else() + message(WARNING + "Can't specify static linking for the C++ standard library") + endif() + else() + message(WARNING "Not sure how to specify static linking of C++ standard " + "library for this compiler") + endif() + endif() +endif() |
