aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-01-17 15:45:42 -0800
committerChris Robinson <[email protected]>2016-01-17 15:45:42 -0800
commit0bb838bbaf8aae967588431adfbd4e5b8bee2317 (patch)
treef5d9d5280eeea6fafbe8b8c48053f7a2b67fbb54 /CMakeLists.txt
parent1930ee3e5fee3c2f3bc4fa2386e9382a7cd6d600 (diff)
Add an option to static-link libgcc
Mainly just for MinGW to make OpenAL32.dll not rely on libgcc_s_sjlj-1.dll.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt19
1 files changed, 19 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d6ffe9a2..f4740600 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -304,6 +304,25 @@ ELSE()
CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor));
int main() {return 0;}" HAVE_GCC_DESTRUCTOR)
+
+ option(ALSOFT_STATIC_LIBGCC "Force -static-libgcc for static GCC runtimes" OFF)
+ if(ALSOFT_STATIC_LIBGCC)
+ set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+ set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -static-libgcc)
+ check_c_source_compiles(
+"#include <stdlib.h>
+int main()
+{
+ return 0;
+}"
+ HAVE_STATIC_LIBGCC_SWITCH
+ )
+ if(HAVE_STATIC_LIBGCC_SWITCH)
+ set(EXTRA_LIBS ${EXTRA_LIBS} -static-libgcc)
+ endif()
+ set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
+ unset(OLD_REQUIRED_LIBRARIES)
+ endif()
ENDIF()
# Set visibility/export options if available