CMake: Split target finalization code into a separate function
It was duplicated across a few public API. Splitting it will also allow it to be be reused in a future change in another function. Also add the ability to use the poor man finalizer approach for CMake 3.16, but only via an opt-in that will be set by the qt build process, so that the finalizers can be used for tests in a future change. Task-number: QTBUG-93625 Task-number: QTBUG-112212 Change-Id: I097faf5e3db98457acfdfb3ae2011efb6640f35e Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> (cherry picked from commit 2bbc0bda30e0c34ea63f0b6836c34c765a06e049) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
ef3db62459
commit
45c8ab1149
@ -88,6 +88,9 @@ function(qt_watch_current_list_dir variable access value current_list_file stack
|
||||
elseif(func STREQUAL "_qt_internal_finalize_sbom")
|
||||
_qt_internal_finalize_sbom(
|
||||
${a1} ${a2} ${a3} ${a4} ${a5} ${a6} ${a7} ${a8} ${a9})
|
||||
elseif(func STREQUAL "qt6_finalize_target")
|
||||
qt6_finalize_target(
|
||||
${a1} ${a2} ${a3} ${a4} ${a5} ${a6} ${a7} ${a8} ${a9})
|
||||
else()
|
||||
message(FATAL_ERROR "qt_watch_current_list_dir doesn't know about ${func}. Consider adding it.")
|
||||
endif()
|
||||
|
@ -652,17 +652,7 @@ function(qt6_add_executable target)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Defer the finalization if we can. When the caller's project requires
|
||||
# CMake 3.19 or later, this makes the calls to this function concise while
|
||||
# still allowing target property modification before finalization.
|
||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.19)
|
||||
# Need to wrap in an EVAL CODE or else ${target} won't be evaluated
|
||||
# due to special behavior of cmake_language() argument handling
|
||||
cmake_language(EVAL CODE "cmake_language(DEFER CALL qt6_finalize_target ${target})")
|
||||
else()
|
||||
set_target_properties("${target}" PROPERTIES _qt_is_immediately_finalized TRUE)
|
||||
qt6_finalize_target("${target}")
|
||||
endif()
|
||||
_qt_internal_finalize_target_defer("${target}")
|
||||
endfunction()
|
||||
|
||||
# Just like for qt_add_resources, we should disable zstd compression when cross-compiling to a
|
||||
@ -861,6 +851,22 @@ function(qt6_finalize_target target)
|
||||
set_target_properties(${target} PROPERTIES _qt_is_finalized TRUE)
|
||||
endfunction()
|
||||
|
||||
function(_qt_internal_finalize_target_defer target)
|
||||
# Defer the finalization if we can. When the caller's project requires
|
||||
# CMake 3.19 or later, this makes the calls to this function concise while
|
||||
# still allowing target property modification before finalization.
|
||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.19)
|
||||
# Need to wrap in an EVAL CODE or else ${target} won't be evaluated
|
||||
# due to special behavior of cmake_language() argument handling
|
||||
cmake_language(EVAL CODE "cmake_language(DEFER CALL qt6_finalize_target ${target})")
|
||||
elseif(QT_BUILDING_QT AND QT_INTERNAL_USE_POOR_MANS_SCOPE_FINALIZER)
|
||||
qt_add_list_file_finalizer(qt6_finalize_target "${target}")
|
||||
else()
|
||||
set_target_properties("${target}" PROPERTIES _qt_is_immediately_finalized TRUE)
|
||||
qt6_finalize_target("${target}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(_qt_internal_finalize_source_groups target)
|
||||
if(NOT ("${CMAKE_GENERATOR}" STREQUAL "Xcode"
|
||||
OR "${CMAKE_GENERATOR}" MATCHES "^Visual Studio"))
|
||||
@ -2628,17 +2634,7 @@ function(qt6_add_plugin target)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Defer the finalization if we can. When the caller's project requires
|
||||
# CMake 3.19 or later, this makes the calls to this function concise while
|
||||
# still allowing target property modification before finalization.
|
||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.19)
|
||||
# Need to wrap in an EVAL CODE or else ${target} won't be evaluated
|
||||
# due to special behavior of cmake_language() argument handling
|
||||
cmake_language(EVAL CODE "cmake_language(DEFER CALL qt6_finalize_target ${target})")
|
||||
else()
|
||||
set_target_properties("${target}" PROPERTIES _qt_is_immediately_finalized TRUE)
|
||||
qt6_finalize_target("${target}")
|
||||
endif()
|
||||
_qt_internal_finalize_target_defer("${target}")
|
||||
endfunction()
|
||||
|
||||
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
|
||||
@ -2664,17 +2660,7 @@ function(qt6_add_library target)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Defer the finalization if we can. When the caller's project requires
|
||||
# CMake 3.19 or later, this makes the calls to this function concise while
|
||||
# still allowing target property modification before finalization.
|
||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.19)
|
||||
# Need to wrap in an EVAL CODE or else ${target} won't be evaluated
|
||||
# due to special behavior of cmake_language() argument handling
|
||||
cmake_language(EVAL CODE "cmake_language(DEFER CALL qt6_finalize_target ${target})")
|
||||
else()
|
||||
set_target_properties("${target}" PROPERTIES _qt_is_immediately_finalized TRUE)
|
||||
qt6_finalize_target("${target}")
|
||||
endif()
|
||||
_qt_internal_finalize_target_defer("${target}")
|
||||
endfunction()
|
||||
|
||||
# Creates a library target by forwarding the arguments to add_library.
|
||||
|
Loading…
x
Reference in New Issue
Block a user