Skip to content

Commit

Permalink
CMake: Warn about double qt6_finalize_target for plugins and libs
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jobor committed Feb 7, 2023
1 parent 3c66def commit 19c32e7
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/corelib/Qt6CoreMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -722,13 +712,24 @@ 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)

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)
Expand Down

0 comments on commit 19c32e7

Please sign in to comment.