summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexey Edelev <alexey.edelev@qt.io>2022-01-31 18:53:57 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-02-02 21:25:10 +0000
commitadaddfe1b78709690f4de7265d60ee1bfdc48b1a (patch)
tree6bc11d502371a1618bc5ff01d76146f5a39c303e /cmake
parent3e6a44130f10a7677aeb561e0c266f9e5d53b40d (diff)
Add qt_internal_undefine_global_definition function
qt_internal_undefine_global_definition disables an internal global definition that is defined by the qt_internal_add_global_definition function for a specific target. Remove the ability to set the custom "undefine" flag for the definitions since it's hard to control it using the introduced function. Task-number: QTBUG-100334 Change-Id: Ic1637d97aa51bbdd06c5b191c57a941aa208d4dc Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit fd3341a74ecbe93c5fb931f625075b93be69b9de) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtInternalTargets.cmake11
-rw-r--r--cmake/QtTargetHelpers.cmake17
-rw-r--r--cmake/QtTestHelpers.cmake12
3 files changed, 23 insertions, 17 deletions
diff --git a/cmake/QtInternalTargets.cmake b/cmake/QtInternalTargets.cmake
index fb235baffb..cdbb1777e9 100644
--- a/cmake/QtInternalTargets.cmake
+++ b/cmake/QtInternalTargets.cmake
@@ -73,10 +73,7 @@ function(qt_internal_set_warnings_are_errors_flags target)
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.
+# property-based switch to disable the definition.
# 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
@@ -87,10 +84,9 @@ endfunction()
# 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(single_value_args VALUE)
set(multi_value_args SCOPE)
cmake_parse_arguments(args
"${optional_args}"
@@ -105,9 +101,6 @@ function(qt_internal_add_global_definition definition)
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}")
diff --git a/cmake/QtTargetHelpers.cmake b/cmake/QtTargetHelpers.cmake
index 74044ec166..d26e84ce16 100644
--- a/cmake/QtTargetHelpers.cmake
+++ b/cmake/QtTargetHelpers.cmake
@@ -857,3 +857,20 @@ function(qt_internal_add_target_include_dirs_and_optionally_propagate target dep
qt_record_extra_third_party_dependency("${target}" "${dep_target}")
endfunction()
+
+# The function disables one or multiple internal global definitions that are defined by the
+# qt_internal_add_global_definition function for a specific 'target'.
+function(qt_internal_undefine_global_definition target)
+ if(NOT TARGET ${target})
+ message(FATAL_ERROR "${target} is not a target.")
+ endif()
+
+ if("${ARGN}" STREQUAL "")
+ message(FATAL_ERROR "The function expects at least one definition as an argument.")
+ endif()
+
+ foreach(definition IN LISTS ARGN)
+ set(undef_property_name "QT_INTERNAL_UNDEF_${definition}")
+ set_target_properties(${target} PROPERTIES "${undef_property_name}" TRUE)
+ endforeach()
+endfunction()
diff --git a/cmake/QtTestHelpers.cmake b/cmake/QtTestHelpers.cmake
index a6d0be58c4..e85c4e4397 100644
--- a/cmake/QtTestHelpers.cmake
+++ b/cmake/QtTestHelpers.cmake
@@ -34,8 +34,7 @@ function(qt_internal_add_benchmark target)
)
# Disable the QT_NO_NARROWING_CONVERSIONS_IN_CONNECT define for benchmarks
- set_target_properties(${target} PROPERTIES
- QT_INTERNAL_UNDEF_QT_NO_NARROWING_CONVERSIONS_IN_CONNECT TRUE)
+ qt_internal_undefine_global_definition(${target} QT_NO_NARROWING_CONVERSIONS_IN_CONNECT)
qt_internal_collect_command_environment(benchmark_env_path benchmark_env_plugin_path)
@@ -97,8 +96,7 @@ function(qt_internal_add_manual_test target)
)
# Disable the QT_NO_NARROWING_CONVERSIONS_IN_CONNECT define for manual tests
- set_target_properties(${target} PROPERTIES
- QT_INTERNAL_UNDEF_QT_NO_NARROWING_CONVERSIONS_IN_CONNECT TRUE)
+ qt_internal_undefine_global_definition(${target} QT_NO_NARROWING_CONVERSIONS_IN_CONNECT)
endfunction()
@@ -240,8 +238,7 @@ function(qt_internal_add_test name)
)
# Disable the QT_NO_NARROWING_CONVERSIONS_IN_CONNECT define for tests
- set_target_properties(${name} PROPERTIES
- QT_INTERNAL_UNDEF_QT_NO_NARROWING_CONVERSIONS_IN_CONNECT TRUE)
+ qt_internal_undefine_global_definition(${name} QT_NO_NARROWING_CONVERSIONS_IN_CONNECT)
# Tests should not be bundles on macOS even if arg_GUI is true, because some tests make
# assumptions about the location of helper processes, and those paths would be different
@@ -631,8 +628,7 @@ function(qt_internal_add_test_helper name)
qt_internal_add_executable("${name}" NO_INSTALL ${extra_args_to_pass} ${forward_args})
# Disable the QT_NO_NARROWING_CONVERSIONS_IN_CONNECT define for test helpers
- set_target_properties(${name} PROPERTIES
- QT_INTERNAL_UNDEF_QT_NO_NARROWING_CONVERSIONS_IN_CONNECT TRUE)
+ qt_internal_undefine_global_definition(${name} QT_NO_NARROWING_CONVERSIONS_IN_CONNECT)
endfunction()