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 <joerg.bornemann@qt.io>
This commit is contained in:
Li Xinwei 2020-12-16 13:32:04 +08:00
parent 796de4f066
commit 970e54c63d

View File

@ -188,15 +188,15 @@ function(qt_set_common_target_properties target)
OBJCXX_VISIBILITY_PRESET hidden OBJCXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN 1) VISIBILITY_INLINES_HIDDEN 1)
endif() endif()
if(FEATURE_static_runtime) if(QT_FEATURE_static_runtime)
if(MSVC) if(MSVC)
set_property(TARGET ${target} PROPERTY set_property(TARGET ${target} PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
elseif(MINGW) elseif(MINGW)
target_link_options(${target} INTERFACE "LINKER:-static") target_link_options(${target} INTERFACE "LINKER:-static")
endif() endif()
endif() endif()
qt_internal_set_compile_pdb_names("${target}") qt_internal_set_compile_pdb_names("${target}")
endfunction() endfunction()
# Set common, informational target properties. # Set common, informational target properties.