28 lines
928 B
CMake
28 lines
928 B
CMake
|
|
# QML unit tests — opt-in, only built when BUILD_TESTING is on (CTest's
|
||
|
|
# convention). Wired from ../CMakeLists.txt under the same guard.
|
||
|
|
#
|
||
|
|
# Run via:
|
||
|
|
# cmake -S . -B build -DBUILD_TESTING=ON
|
||
|
|
# cmake --build build --target qml_unit_tests
|
||
|
|
# ctest --test-dir build --output-on-failure -R qml_unit_tests
|
||
|
|
#
|
||
|
|
# Or from the skeleton / example Makefiles via `make qmltest`.
|
||
|
|
|
||
|
|
find_package(Qt6 6.5 REQUIRED COMPONENTS QuickTest)
|
||
|
|
|
||
|
|
qt_add_executable(qml_unit_tests main.cpp)
|
||
|
|
target_link_libraries(qml_unit_tests PRIVATE
|
||
|
|
Qt6::QuickTest
|
||
|
|
Qt6::Qml
|
||
|
|
Qt6::Quick
|
||
|
|
)
|
||
|
|
|
||
|
|
# QUICK_TEST_MAIN reads QUICK_TEST_SOURCE_DIR from the macro definition
|
||
|
|
# at compile time. Point it at this directory so qmltestrunner finds
|
||
|
|
# the tst_*.qml files regardless of where the binary runs.
|
||
|
|
target_compile_definitions(qml_unit_tests PRIVATE
|
||
|
|
QUICK_TEST_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
|
||
|
|
)
|
||
|
|
|
||
|
|
add_test(NAME qml_unit_tests COMMAND qml_unit_tests)
|