Demos (master): cmake: Avoid depending on MinGW runtime DLLs.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Wed Feb 8 17:31:36 UTC 2012


Module: Demos
Branch: master
Commit: 8248eae1a1d7f4183cbcb05e1ff804d81b098ee8
URL:    http://cgit.freedesktop.org/mesa/demos/commit/?id=8248eae1a1d7f4183cbcb05e1ff804d81b098ee8

Author: José Fonseca <jfonseca at vmware.com>
Date:   Wed Feb  8 11:00:16 2012 +0000

cmake: Avoid depending on MinGW runtime DLLs.

---

 CMakeLists.txt |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 90a9841..85390b1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,6 +3,7 @@ cmake_minimum_required (VERSION 2.8)
 project (mesademos)
 
 include (FindPkgConfig)
+include (CheckCCompilerFlag)
 
 find_package (OpenGL REQUIRED)
 find_package (GLUT REQUIRED)
@@ -108,6 +109,22 @@ if (MSVC)
 	add_definitions (-wd4244) # conversion' conversion from 'type1' to 'type2', possible loss of data
 endif (MSVC)
 
+if (MINGW)
+	# Avoid depending on MinGW runtime DLLs
+	check_c_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_c_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 ()
+
 add_definitions(-DDEMOS_DATA_DIR=\"../data/\")
 
 if (BUILD_SHARED_LIBS AND NOT DEFINED LIBDIR)




More information about the mesa-commit mailing list