diff options
author | Alexey Edelev <alexey.edelev@qt.io> | 2021-01-22 14:06:49 +0100 |
---|---|---|
committer | Alexey Edelev <alexey.edelev@qt.io> | 2022-01-31 17:40:43 +0100 |
commit | 1d28fd7a9c4720289f3d41db2ed8e6fcb07d5a30 (patch) | |
tree | 0be203a249dbd46f2a518f2ded82a7a5950d81c1 /cmake/QtInternalTargets.cmake | |
parent | f2f5c7d2b71a93ff826e3731cbb80febe5c7b308 (diff) |
Restore missing Qt definitions
Restore the 'QT_NO_JAVA_STYLE_ITERATORS' and
'QT_NO_NARROWING_CONVERSIONS_IN_CONNECT' definitions for Qt
targets.
Add the function that adds global definitions for Qt targets according
to the provided scope and the target property-based switch to disable
the definition for a specific target.
Pick-to: 6.2 6.3
Task-number: QTBUG-100295
Change-Id: I28697e81f9aabc45c48d79aae1e5caea141e04e1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtInternalTargets.cmake')
-rw-r--r-- | cmake/QtInternalTargets.cmake | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/cmake/QtInternalTargets.cmake b/cmake/QtInternalTargets.cmake index 693c0eb83f..72e6b6ab9a 100644 --- a/cmake/QtInternalTargets.cmake +++ b/cmake/QtInternalTargets.cmake @@ -72,6 +72,62 @@ function(qt_internal_set_warnings_are_errors_flags target) target_compile_options("${target}" INTERFACE "${flags_generator_expression}") endfunction() +# The function adds a global 'definition' to the platform internal targets and the target +# property-based switch to disable the definition. The following command disables the definition for +# a specific target: +# set_target_properties(<target> PROPERTIES QT_INTERNAL_UNDEF_<definition> TRUE) +# where 'QT_INTERNAL_UNDEF_<definition>' might be customized using the UNDEF_PROPERTY_NAME option. +# Arguments: +# VALUE optional value that the definition will take. +# SCOPE the list of scopes the definition needs to be set for. If the SCOPE is not specified the +# definition is added to PlatformCommonInternal target. +# Possible values: +# MODULE - set the definition for all Qt modules +# PLUGIN - set the definition for all Qt plugins +# TOOL - set the definition for all Qt tools +# APP - set the definition for all Qt applications +# TODO: Add a tests specific platform target and the definition scope for it. +# UNDEF_PROPERTY_NAME customizes the name of the target property to avoid adding the definition. +function(qt_internal_add_global_definition definition) + set(optional_args) + set(single_value_args VALUE UNDEF_PROPERTY_NAME) + set(multi_value_args SCOPE) + cmake_parse_arguments(args + "${optional_args}" + "${single_value_args}" + "${multi_value_args}" + ${ARGN} + ) + + set(scope_MODULE PlatformModuleInternal) + set(scope_PLUGIN PlatformPluginInternal) + set(scope_TOOL PlatformToolInternal) + set(scope_APP PlatformAppInternal) + + set(undef_property_name "QT_INTERNAL_UNDEF_${definition}") + if(DEFINED arg_UNDEF_PROPERTY_NAME) + set(undef_property_name "${arg_UNDEF_PROPERTY_NAME}") + endif() + + if(DEFINED arg_VALUE) + set(definition "${definition}=${arg_VALUE}") + endif() + + set(definition_genex + "$<$<NOT:$<BOOL:$<TARGET_PROPERTY:${undef_property_name}>>>:${definition}>") + + if(NOT DEFINED arg_SCOPE) + target_compile_definitions(PlatformCommonInternal INTERFACE "${definition_genex}") + else() + foreach(scope IN LISTS arg_SCOPE) + if(NOT DEFINED scope_${scope}) + message(FATAL_ERROR "Unknown scope ${scope}.") + endif() + target_compile_definitions("${scope_${scope}}" INTERFACE "${definition_genex}") + endforeach() + endif() +endfunction() + add_library(PlatformCommonInternal INTERFACE) add_library(Qt::PlatformCommonInternal ALIAS PlatformCommonInternal) target_link_libraries(PlatformCommonInternal INTERFACE Platform) @@ -92,6 +148,9 @@ add_library(PlatformToolInternal INTERFACE) add_library(Qt::PlatformToolInternal ALIAS PlatformToolInternal) target_link_libraries(PlatformToolInternal INTERFACE PlatformAppInternal) +qt_internal_add_global_definition(QT_NO_JAVA_STYLE_ITERATORS) +qt_internal_add_global_definition(QT_NO_NARROWING_CONVERSIONS_IN_CONNECT) + if(WARNINGS_ARE_ERRORS) qt_internal_set_warnings_are_errors_flags(PlatformModuleInternal) qt_internal_set_warnings_are_errors_flags(PlatformPluginInternal) |