diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2022-09-16 16:27:45 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2022-09-23 13:53:27 +0200 |
commit | 67de96852d2c30ca241740c4b45d1414f540dc32 (patch) | |
tree | 33b31225fecfbcce7572580623c58309124a8c8d /src/corelib | |
parent | de8018557568465305cf3c9eb6e85f9a7608c26e (diff) |
CMake: Add finalization to plugins created with qt_add_plugin
Add the MANUAL_FINALIZATION option to qt_add_plugin and run
qt_finalize_target like we do for qt_add_executable and qt_add_library.
Currently, the only user-visible effect is that resource files are put
into a FOLDER and not underneath a XXX_other_files target.
Change-Id: I430d87b5357f6d2ed7fe32198a73eb919f393dd8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/Qt6CoreMacros.cmake | 19 | ||||
-rw-r--r-- | src/corelib/doc/src/cmake/qt_add_library.qdoc | 1 | ||||
-rw-r--r-- | src/corelib/doc/src/cmake/qt_add_plugin.qdoc | 14 |
3 files changed, 34 insertions, 0 deletions
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index bcb76d4256..dfd37c43af 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -1984,6 +1984,7 @@ endmacro() function(qt6_add_plugin target) _qt_internal_get_add_plugin_keywords(opt_args single_args multi_args) + list(APPEND opt_args MANUAL_FINALIZATION) cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}") @@ -2030,6 +2031,7 @@ function(qt6_add_plugin target) endif() _qt_internal_add_library(${target} ${type_to_create} ${arg_UNPARSED_ARGUMENTS}) + set_property(TARGET ${target} PROPERTY _qt_expects_finalization TRUE) get_target_property(target_type "${target}" TYPE) if (target_type STREQUAL "STATIC_LIBRARY") @@ -2107,6 +2109,23 @@ function(qt6_add_plugin target) endif() add_dependencies(qt_internal_plugins ${target}) endif() + + if(arg_MANUAL_FINALIZATION) + # Caller says they will call qt6_finalize_target() themselves later + 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() endfunction() if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) diff --git a/src/corelib/doc/src/cmake/qt_add_library.qdoc b/src/corelib/doc/src/cmake/qt_add_library.qdoc index 52b85d0476..3d932b5d5d 100644 --- a/src/corelib/doc/src/cmake/qt_add_library.qdoc +++ b/src/corelib/doc/src/cmake/qt_add_library.qdoc @@ -51,6 +51,7 @@ library created. The \c{qt_add_library()} command does not consider Any \c{sources} provided will be passed through to the internal call to \c{add_library()}. +\target qt_add_library finalization \section2 Finalization After a target is created, further processing or \e{finalization} steps may be diff --git a/src/corelib/doc/src/cmake/qt_add_plugin.qdoc b/src/corelib/doc/src/cmake/qt_add_plugin.qdoc index e4bacc36a9..43c40d544b 100644 --- a/src/corelib/doc/src/cmake/qt_add_plugin.qdoc +++ b/src/corelib/doc/src/cmake/qt_add_plugin.qdoc @@ -21,6 +21,7 @@ qt_add_plugin(target [SHARED | STATIC] [CLASS_NAME class_name] [OUTPUT_TARGETS variable_name] + [MANUAL_FINALIZATION] sources... ) \endcode @@ -67,4 +68,17 @@ project should also install these internal targets. The names of these targets can be obtained by providing the \c OUTPUT_TARGETS option, followed by the name of a variable in which to return the target list. +\section2 Finalization + +After a target is created, further processing or \e{finalization} steps may be +needed. The finalization processing is implemented by the +\l{qt6_finalize_target}{qt_finalize_target()} command. + +For details and the meaning of the \c{MANUAL_FINALIZATION} option, refer to the +\l{qt_add_library finalization}{finalization documentation} for +\c{qt_add_library}. + +\sa {qt6_finalize_target}{qt_finalize_target()}, + {qt6_add_executable}{qt_add_executable()} + */ |