diff options
| author | Alex Richardson <arichardson.kde@gmail.com> | 2014-02-04 16:44:16 +0100 | 
|---|---|---|
| committer | Alex Richardson <arichardson.kde@gmail.com> | 2014-02-04 16:44:16 +0100 | 
| commit | a35743f3d7496aef1155f320b871acb309b7b06f (patch) | |
| tree | 02f5258877fb52cf377aa23d11d494af5e722d97 | |
| parent | dc3e32e27dcd42f551e5fb2c923689275c6b3f52 (diff) | |
| download | extra-cmake-modules-a35743f3d7496aef1155f320b871acb309b7b06f.tar.gz extra-cmake-modules-a35743f3d7496aef1155f320b871acb309b7b06f.tar.bz2 | |
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
| -rw-r--r-- | kde-modules/KDECompilerSettings.cmake | 8 | 
1 files changed, 7 insertions, 1 deletions
| 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() | 
