From 970e54c63d487ff5a334b8037ce0890fceb24e0f Mon Sep 17 00:00:00 2001 From: Li Xinwei <1326710505@qq.com> Date: Wed, 16 Dec 2020 13:32:04 +0800 Subject: [PATCH] CMake: Fix module separate build error when -DFEATURE_static_runtime=ON Build qtbase with -DFEATURE_static_runtime=ON, and then separately build another module, following build error occurs: error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease'. That's because all the sources in this module are compiled with 'MD'. When separately building a module except qtbase, FEATURE_static_runtime is not exist in cmake cache. So we should use QT_FEATURE_static_runtime instead of FEATURE_static_runtime in qt_set_common_target_properties. Additionally, adjust the indentation. Pick-to: 6.0 Change-Id: I2cf4737db9d3e8533570039a66c7d277d62a8d14 Reviewed-by: Joerg Bornemann --- cmake/QtTargetHelpers.cmake | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cmake/QtTargetHelpers.cmake b/cmake/QtTargetHelpers.cmake index fe8d4618564..e4f885a5122 100644 --- a/cmake/QtTargetHelpers.cmake +++ b/cmake/QtTargetHelpers.cmake @@ -188,15 +188,15 @@ function(qt_set_common_target_properties target) OBJCXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN 1) endif() - if(FEATURE_static_runtime) - if(MSVC) - set_property(TARGET ${target} PROPERTY - MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - elseif(MINGW) - target_link_options(${target} INTERFACE "LINKER:-static") - endif() - endif() - qt_internal_set_compile_pdb_names("${target}") + if(QT_FEATURE_static_runtime) + if(MSVC) + set_property(TARGET ${target} PROPERTY + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + elseif(MINGW) + target_link_options(${target} INTERFACE "LINKER:-static") + endif() + endif() + qt_internal_set_compile_pdb_names("${target}") endfunction() # Set common, informational target properties.