Fix CMP0099 impact - disallow propagating internal linker options
CMP0099 changes the way of LINK_ONLY genex works. With CMP0099 set to OLD LINK_ONLY genex only links the exact library binary/archive without propagating other interface options from the target. This feature was exploited by PlatformXInternal targets to avoid propagating of their linker options. Nowadays when CMP0099 is forced to NEW by Qt scripts, including user-facing, we cannot rely on LINK_ONLY genex. Introduce _qt_is_internal_target property that is set for all Qt executables and explicitly limits the propagation of the linker options from PlatformXInternal targets. Fixes: QTBUG-113641 Change-Id: I3a0ecddb65886e435073feb24c1b47035130ba70 Reviewed-by: Alexandru Croitor (OOO) <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 28c9625d00d084cfc226c979be52231df7f5d3e3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
733722f2ca
commit
8bdde990d7
@ -30,6 +30,7 @@ function(qt_internal_add_executable name)
|
||||
endif()
|
||||
|
||||
_qt_internal_create_executable(${name})
|
||||
qt_internal_mark_as_internal_target(${name})
|
||||
if(ANDROID)
|
||||
_qt_internal_android_executable_finalizer(${name})
|
||||
endif()
|
||||
|
@ -207,6 +207,14 @@ function(qt_internal_apply_bitcode_flags target)
|
||||
target_compile_options("${target}" INTERFACE ${bitcode_flags})
|
||||
endfunction()
|
||||
|
||||
# Function guards linker options that are applicable for internal Qt targets only from propagating
|
||||
# them to user projects.
|
||||
function(qt_internal_platform_link_options target scope)
|
||||
set(options ${ARGN})
|
||||
set(is_internal_target_genex "$<BOOL:$<TARGET_PROPERTY:_qt_is_internal_target>>")
|
||||
target_link_options(${target} ${scope} "$<${is_internal_target_genex}:${options}>")
|
||||
endfunction()
|
||||
|
||||
# Apple deprecated the entire OpenGL API in favor of Metal, which
|
||||
# we are aware of, so silence the deprecation warnings in code.
|
||||
# This does not apply to user-code, which will need to silence
|
||||
@ -285,7 +293,7 @@ if (MSVC)
|
||||
$<$<NOT:$<CONFIG:Debug>>:-guard:cf -Gw>
|
||||
)
|
||||
|
||||
target_link_options(PlatformCommonInternal INTERFACE
|
||||
qt_internal_platform_link_options(PlatformCommonInternal INTERFACE
|
||||
-DYNAMICBASE -NXCOMPAT -LARGEADDRESSAWARE
|
||||
$<$<NOT:$<CONFIG:Debug>>:-OPT:REF -OPT:ICF -GUARD:CF>
|
||||
)
|
||||
@ -301,7 +309,7 @@ endif()
|
||||
|
||||
if(QT_FEATURE_intelcet)
|
||||
if(MSVC)
|
||||
target_link_options(PlatformCommonInternal INTERFACE
|
||||
qt_internal_platform_link_options(PlatformCommonInternal INTERFACE
|
||||
-CETCOMPAT
|
||||
)
|
||||
else()
|
||||
@ -330,22 +338,23 @@ endif()
|
||||
if(DEFINED QT_EXTRA_FRAMEWORKPATHS AND APPLE)
|
||||
list(TRANSFORM QT_EXTRA_FRAMEWORKPATHS PREPEND "-F" OUTPUT_VARIABLE __qt_fw_flags)
|
||||
target_compile_options(PlatformCommonInternal INTERFACE ${__qt_fw_flags})
|
||||
target_link_options(PlatformCommonInternal INTERFACE ${__qt_fw_flags})
|
||||
qt_internal_platform_link_options(PlatformCommonInternal INTERFACE ${__qt_fw_flags})
|
||||
unset(__qt_fw_flags)
|
||||
endif()
|
||||
|
||||
qt_internal_get_active_linker_flags(__qt_internal_active_linker_flags)
|
||||
if(__qt_internal_active_linker_flags)
|
||||
target_link_options(PlatformCommonInternal INTERFACE "${__qt_internal_active_linker_flags}")
|
||||
qt_internal_platform_link_options(PlatformCommonInternal INTERFACE
|
||||
"${__qt_internal_active_linker_flags}")
|
||||
endif()
|
||||
unset(__qt_internal_active_linker_flags)
|
||||
|
||||
if(QT_FEATURE_enable_gdb_index)
|
||||
target_link_options(PlatformCommonInternal INTERFACE "-Wl,--gdb-index")
|
||||
qt_internal_platform_link_options(PlatformCommonInternal INTERFACE "-Wl,--gdb-index")
|
||||
endif()
|
||||
|
||||
if(QT_FEATURE_enable_new_dtags)
|
||||
target_link_options(PlatformCommonInternal INTERFACE "-Wl,--enable-new-dtags")
|
||||
qt_internal_platform_link_options(PlatformCommonInternal INTERFACE "-Wl,--enable-new-dtags")
|
||||
endif()
|
||||
|
||||
function(qt_get_implicit_sse2_genex_condition out_var)
|
||||
|
@ -1001,6 +1001,15 @@ endfunction()
|
||||
# Needed to allow selectively applying certain flags via PlatformXInternal targets.
|
||||
function(qt_internal_mark_as_internal_library target)
|
||||
set_target_properties(${target} PROPERTIES _qt_is_internal_library TRUE)
|
||||
qt_internal_mark_as_internal_target(${target})
|
||||
endfunction()
|
||||
|
||||
# Marks a target with a property that it was built using the internal Qt API (qt_internal_*) as
|
||||
# opposed to it being a user project library or executable(qt_add_*, etc).
|
||||
#
|
||||
# Needed to allow selectively applying certain flags via PlatformXInternal targets.
|
||||
function(qt_internal_mark_as_internal_target target)
|
||||
set_target_properties(${target} PROPERTIES _qt_is_internal_target TRUE)
|
||||
endfunction()
|
||||
|
||||
function(qt_internal_link_internal_platform_for_object_library target)
|
||||
|
Loading…
x
Reference in New Issue
Block a user