diff --git a/cmake/QtInternalTargets.cmake b/cmake/QtInternalTargets.cmake index 13cd11b909f..221ca7c2a78 100644 --- a/cmake/QtInternalTargets.cmake +++ b/cmake/QtInternalTargets.cmake @@ -94,10 +94,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( PROPERTIES QT_INTERNAL_UNDEF_ TRUE) -# where 'QT_INTERNAL_UNDEF_' 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 @@ -108,10 +105,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}" @@ -126,9 +122,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 74044ec1661..d26e84ce16c 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 a6d0be58c42..e85c4e4397b 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 0d0a2cb4bc1..7321f89d838 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 685d3761fbe..a52bc6a7729 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 ba038c8f011..93535f2c664 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 b5d36bf214d..30c170e9fe1 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 f24d0da2125..b56a0a210cf 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)