[CMake] Defining dependent compile and run tests using CMake/CTest

Neil Carlson neil.n.carlson at gmail.com
Sun Nov 26 18:06:51 EST 2017


On Sun, Nov 26, 2017 at 12:42 PM, Craig Scott <craig.scott at crascit.com>
wrote:

> Please post your CMakeLists.txt so we can see how you've got the fixtures
> and tests defined.
>

Here's what I've got (I put the run test first to verify that the
reordering takes place):

add_test(NAME intel-20171126-run COMMAND intel-20171126)
set_tests_properties(intel-20171126-run PROPERTIES PASS_REGULAR_EXPRESSION
"pass")
set_tests_properties(intel-20171126-run PROPERTIES FIXTURES_REQUIRED foo)

add_executable(intel-20171126 EXCLUDE_FROM_ALL intel-20171126.f90)
add_test(NAME intel-20171126
    COMMAND ${CMAKE_COMMAND} --build . --target intel-20171126 --config
$<CONFIGURATION>
    WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_tests_properties(intel-20171126 PROPERTIES FIXTURES_SETUP foo)

After posting my question, I manually created the "executable"
('touch intel-20171126`)
and re-ran ctest.  Sure enough, that time I didn't get the long message
spew about
being able to find the executable, but instead a 1-line message, which is
what I had
expected to see originally

      Start  2: intel-20171126
 1/13 Test  #2: intel-20171126 ...................***Failed    0.15 sec
      Start  1: intel-20171126-run
Failed test dependencies: intel-20171126
 2/13 Test  #1: intel-20171126-run ...............***Not Run   0.00 sec
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20171126/a0099a6a/attachment.html>


More information about the CMake mailing list