summaryrefslogtreecommitdiffstats
path: root/cmake/QtBuild.cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-07-27 10:17:04 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-07-31 12:55:32 +0200
commitb3b1e4737808bc2f2ccaef88d133404877ebce58 (patch)
treec102293b7dfe24c7989a425aad4d384bff568933 /cmake/QtBuild.cmake
parent704e215295954fc45b4f4c3fce4ba214cf3050cb (diff)
CMake: Introduce qt_internal_add_app
This new function is meant to be used where load(qt_app) is used. It delegates functionality to qt_add_executable, while handling some additional behavior via a finalization function (mostly handling of macOS Info.plist files and icons, as well as Windows icons and resource files) It uses a new PlatformAppInternal interface target. Task-number: QTBUG-85757 Change-Id: I1a2d5851b137fcd4a6323e0e06fb154f91619800 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Diffstat (limited to 'cmake/QtBuild.cmake')
-rw-r--r--cmake/QtBuild.cmake56
1 files changed, 49 insertions, 7 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
index 34757728bb..9fd5b3c244 100644
--- a/cmake/QtBuild.cmake
+++ b/cmake/QtBuild.cmake
@@ -2503,6 +2503,8 @@ function(qt_watch_current_list_dir variable access value current_list_file stack
qt_finalize_module(${a1} ${a2} ${a3} ${a4} ${a5} ${a6} ${a7} ${a8} ${a9})
elseif(func STREQUAL "qt_finalize_plugin")
qt_finalize_plugin(${a1} ${a2} ${a3} ${a4} ${a5} ${a6} ${a7} ${a8} ${a9})
+ elseif(func STREQUAL "qt_internal_finalize_app")
+ qt_internal_finalize_app(${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()
@@ -2569,6 +2571,32 @@ function(qt_set_target_info_properties target)
QT_TARGET_PRODUCT_NAME "${arg_TARGET_PRODUCT}")
endfunction()
+# Uses the QT_DELAYED_TARGET_* property values to set the final QT_TARGET_* properties.
+# Needed when doing executable finalization at the end of a subdirectory scope
+# (aka scope finalization).
+function(qt_internal_set_target_info_properties_from_delayed_properties target)
+ set(args "")
+ foreach(prop ${__default_target_info_args})
+ get_target_property(prop_value "${target}" "QT_DELAYED_${prop}")
+ list(APPEND args "${prop}" "${prop_value}")
+ endforeach()
+ qt_set_target_info_properties(${target} ${args})
+endfunction()
+
+# Updates the QT_DELAYED_ properties with values from the QT_ variants, in case if they were
+# set in-between a qt_add_* call and before scope finalization.
+function(qt_internal_update_delayed_target_info_properties target)
+ foreach(prop ${__default_target_info_args})
+ get_target_property(prop_value "${target}" "QT_${prop}")
+ get_target_property(delayed_prop_value ${target} "QT_DELAYED_${prop}")
+ set(final_value "${delayed_prop_value}")
+ if(prop_value)
+ set(final_value "${prop_value}")
+ endif()
+ set_target_properties(${target} PROPERTIES "QT_DELAYED_${prop}" "${final_value}")
+ endforeach()
+endfunction()
+
# This is the main entry function for creating a Qt module, that typically
# consists of a library, public header files, private header files and configurable
# features.
@@ -3962,7 +3990,7 @@ endfunction()
# Collection of qt_add_executable arguments so they can be shared across qt_add_executable
# and qt_add_test_helper.
set(__qt_add_executable_optional_args
- "GUI;BOOTSTRAP;NO_QT;NO_INSTALL;EXCEPTIONS"
+ "GUI;BOOTSTRAP;NO_QT;NO_INSTALL;EXCEPTIONS;DELAY_RC;DELAY_TARGET_INFO"
)
set(__qt_add_executable_single_args
"OUTPUT_DIRECTORY;INSTALL_DIRECTORY;VERSION"
@@ -4023,15 +4051,27 @@ function(qt_add_executable name)
endif()
endif()
- if("${arg_TARGET_DESCRIPTION}" STREQUAL "")
- set(arg_TARGET_DESCRIPTION "Qt ${name}")
+ if(arg_DELAY_TARGET_INFO)
+ # Delay the setting of target info properties if requested. Needed for scope finalization
+ # of Qt apps.
+ set_target_properties("${name}" PROPERTIES
+ QT_DELAYED_TARGET_VERSION "${arg_VERSION}"
+ QT_DELAYED_TARGET_PRODUCT "${arg_TARGET_PRODUCT}"
+ QT_DELAYED_TARGET_DESCRIPTION "${arg_TARGET_DESCRIPTION}"
+ QT_DELAYED_TARGET_COMPANY "${arg_TARGET_COMPANY}"
+ QT_DELAYED_TARGET_COPYRIGHT "${arg_TARGET_COPYRIGHT}"
+ )
+ else()
+ if("${arg_TARGET_DESCRIPTION}" STREQUAL "")
+ set(arg_TARGET_DESCRIPTION "Qt ${name}")
+ endif()
+ qt_set_target_info_properties(${name} ${ARGN}
+ TARGET_DESCRIPTION "${arg_TARGET_DESCRIPTION}"
+ TARGET_VERSION "${arg_VERSION}")
endif()
- qt_set_target_info_properties(${name} ${ARGN}
- TARGET_DESCRIPTION "${arg_TARGET_DESCRIPTION}"
- TARGET_VERSION "${arg_VERSION}")
- if (WIN32)
+ if (WIN32 AND NOT arg_DELAY_RC)
qt6_generate_win32_rc_file(${name})
endif()
@@ -6027,6 +6067,8 @@ function(qt_internal_apply_win_prefix_and_suffix target)
endif()
endfunction()
+include(QtApp)
+
# Compatibility macros that should be removed once all their usages are removed.
function(extend_target)
qt_extend_target(${ARGV})