From 3f2b0ca5c6eb97d65fec58dfaccc75e537ab6656 Mon Sep 17 00:00:00 2001 From: Thomas Thomassen Date: Wed, 10 Feb 2016 12:55:47 +0100 Subject: [PATCH] Adding more granular control over CRT for Debug vs Release builds. Ref #776. --- CMakeLists.txt | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f2452475..31b869d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -272,6 +272,10 @@ elseif(MSVC) #/D_HAS_ITERATOR_DEBUGGING=0 ) + # thomthom : When enabling static CRT there are linker errors in Release + # referring to libcpmt (Note not libcmt). Not sure why, but removing this + # exclude allowed it to build, and there where no linker error in VS2013/15 + # when building with minimal build. # Turn off a duplicate LIBCMT linker warning #set(CMAKE_EXE_LINKER_FLAGS # "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:libcmt.lib") @@ -314,18 +318,24 @@ option(NO_DX "Disable DirectX support") option(NO_TESTS "Disable all tests") option(NO_GLTESTS "Disable GL tests") -option(STATIC_CRT "Statically link MSVC CRT" OFF) +option(MSVC_STATIC_CRT_RELEASE "Statically link MSVC CRT in Release" OFF) +option(MSVC_STATIC_CRT_DEBUG "Statically link MSVC CRT in Debug" OFF) -if(MSVC AND STATIC_CRT) - message(STATUS "Using static MSVC CRT") +if(MSVC AND MSVC_STATIC_CRT_RELEASE) + message(STATUS "Using static MSVC CRT Release") # http://stackoverflow.com/a/32128977/486990 add_compile_options( - "$<$:/MDd>" "$<$:/MT>" "$<$:/MT>" "$<$:/MT>" ) endif() +if(MSVC AND MSVC_STATIC_CRT_DEBUG) + message(STATUS "Using static MSVC CRT Debug") + add_compile_options( + "$<$:/MTd>" + ) +endif() set(OSD_GPU FALSE)