summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmake/QtInternalTargets.cmake59
-rw-r--r--cmake/QtTestHelpers.cmake17
-rw-r--r--tests/auto/corelib/thread/qfuture/CMakeLists.txt5
-rw-r--r--tests/auto/corelib/tools/collections/CMakeLists.txt5
-rw-r--r--tests/auto/corelib/tools/qhash/CMakeLists.txt5
-rw-r--r--tests/auto/corelib/tools/qmap/CMakeLists.txt5
-rw-r--r--tests/auto/corelib/tools/qset/CMakeLists.txt6
7 files changed, 90 insertions, 12 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)
diff --git a/cmake/QtTestHelpers.cmake b/cmake/QtTestHelpers.cmake
index 6c9ecba069..79e69f231b 100644
--- a/cmake/QtTestHelpers.cmake
+++ b/cmake/QtTestHelpers.cmake
@@ -33,6 +33,10 @@ function(qt_internal_add_benchmark target)
${exec_args}
)
+ # 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_collect_command_environment(benchmark_env_path benchmark_env_plugin_path)
# Add a ${target}_benchmark generator target, to run single benchmark more easily.
@@ -92,6 +96,10 @@ function(qt_internal_add_manual_test target)
${exec_args}
)
+ # 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)
+
endfunction()
# This function will configure the fixture for the network tests that require docker network services
@@ -231,6 +239,10 @@ function(qt_internal_add_test name)
DISABLE_AUTOGEN_TOOLS ${arg_DISABLE_AUTOGEN_TOOLS}
)
+ # 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)
+
# 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
# if a test is built as a bundle.
@@ -617,6 +629,11 @@ function(qt_internal_add_test_helper name)
endif()
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)
+
endfunction()
function(qt_internal_wrap_command_arguments argument_list)
diff --git a/tests/auto/corelib/thread/qfuture/CMakeLists.txt b/tests/auto/corelib/thread/qfuture/CMakeLists.txt
index 7844cf31b9..0d0a2cb4bc 100644
--- a/tests/auto/corelib/thread/qfuture/CMakeLists.txt
+++ b/tests/auto/corelib/thread/qfuture/CMakeLists.txt
@@ -7,8 +7,6 @@
qt_internal_add_test(tst_qfuture
SOURCES
tst_qfuture.cpp
-# DEFINES
-# -QT_NO_JAVA_STYLE_ITERATORS
PUBLIC_LIBRARIES
Qt::CorePrivate
)
@@ -17,3 +15,6 @@ qt_internal_extend_target(tst_qfuture CONDITION MSVC
COMPILE_OPTIONS
/bigobj
)
+
+set_target_properties(tst_qfuture PROPERTIES
+ QT_INTERNAL_UNDEF_QT_NO_JAVA_STYLE_ITERATORS TRUE)
diff --git a/tests/auto/corelib/tools/collections/CMakeLists.txt b/tests/auto/corelib/tools/collections/CMakeLists.txt
index 32ef8d7506..685d3761fb 100644
--- a/tests/auto/corelib/tools/collections/CMakeLists.txt
+++ b/tests/auto/corelib/tools/collections/CMakeLists.txt
@@ -7,6 +7,7 @@
qt_internal_add_test(tst_collections
SOURCES
tst_collections.cpp
- DEFINES
- # -QT_NO_JAVA_STYLE_ITERATORS # special case remove
)
+
+set_target_properties(tst_collections PROPERTIES
+ QT_INTERNAL_UNDEF_QT_NO_JAVA_STYLE_ITERATORS TRUE)
diff --git a/tests/auto/corelib/tools/qhash/CMakeLists.txt b/tests/auto/corelib/tools/qhash/CMakeLists.txt
index b01782aed5..ba038c8f01 100644
--- a/tests/auto/corelib/tools/qhash/CMakeLists.txt
+++ b/tests/auto/corelib/tools/qhash/CMakeLists.txt
@@ -7,6 +7,7 @@
qt_internal_add_test(tst_qhash
SOURCES
tst_qhash.cpp
- DEFINES
- #-QT_NO_JAVA_STYLE_ITERATORS # special case remove
)
+
+set_target_properties(tst_qhash PROPERTIES
+ QT_INTERNAL_UNDEF_QT_NO_JAVA_STYLE_ITERATORS TRUE)
diff --git a/tests/auto/corelib/tools/qmap/CMakeLists.txt b/tests/auto/corelib/tools/qmap/CMakeLists.txt
index c0a2cb79ab..b5d36bf214 100644
--- a/tests/auto/corelib/tools/qmap/CMakeLists.txt
+++ b/tests/auto/corelib/tools/qmap/CMakeLists.txt
@@ -7,6 +7,7 @@
qt_internal_add_test(tst_qmap
SOURCES
tst_qmap.cpp
- DEFINES
- #-QT_NO_JAVA_STYLE_ITERATORS # special case remove
)
+
+set_target_properties(tst_qmap PROPERTIES
+ QT_INTERNAL_UNDEF_QT_NO_JAVA_STYLE_ITERATORS TRUE)
diff --git a/tests/auto/corelib/tools/qset/CMakeLists.txt b/tests/auto/corelib/tools/qset/CMakeLists.txt
index ed92c1e036..f24d0da212 100644
--- a/tests/auto/corelib/tools/qset/CMakeLists.txt
+++ b/tests/auto/corelib/tools/qset/CMakeLists.txt
@@ -7,9 +7,7 @@
qt_internal_add_test(tst_qset
SOURCES
tst_qset.cpp
- #DEFINES # special case remove
- #-QT_NO_JAVA_STYLE_ITERATORS # special case remove
)
-## Scopes:
-#####################################################################
+set_target_properties(tst_qset PROPERTIES
+ QT_INTERNAL_UNDEF_QT_NO_JAVA_STYLE_ITERATORS TRUE)