From 19c32e7ee70bd6ad291fb76f7db015b712fe8981 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 27 Jan 2023 15:32:08 +0100 Subject: [PATCH] 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. Pick-to: 6.5 Change-Id: I06821d08042e1453f3e058ed90a13e90a4f06640 Reviewed-by: Alexandru Croitor --- src/corelib/Qt6CoreMacros.cmake | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index 9456687c31c..4cc8804a27e 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -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() function(_cat IN_FILE OUT_FILE) @@ -722,6 +712,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) @@ -729,6 +728,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)