diff options
-rw-r--r-- | CMakeLists.txt | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6247af93..524b4e5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,7 @@ INCLUDE(CheckSymbolExists) INCLUDE(CheckCCompilerFlag) INCLUDE(CheckCXXCompilerFlag) INCLUDE(CheckCSourceCompiles) +INCLUDE(CheckCXXSourceCompiles) INCLUDE(CheckTypeSize) include(CheckStructHasMember) include(CheckFileOffsetBits) @@ -163,7 +164,7 @@ IF(HAVE___RESTRICT) SET(RESTRICT_DECL "__restrict") ENDIF() -# MSVC may need workarounds for C99 restrict and inline +# MSVC may need workarounds for C99 inline IF(MSVC) # TODO: Once we truly require C99, this inline check should go away. CHECK_C_SOURCE_COMPILES("inline void foo(void) { } @@ -350,6 +351,25 @@ int main() set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES}) unset(OLD_REQUIRED_LIBRARIES) endif() + + option(ALSOFT_STATIC_STDCXX "Static link libstdc++ with -static-libstdc++" OFF) + if(ALSOFT_STATIC_STDCXX) + set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -static-libstdc++) + check_cxx_source_compiles( +"#include <cstdlib> +int main() +{ + return 0; +}" + HAVE_STATIC_LIBSTDCXX_SWITCH + ) + if(HAVE_STATIC_LIBSTDCXX_SWITCH) + SET(LINKER_FLAGS ${LINKER_FLAGS} -static-libstdc++) + endif() + set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES}) + unset(OLD_REQUIRED_LIBRARIES) + endif() ENDIF() # Set visibility/export options if available |