summaryrefslogtreecommitdiffstats
path: root/cmake/QtTestHelpers.cmake
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2022-08-15 19:20:39 +0200
committerIvan Solovev <ivan.solovev@qt.io>2022-09-06 16:57:58 +0200
commit734e0a2fbe18546780fb350af5e8b4ee2eb16d68 (patch)
tree364b0f69518b4bcd3031359e788cb6a9056f82a9 /cmake/QtTestHelpers.cmake
parentd674f3f5454fb39de9405484a8c01fb928523f67 (diff)
CMake: propagate deprecation definitions to unit-tests
If Qt itself is built without the deprecated APIs, but the tests are not, tests will fail to compile and/or link. This patch makes sure that the specified QT_DISABLE_DEPRECATED_UP_TO and QT_WARN_DEPRECATED_UP_TO values are correctly used in the tests. The definitions are propagated to tests, batched tests, manual tests and benchmarks. Fixes: QTBUG-104858 Change-Id: Idf15accaf96c47599084426ba625b985f507ca8b Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtTestHelpers.cmake')
-rw-r--r--cmake/QtTestHelpers.cmake21
1 files changed, 20 insertions, 1 deletions
diff --git a/cmake/QtTestHelpers.cmake b/cmake/QtTestHelpers.cmake
index 9ea4b4d669..7e58fe08ed 100644
--- a/cmake/QtTestHelpers.cmake
+++ b/cmake/QtTestHelpers.cmake
@@ -33,11 +33,17 @@ function(qt_internal_add_benchmark target)
set(arg_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endif()
+ qt_internal_library_deprecation_level(deprecation_define)
+
qt_internal_add_executable(${target}
NO_INSTALL # we don't install benchmarks
OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}" # avoid polluting bin directory
${exec_args}
)
+ qt_internal_extend_target(${target}
+ DEFINES
+ ${deprecation_define}
+ )
# Benchmarks on iOS must be app bundles.
if(IOS)
@@ -111,11 +117,17 @@ function(qt_internal_add_manual_test target)
set(arg_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endif()
+ qt_internal_library_deprecation_level(deprecation_define)
+
qt_internal_add_executable(${target}
NO_INSTALL # we don't install benchmarks
OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}" # avoid polluting bin directory
${exec_args}
)
+ qt_internal_extend_target(${target}
+ DEFINES
+ ${deprecation_define}
+ )
# Tests on iOS must be app bundles.
if(IOS)
@@ -327,13 +339,17 @@ function(qt_internal_add_test_to_batch batch_name name)
list(PREPEND batched_test_list ${name})
set_property(GLOBAL PROPERTY _qt_batched_test_list_property ${batched_test_list})
+ qt_internal_library_deprecation_level(deprecation_define)
+
# Merge the current test with the rest of the batch
qt_internal_extend_target(${target}
INCLUDE_DIRECTORIES ${arg_INCLUDE_DIRECTORIES}
PUBLIC_LIBRARIES ${arg_PUBLIC_LIBRARIES}
LIBRARIES ${arg_LIBRARIES}
SOURCES ${arg_SOURCES}
- DEFINES ${arg_DEFINES}
+ DEFINES
+ ${arg_DEFINES}
+ ${deprecation_define}
COMPILE_OPTIONS ${arg_COMPILE_OPTIONS}
COMPILE_FLAGS ${arg_COMPILE_FLAGS}
LINK_OPTIONS ${arg_LINK_OPTIONS}
@@ -426,6 +442,8 @@ function(qt_internal_add_test name)
list(APPEND private_includes ${arg_INCLUDE_DIRECTORIES})
qt_internal_prepare_test_target_flags(version_arg exceptions_text gui_text ${ARGN})
+ qt_internal_library_deprecation_level(deprecation_define)
+
qt_internal_add_executable("${name}"
${exceptions_text}
${gui_text}
@@ -437,6 +455,7 @@ function(qt_internal_add_test name)
${private_includes}
DEFINES
${arg_DEFINES}
+ ${deprecation_define}
LIBRARIES
${arg_LIBRARIES}
${arg_PUBLIC_LIBRARIES}