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>
This commit is contained in:
Alexey Edelev 2021-01-22 14:06:49 +01:00
parent f2f5c7d2b7
commit 1d28fd7a9c
7 changed files with 90 additions and 12 deletions

View File

@ -72,6 +72,62 @@ function(qt_internal_set_warnings_are_errors_flags target)
target_compile_options("${target}" INTERFACE "${flags_generator_expression}") target_compile_options("${target}" INTERFACE "${flags_generator_expression}")
endfunction() 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(PlatformCommonInternal INTERFACE)
add_library(Qt::PlatformCommonInternal ALIAS PlatformCommonInternal) add_library(Qt::PlatformCommonInternal ALIAS PlatformCommonInternal)
target_link_libraries(PlatformCommonInternal INTERFACE Platform) target_link_libraries(PlatformCommonInternal INTERFACE Platform)
@ -92,6 +148,9 @@ add_library(PlatformToolInternal INTERFACE)
add_library(Qt::PlatformToolInternal ALIAS PlatformToolInternal) add_library(Qt::PlatformToolInternal ALIAS PlatformToolInternal)
target_link_libraries(PlatformToolInternal INTERFACE PlatformAppInternal) 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) if(WARNINGS_ARE_ERRORS)
qt_internal_set_warnings_are_errors_flags(PlatformModuleInternal) qt_internal_set_warnings_are_errors_flags(PlatformModuleInternal)
qt_internal_set_warnings_are_errors_flags(PlatformPluginInternal) qt_internal_set_warnings_are_errors_flags(PlatformPluginInternal)

View File

@ -33,6 +33,10 @@ function(qt_internal_add_benchmark target)
${exec_args} ${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) qt_internal_collect_command_environment(benchmark_env_path benchmark_env_plugin_path)
# Add a ${target}_benchmark generator target, to run single benchmark more easily. # 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} ${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() endfunction()
# This function will configure the fixture for the network tests that require docker network services # 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_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 # 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 # assumptions about the location of helper processes, and those paths would be different
# if a test is built as a bundle. # if a test is built as a bundle.
@ -617,6 +629,11 @@ function(qt_internal_add_test_helper name)
endif() endif()
qt_internal_add_executable("${name}" NO_INSTALL ${extra_args_to_pass} ${forward_args}) 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() endfunction()
function(qt_internal_wrap_command_arguments argument_list) function(qt_internal_wrap_command_arguments argument_list)

View File

@ -7,8 +7,6 @@
qt_internal_add_test(tst_qfuture qt_internal_add_test(tst_qfuture
SOURCES SOURCES
tst_qfuture.cpp tst_qfuture.cpp
# DEFINES
# -QT_NO_JAVA_STYLE_ITERATORS
PUBLIC_LIBRARIES PUBLIC_LIBRARIES
Qt::CorePrivate Qt::CorePrivate
) )
@ -17,3 +15,6 @@ qt_internal_extend_target(tst_qfuture CONDITION MSVC
COMPILE_OPTIONS COMPILE_OPTIONS
/bigobj /bigobj
) )
set_target_properties(tst_qfuture PROPERTIES
QT_INTERNAL_UNDEF_QT_NO_JAVA_STYLE_ITERATORS TRUE)

View File

@ -7,6 +7,7 @@
qt_internal_add_test(tst_collections qt_internal_add_test(tst_collections
SOURCES SOURCES
tst_collections.cpp 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)

View File

@ -7,6 +7,7 @@
qt_internal_add_test(tst_qhash qt_internal_add_test(tst_qhash
SOURCES SOURCES
tst_qhash.cpp 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)

View File

@ -7,6 +7,7 @@
qt_internal_add_test(tst_qmap qt_internal_add_test(tst_qmap
SOURCES SOURCES
tst_qmap.cpp 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)

View File

@ -7,9 +7,7 @@
qt_internal_add_test(tst_qset qt_internal_add_test(tst_qset
SOURCES SOURCES
tst_qset.cpp 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)