From 20209750aa57783468dea901eb205cbc805a2c56 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 14 Jan 2014 11:45:06 +0100 Subject: [PATCH] CMake: MSVC builds use static CRT. We don't want to be dependent on the VC runtime. --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c39fe679c..6e88a8337 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,15 @@ if(LINUX AND NOT CROSSCOMPILE) endif() +# Use static CRT in MSVC builds: +if (MSVC) + string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") + string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") + string(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") + string(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") +endif() + + # Set lower warnings-level for the libraries: if (MSVC) # Remove /W3 from command line -- cannot just cancel it later with /w like in unix, MSVC produces a D9025 warning (option1 overriden by option2)