From a35743f3d7496aef1155f320b871acb309b7b06f Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Tue, 4 Feb 2014 16:44:16 +0100 Subject: Fix MSVC libc linkage for debug builds Previously we would end up with both /DEFAULTLIB:msvcrt and /DEFAULTLIB:msvcrtd on the command line. As a result of the the programs would link to both the debug and the release C library and always crash soon after startup. REVIEW: 115456 --- kde-modules/KDECompilerSettings.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kde-modules/KDECompilerSettings.cmake b/kde-modules/KDECompilerSettings.cmake index 335e1270..23c35152 100644 --- a/kde-modules/KDECompilerSettings.cmake +++ b/kde-modules/KDECompilerSettings.cmake @@ -356,7 +356,13 @@ if (WIN32) (WIN32 AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")) # make sure that no header adds libcmt by default using # #pragma comment(lib, "libcmt.lib") as done by mfc/afx.h - set(CMAKE_EXE_LINKER_FLAGS "/NODEFAULTLIB:libcmt /DEFAULTLIB:msvcrt ${CMAKE_EXE_LINKER_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/NODEFAULTLIB:libcmt /DEFAULTLIB:msvcrt ${CMAKE_EXE_LINKER_FLAGS_RELEASE}") + set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/NODEFAULTLIB:libcmt /DEFAULTLIB:msvcrt ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}") + set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "/NODEFAULTLIB:libcmt /DEFAULTLIB:msvcrt ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL}") + # use the debug versions of the libraries for debug builds + # if we just set /NODEFAULTLIB:libcmt /DEFAULTLIB:msvcrt unconditionally in CMAKE_EXE_LINKER_FLAGS we end up + # linking to the debug and the release C runtime at the same time which will cause crashes + set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/NODEFAULTLIB:libcmtd /DEFAULTLIB:msvcrtd ${CMAKE_EXE_LINKER_FLAGS_DEBUG}") endif() endif() -- cgit v1.2.1