[CMake] how to add a test that calls ctest

Kris Thielemans kris.f.thielemans at gmail.com
Sat Dec 30 17:28:25 EST 2017


Hi all

 

I've managed to solve my own question. The trick is to use the
$<CONFIGURATION>  generator expression. Here is the correct line (this time
with the add_test command included, which I had forgotten to copy-paste
before, which no doubt confused everyone).

 

add_test(NAME SIRF_TESTS

               COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> 

               WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/SIRF-prefix/src/SIRF-build/)

 

Best wishes 

 

Kris 

 

From: Kris Thielemans 
Sent: 23 December 2017 09:12
To: 'CMake Mail List' <cmake at cmake.org>
Subject: how to add a test that calls ctest

 

Hi

 

We have a superbuild-type project
https://github.com/CCPPETMR/SIRF-SuperBuild where we want to add tests that
call ctest for the dependent projects. We do this as

 

 

               COMMAND ${CMAKE_CTEST_COMMAND} WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/SIRF-prefix/src/SIRF-build/)

 

which works fine when using Makefiles, but fails with Visual Studio as we
don't pass the "-C config" flag. So how do we put this in? I tried

 

               COMMAND ${CMAKE_CTEST_COMMAND} -C ${CMAKE_CFG_INTDIR} -VV
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/SIRF-prefix/src/SIRF-build/)

 

But this gives me errors like

 

1: 4: Test command: NOT_AVAILABLE

1: Test not available in configuration "$(Configuration)".

 

Best wishes

 

 

Kris Thielemans
Reader in Medical Imaging Physics at University College London

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20171230/b0807258/attachment.html>


More information about the CMake mailing list