CMake: Fix tst_foo_check to work for qml tests as well

Qml tests currently don't expose a CMake target, so no
dependency should be added to a non-existent target.

Make sure to add the check target only if the test was previously
added.

Fixes configurtion failure of qtdeclarative tests.

Amends 873aa682c56b1c187e2c87b49050509db9d1b16b

Change-Id: Ic8bbfe668c00c1ce05f1e1dfe5494dafd91dd7b8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Alexandru Croitor 2020-06-03 11:58:17 +02:00
parent d268b91907
commit 53bee75001

View File

@ -3699,12 +3699,16 @@ function(qt_add_test name)
endif()
# Add a ${target}/check makefile target, to more easily test one test.
add_custom_target("${name}_check"
VERBATIM
COMMENT "Running ${CMAKE_CTEST_COMMAND} -V -R \"^${name}$\""
COMMAND "${CMAKE_CTEST_COMMAND}" -V -R "^${name}$"
)
add_dependencies("${name}_check" "${name}")
if(TEST "${name}")
add_custom_target("${name}_check"
VERBATIM
COMMENT "Running ${CMAKE_CTEST_COMMAND} -V -R \"^${name}$\""
COMMAND "${CMAKE_CTEST_COMMAND}" -V -R "^${name}$"
)
if(TARGET "${name}")
add_dependencies("${name}_check" "${name}")
endif()
endif()
# Get path to <qt_relocatable_install_prefix>/bin, as well as CMAKE_INSTALL_PREFIX/bin, then
# prepend them to the PATH environment variable.