Skip to content

Commit

Permalink
Add qt_internal_undefine_global_definition function
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Qt CI Bot <[email protected]>
(cherry picked from commit fd3341a)
Reviewed-by: Qt Cherry-pick Bot <[email protected]>
  • Loading branch information
semlanik authored and Qt Cherry-pick Bot committed Feb 2, 2022
1 parent bd269f6 commit 102aed7
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 27 deletions.
11 changes: 2 additions & 9 deletions cmake/QtInternalTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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(<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
Expand All @@ -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}"
Expand All @@ -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}")
Expand Down
17 changes: 17 additions & 0 deletions cmake/QtTargetHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
12 changes: 4 additions & 8 deletions cmake/QtTestHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down
3 changes: 1 addition & 2 deletions tests/auto/corelib/thread/qfuture/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 1 addition & 2 deletions tests/auto/corelib/tools/collections/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 1 addition & 2 deletions tests/auto/corelib/tools/qhash/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 1 addition & 2 deletions tests/auto/corelib/tools/qmap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 1 addition & 2 deletions tests/auto/corelib/tools/qset/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 102aed7

Please sign in to comment.