From 873aa682c56b1c187e2c87b49050509db9d1b16b Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 29 May 2020 19:50:06 +0200 Subject: [PATCH] CMake: Add ${tst_foo}_check target for easy test running Given a test named "tst_qdrag", you can run "ninja tst_qdrag_check" to build and run the test. Change-Id: I47dccb39dd60fca9cb07ff9af9fb739b293c5aaf Reviewed-by: Joerg Bornemann --- cmake/QtBuild.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 8081c7140fa..a89ef609946 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -3692,6 +3692,14 @@ function(qt_add_test name) set_tests_properties(${name} PROPERTIES TIMEOUT ${arg_TIMEOUT}) 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}") + # Get path to /bin, as well as CMAKE_INSTALL_PREFIX/bin, then # prepend them to the PATH environment variable. # It's needed on Windows to find the shared libraries and plugins.