summaryrefslogtreecommitdiffstats
path: root/bin/qt-cmake-standalone-test.in
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-03-18 19:09:00 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-03-23 09:54:48 +0100
commit1f442c684fa68ff9ebbc8ffd1b92a6c1d5f87b83 (patch)
tree06c56d9f246239274e0a5e4e7d7936974e992c9a /bin/qt-cmake-standalone-test.in
parentb888cc6fbc09903680a62d66ff556f949a139751 (diff)
CMake: Provide script to configure and build one or more tests
Before this patch there were a few ways to build tests - Configure all tests as part of the repo build - Configure all tests as part of the repo build, but don't build tests by default (-DQT_NO_MAKE_TESTS=ON) - Configure all tests as a standalone project in a separate build dir using -QT_BUILD_STANDALONE_TESTS=ON All of the above incur some time overhead due to the necessity of configuring all tests. Sometimes you just want to build ONE test (or a few). To facilitate that use case, a new shell script called bin/qt-cmake-standalone-test(.bat) can now be used to configure and build one or more tests. The script takes one single argument pointing to the desired test project path and configures a generic template project that sets up all the necessary Qt CMake private API, afterwards calling add_subdirectory on the passed in project. Example $ path/to/qt/bin/qt-cmake-standalone-test ./tests/auto/gui/image/qicon or $ path/to/qt/bin/qt-cmake-standalone-test ./tests/auto/gui/image After that, simply run 'ninja && ctest' to build and run the test(s). This is the CMake equivalent of calling qmake on a test .pro file (or on a tests SUBDIRS .pro file) There are 3 details worth mentioning. Due to the add_subdirectory call, the built artifacts will not be in the top-level build dir, but rather in a nested build_dir. The script currently can't handle more than one argument (the path to the project), so you can't pass additional -DFoo=bar arguments. If a test uses a 3rd party library (like Threads::Threads) which was not a public dependency for any of the Qt modules, configuration will fail saying that the target was not found. Perhaps we should consider recording these packages when generating the StandaloneConfig.cmake files. Change-Id: Icde6ecb839341d34f341d9a19402c91196ed5aa0 Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'bin/qt-cmake-standalone-test.in')
-rwxr-xr-xbin/qt-cmake-standalone-test.in1
1 files changed, 1 insertions, 0 deletions
diff --git a/bin/qt-cmake-standalone-test.in b/bin/qt-cmake-standalone-test.in
new file mode 100755
index 0000000000..fce287ac94
--- /dev/null
+++ b/bin/qt-cmake-standalone-test.in
@@ -0,0 +1 @@
+@__qt_cmake_private_path@ @__qt_cmake_standalone_test_path@ -DQT_STANDALONE_TEST_PATH=@__qt_cmake_standalone_passed_args@