summaryrefslogtreecommitdiffstats
path: root/cmake/QtResourceHelpers.cmake
diff options
context:
space:
mode:
authorMikolaj Boc <mikolaj.boc@qt.io>2022-07-12 18:15:24 +0200
committerMikolaj Boc <mikolaj.boc@qt.io>2022-08-24 02:46:37 +0200
commit8d728a0ed9c1fb366c64babc1f753b5ea77c2cdf (patch)
treec6c73b5bfa6ee2068707989500221064c1488fe9 /cmake/QtResourceHelpers.cmake
parent8446655f24c38d2d52f56d0369182895b6306026 (diff)
Implement the batch_tests feature
An approach of test batching (joining multiple tests into a single binary) has been taken, due to long linking times/binary size on certain platforms, including WASM. This change adds a new feature 'batch_test_support' in Qt testlib. Based on the value of the feature, test batching may become enabled with the -batch-tests switch. Batching works for every target added via qt_internal_add_test. When first such target is being processed, a new combined target for all of the future test sources is created under the name of 'test_batch'. CMake attempts to merge the parameters of each of the tests, and some basic checks are run for parameter differences that are impossible to reconcile. On the C++ level, convenience macros instantiating the tests are redefined when batch_tests is on. The new, changed behavior triggered by the changes in the macros registers the tests in a central test registry, where they are available for execution based solely on their test name. The test name is interoperable with the names CMake is aware of, so CTest is able to run the tests one by one in the combined binary. Task-number: QTBUG-105273 Change-Id: I2b6071d58be16979bd967eab2d405249f5a4e658 Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'cmake/QtResourceHelpers.cmake')
-rw-r--r--cmake/QtResourceHelpers.cmake8
1 files changed, 8 insertions, 0 deletions
diff --git a/cmake/QtResourceHelpers.cmake b/cmake/QtResourceHelpers.cmake
index 5d605d90a0..8a3ea8babd 100644
--- a/cmake/QtResourceHelpers.cmake
+++ b/cmake/QtResourceHelpers.cmake
@@ -2,6 +2,14 @@
# SPDX-License-Identifier: BSD-3-Clause
function(qt_internal_add_resource target resourceName)
+ if(NOT TARGET "${target}")
+ qt_internal_is_in_test_batch(in_batch ${target})
+ if(NOT in_batch)
+ message(FATAL_ERROR "Trying to add resource to a non-existing target \"${target}\".")
+ endif()
+ qt_internal_test_batch_target_name(target)
+ endif()
+
# Don't try to add resources when cross compiling, and the target is actually a host target
# (like a tool).
qt_is_imported_target("${target}" is_imported)