Set the CMP0156 policy to OLD for Qt calls
We want to avoid using the NEW behavior of CMP0156, since the linking order we specify matters in several cases, even if this lead to library duplication in linker command line. Until the NEW policy behavior with the Qt code is not fully tested we should force the policy to OLD, and keep the existing behavior. Pick-to: 6.8 6.7 6.5 Change-Id: I61641f499e71a14d90b4d92419a6b916029dbc0b Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
53e44e753b
commit
9702c3c78b
@ -70,3 +70,22 @@ function(__qt_internal_require_suitable_cmake_version_for_using_qt)
|
||||
"Use at your own risk.")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(__qt_internal_set_cmp0156)
|
||||
if(POLICY CMP0156)
|
||||
if(QT_FORCE_CMP0156_TO_NEW)
|
||||
cmake_policy(SET CMP0156 "NEW")
|
||||
else()
|
||||
cmake_policy(GET CMP0156 policy_value)
|
||||
if(NOT "${policy_value}" STREQUAL "OLD")
|
||||
if("${policy_value}" STREQUAL "NEW" AND NOT QT_BUILDING_QT)
|
||||
message(WARNING "CMP0156 is set to '${policy_value}'. Qt forces the 'OLD'"
|
||||
" behavior of this policy by default. Set QT_FORCE_CMP0156_TO_NEW=ON to"
|
||||
" force the 'NEW' behavior for the Qt commands that create either"
|
||||
" library or executable targets.")
|
||||
endif()
|
||||
cmake_policy(SET CMP0156 "OLD")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
@ -659,7 +659,10 @@ endfunction()
|
||||
function(_qt_internal_create_executable target)
|
||||
if(ANDROID)
|
||||
list(REMOVE_ITEM ARGN "WIN32" "MACOSX_BUNDLE")
|
||||
cmake_policy(PUSH)
|
||||
__qt_internal_set_cmp0156()
|
||||
add_library("${target}" MODULE ${ARGN})
|
||||
cmake_policy(POP)
|
||||
# On our qmake builds we do don't compile the executables with
|
||||
# visibility=hidden. Not having this flag set will cause the
|
||||
# executable to have main() hidden and can then no longer be loaded
|
||||
@ -673,7 +676,10 @@ function(_qt_internal_create_executable target)
|
||||
qt6_android_apply_arch_suffix("${target}")
|
||||
set_property(TARGET "${target}" PROPERTY _qt_is_android_executable TRUE)
|
||||
else()
|
||||
cmake_policy(PUSH)
|
||||
__qt_internal_set_cmp0156()
|
||||
add_executable("${target}" ${ARGN})
|
||||
cmake_policy(POP)
|
||||
endif()
|
||||
|
||||
_qt_internal_disable_autorcc_zstd_when_not_supported("${target}")
|
||||
@ -2725,7 +2731,11 @@ function(_qt_internal_add_library target)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
cmake_policy(PUSH)
|
||||
__qt_internal_set_cmp0156()
|
||||
add_library(${target} ${type_to_create} ${arg_UNPARSED_ARGUMENTS})
|
||||
cmake_policy(POP)
|
||||
|
||||
_qt_internal_disable_autorcc_zstd_when_not_supported("${target}")
|
||||
_qt_internal_set_up_static_runtime_library(${target})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user