From 525fe9c1347c66b3530e69dd095f7c36f64e38b9 Mon Sep 17 00:00:00 2001 From: Geoff McLane Date: Thu, 23 Mar 2017 14:53:44 +0100 Subject: [PATCH] Issue #515 - Add option to use MSVC statis runtime /MT --- CMakeLists.txt | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f9eb837..6cd778a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,6 +103,27 @@ set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS} -D_REENTRANT set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS} -D_REENTRANT" ) set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MSVC_LD_FLAGS}" ) +# option to use static windows runtime - maybe only applies to WIN32/MSVC +if (MSVC) + option( USE_STATIC_RUNTIME "Set ON to change /MD(DLL) to /MT(static)" OFF ) + if (USE_STATIC_RUNTIME) + set(CompilerFlags + CMAKE_CXX_FLAGS + CMAKE_CXX_FLAGS_DEBUG + CMAKE_CXX_FLAGS_RELEASE + CMAKE_C_FLAGS + CMAKE_C_FLAGS_DEBUG + CMAKE_C_FLAGS_RELEASE + ) + foreach(CompilerFlag ${CompilerFlags}) + string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}") + endforeach() + message(STATUS "Using /MT STATIC runtime") + else () + message(STATUS "Using /MD DYNAMIC runtime") + endif () +endif () + add_definitions ( -DHAVE_CONFIG_H ) add_definitions ( -DSUPPORT_UTF16_ENCODINGS=1 ) add_definitions ( -DSUPPORT_ASIAN_ENCODINGS=1 ) @@ -328,7 +349,7 @@ if (NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS) # squelch the warning. set (CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON) endif () -set (CMAKE_INSTALL_DEBUG_LIBRARIES ON) +set (CMAKE_INSTALL_DEBUG_LIBRARIES OFF) include (InstallRequiredSystemLibraries) ########################################################## if (WIN32)