From ec86df35bb23941403ec88f9a663a8a44fceae51 Mon Sep 17 00:00:00 2001 From: Hannah von Reth Date: Wed, 14 Apr 2021 12:40:37 +0200 Subject: Fix static Windows builds by not setting /NODEFAULTLIB:libcmt /DEFAULTLIB:msvcrt If we tell the compiler to link the runtime statically and then explicitly link the dynamic runtime and prohibit the static we continue to produce dynamic builds... --- kde-modules/KDECompilerSettings.cmake | 30 ------------------------------ 1 file changed, 30 deletions(-) (limited to 'kde-modules/KDECompilerSettings.cmake') diff --git a/kde-modules/KDECompilerSettings.cmake b/kde-modules/KDECompilerSettings.cmake index ebad20eb..fcd80f30 100644 --- a/kde-modules/KDECompilerSettings.cmake +++ b/kde-modules/KDECompilerSettings.cmake @@ -450,36 +450,6 @@ if (APPLE) set (CMAKE_MODULE_LINKER_FLAGS "-multiply_defined suppress ${CMAKE_MODULE_LINKER_FLAGS}") endif() -if (WIN32) - if (MSVC OR CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - # MSVC has four incompatible C runtime libraries: static (libcmt), - # static debug (libcmtd), shared (msvcrt) and shared debug (msvcrtd): - # see http://support.microsoft.com/kb/154753 - # - # By default, when you create static libraries, they are automatically - # linked against either libcmt or libcmtd, and when you create shared - # libraries, they are automatically linked against either msvcrt or - # msvcrtd. Trying to link to both a library that links to libcmt and - # library that links to mscvrt, for example, will produce a warning as - # described at - # http://msdn.microsoft.com/en-us/library/aa267384%28VS.60%29.aspx - # and can produce link errors like - # "__thiscall type_info::type_info(class type_info const &)" - # (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj) - # - # It is actually the options passed to the compiler, rather than the - # linker, which control what will be linked (/MT, /MTd, /MD or /MDd), - # but we can override this by telling the linker to ignore any "libcmt" - # or "libcmtd" link suggestion embedded in the object files, and instead - # link against the shared versions. That way, everything will link - # against the same runtime library. - 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}") - set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/NODEFAULTLIB:libcmtd /DEFAULTLIB:msvcrtd ${CMAKE_EXE_LINKER_FLAGS_DEBUG}") - endif() -endif() - if (MINGW AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # This was copied from the Phonon build settings, where it had the comment # "otherwise undefined symbol in phononcore.dll errors occurs", with the commit -- cgit v1.2.1