summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Fonseca <jose.r.fonseca@gmail.com>2011-10-11 19:32:30 +0100
committerJosé Fonseca <jose.r.fonseca@gmail.com>2011-10-11 20:29:32 +0100
commitaa5681e4e7a6c0b60cf4bd05a1b80181c98547f7 (patch)
tree8e0758a091ebe558c92a2568f5ba0bd96eeec4eb
parent08e88810bd94251ced36df7808508c770c9a1165 (diff)
Avoid depending on MinGW runtime DLLs.
-rwxr-xr-xCMakeLists.txt16
1 files changed, 16 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8688898..e01da79 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -106,6 +106,22 @@ else ()
add_definitions (-Wno-sign-compare) # comparison between signed and unsigned integer expressions
endif ()
+if (MINGW)
+ # Avoid depending on MinGW runtime DLLs
+ check_cxx_compiler_flag (-static-libgcc HAVE_STATIC_LIBGCC_FLAG)
+ if (HAVE_STATIC_LIBGCC_FLAG)
+ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc")
+ set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc")
+ set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -static-libgcc")
+ endif ()
+ check_cxx_compiler_flag (-static-libstdc++ HAVE_STATIC_LIBSTDCXX_FLAG)
+ if (HAVE_STATIC_LIBSTDCXX_FLAG)
+ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++")
+ set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libstdc++")
+ set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -static-libstdc++")
+ endif ()
+endif ()
+
# Put all executables into the same top level build directory, regardless of
# which subdirectory they are declared