CMake: Warn about double qt6_finalize_target for plugins and libs

qt6_finalize_target warned about double invocations on executables
already. For libraries and plugins this situation wasn't detected.

Make the warning consistent for qt6_add_executable, qt6_add_library and
qt6_add_plugin. The internal property _qt_executable_is_finalized has
been renamed to _qt_is_finalized and applies to all targets that can be
finalized.

Change-Id: I06821d08042e1453f3e058ed90a13e90a4f06640
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit 19c32e7ee70bd6ad291fb76f7db015b712fe8981)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Joerg Bornemann 2023-01-27 15:32:08 +01:00 committed by Qt Cherry-pick Bot
parent ffd312d565
commit 5b9b2d8f3f

View File

@ -592,14 +592,6 @@ function(_qt_internal_create_executable target)
endfunction()
function(_qt_internal_finalize_executable target)
get_target_property(is_finalized "${target}" _qt_executable_is_finalized)
if(is_finalized)
message(AUTHOR_WARNING
"Tried to call qt6_finalize_target twice on executable: '${target}'. \
Did you forget to specify MANUAL_FINALIZATION to qt6_add_executable?")
return()
endif()
# We can't evaluate generator expressions at configure time, so we can't
# ask for any transitive properties or even the full library dependency
# chain.
@ -666,8 +658,6 @@ function(_qt_internal_finalize_executable target)
__qt_internal_apply_plugin_imports_finalizer_mode("${target}")
__qt_internal_process_dependency_object_libraries("${target}")
endif()
set_target_properties(${target} PROPERTIES _qt_executable_is_finalized TRUE)
endfunction()
# If a task needs to run before any targets are finalized in the current directory
@ -702,6 +692,15 @@ function(qt6_finalize_target target)
message(FATAL_ERROR "No target '${target}' found in current scope.")
endif()
get_target_property(is_finalized "${target}" _qt_is_finalized)
if(is_finalized)
message(AUTHOR_WARNING
"Tried to call qt6_finalize_target twice on target '${target}'. "
"Did you forget to specify MANUAL_FINALIZATION to qt6_add_executable, "
"qt6_add_library or qt6_add_plugin?")
return()
endif()
_qt_internal_expose_deferred_files_to_ide(${target})
get_target_property(target_type ${target} TYPE)
get_target_property(is_android_executable "${target}" _qt_is_android_executable)
@ -709,6 +708,8 @@ function(qt6_finalize_target target)
if(target_type STREQUAL "EXECUTABLE" OR is_android_executable)
_qt_internal_finalize_executable(${ARGV})
endif()
set_target_properties(${target} PROPERTIES _qt_is_finalized TRUE)
endfunction()
function(_qt_internal_darwin_permission_finalizer target)