CMake build: Link qtcreatorcdbext statically

As in the qmake build

Fixes: QTCREATORBUG-24252
Change-Id: Ifb6b375dfe515bb5ace2e70fcd2282d25b919ed5
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Eike Ziller
2020-06-25 10:15:43 +02:00
parent 4ed146035e
commit 15588ea166

View File

@@ -32,6 +32,18 @@ if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(ArchSuffix 64) set(ArchSuffix 64)
endif() endif()
# statically link MSVC runtime
# see https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#how-can-i-build-my-msvc-application-with-a-static-runtime
# TODO change to MSVC_RUNTIME_LIBRARY when CMake 3.15 is required
# set_property(TARGET qtcreatorcdbext PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
foreach(flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif()
endforeach()
add_qtc_library(qtcreatorcdbext add_qtc_library(qtcreatorcdbext
COMPONENT qtcreatorcdbext COMPONENT qtcreatorcdbext
BUILD_BY_DEFAULT BUILD_BY_DEFAULT