summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Edelev <alexey.edelev@qt.io>2022-01-31 18:53:57 +0100
committerAlexey Edelev <alexey.edelev@qt.io>2022-02-02 16:45:37 +0100
commitfd3341a74ecbe93c5fb931f625075b93be69b9de (patch)
treedd0df47448e832b524c91b945bfcc890607a9730
parent1b34ee080e0b336233d2be8422c4476569251da6 (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. Pick-to: 6.2 6.3 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>
-rw-r--r--cmake/QtInternalTargets.cmake11
-rw-r--r--cmake/QtTargetHelpers.cmake17
-rw-r--r--cmake/QtTestHelpers.cmake12
-rw-r--r--tests/auto/corelib/thread/qfuture/CMakeLists.txt3
-rw-r--r--tests/auto/corelib/tools/collections/CMakeLists.txt3
-rw-r--r--tests/auto/corelib/tools/qhash/CMakeLists.txt3
-rw-r--r--tests/auto/corelib/tools/qmap/CMakeLists.txt3
-rw-r--r--tests/auto/corelib/tools/qset/CMakeLists.txt3
8 files changed, 28 insertions, 27 deletions
diff --git a/cmake/QtInternalTargets.cmake b/cmake/QtInternalTargets.cmake
index 72e6b6ab9a..e2eee5b89e 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 52d0e619bb..70bca2267e 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()
diff --git a/tests/auto/corelib/thread/qfuture/CMakeLists.txt b/tests/auto/corelib/thread/qfuture/CMakeLists.txt
index 0d0a2cb4bc..7321f89d83 100644
--- a/tests/auto/corelib/thread/qfuture/CMakeLists.txt
+++ b/tests/auto/corelib/thread/qfuture/CMakeLists.txt
@@ -16,5 +16,4 @@ qt_internal_extend_target(tst_qfuture CONDITION MSVC
/bigobj
)
-set_target_properties(tst_qfuture PROPERTIES
- QT_INTERNAL_UNDEF_QT_NO_JAVA_STYLE_ITERATORS TRUE)
+qt_internal_undefine_global_definition(tst_qfuture QT_NO_JAVA_STYLE_ITERATORS)
diff --git a/tests/auto/corelib/tools/collections/CMakeLists.txt b/tests/auto/corelib/tools/collections/CMakeLists.txt
index 685d3761fb..a52bc6a772 100644
--- a/tests/auto/corelib/tools/collections/CMakeLists.txt
+++ b/tests/auto/corelib/tools/collections/CMakeLists.txt
@@ -9,5 +9,4 @@ qt_internal_add_test(tst_collections
tst_collections.cpp
)
-set_target_properties(tst_collections PROPERTIES
- QT_INTERNAL_UNDEF_QT_NO_JAVA_STYLE_ITERATORS TRUE)
+qt_internal_undefine_global_definition(tst_collections QT_NO_JAVA_STYLE_ITERATORS)
diff --git a/tests/auto/corelib/tools/qhash/CMakeLists.txt b/tests/auto/corelib/tools/qhash/CMakeLists.txt
index ba038c8f01..93535f2c66 100644
--- a/tests/auto/corelib/tools/qhash/CMakeLists.txt
+++ b/tests/auto/corelib/tools/qhash/CMakeLists.txt
@@ -9,5 +9,4 @@ qt_internal_add_test(tst_qhash
tst_qhash.cpp
)
-set_target_properties(tst_qhash PROPERTIES
- QT_INTERNAL_UNDEF_QT_NO_JAVA_STYLE_ITERATORS TRUE)
+qt_internal_undefine_global_definition(tst_qhash QT_NO_JAVA_STYLE_ITERATORS)
diff --git a/tests/auto/corelib/tools/qmap/CMakeLists.txt b/tests/auto/corelib/tools/qmap/CMakeLists.txt
index b5d36bf214..30c170e9fe 100644
--- a/tests/auto/corelib/tools/qmap/CMakeLists.txt
+++ b/tests/auto/corelib/tools/qmap/CMakeLists.txt
@@ -9,5 +9,4 @@ qt_internal_add_test(tst_qmap
tst_qmap.cpp
)
-set_target_properties(tst_qmap PROPERTIES
- QT_INTERNAL_UNDEF_QT_NO_JAVA_STYLE_ITERATORS TRUE)
+qt_internal_undefine_global_definition(tst_qmap QT_NO_JAVA_STYLE_ITERATORS)
diff --git a/tests/auto/corelib/tools/qset/CMakeLists.txt b/tests/auto/corelib/tools/qset/CMakeLists.txt
index f24d0da212..b56a0a210c 100644
--- a/tests/auto/corelib/tools/qset/CMakeLists.txt
+++ b/tests/auto/corelib/tools/qset/CMakeLists.txt
@@ -9,5 +9,4 @@ qt_internal_add_test(tst_qset
tst_qset.cpp
)
-set_target_properties(tst_qset PROPERTIES
- QT_INTERNAL_UNDEF_QT_NO_JAVA_STYLE_ITERATORS TRUE)
+qt_internal_undefine_global_definition(tst_qset QT_NO_JAVA_STYLE_ITERATORS)