qt5base-lts/bin/qt-cmake-standalone-test.in
Alexandru Croitor 1f442c684f 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>
2020-03-23 09:54:48 +01:00

2 lines
122 B
Plaintext
Executable File

@__qt_cmake_private_path@ @__qt_cmake_standalone_test_path@ -DQT_STANDALONE_TEST_PATH=@__qt_cmake_standalone_passed_args@