Replace ctest with "ctest -output-on-failure" permanently for a specific project in CMakeLists.txt

I found that the general command ctestdoes not provide much information about the tests, so I would like to add ctest --output-on-failure, but not have users to worry about the flag. I wish they were just doing cmake, makeproject and run ctest, and it should run ctest with flag --output-on-failure. Is it possible to do this in CMakeLists.txt?

EDIT:

Conclusion env CTEST_OUTPUT_ON_FAILURE=1 make test

 4/13 Test  #4: TEST_SSSP ........................***Failed  Required regular expression not found.Regex=[CORRECT
]  0.00 sec
Loading Matrix-market coordinate-formatted graph ...
Input graph file /home/muhammad/gunrock/dataset/small/chesapeake.mtx does not exis

Conclusion set_property(TEST TestName PROPERTY ENVIRONMENT "CTEST_OUTPUT_ON_FAILURE=1")

 4/13 Test  #4: TEST_SSSP ........................***Failed  Required regular expression not found.Regex=[CORRECT
]  0.00 sec

The flag in set_propertydoes not work.

+4
source share
1 answer

make check : CMake: ctest (, , ctest/make)

add_custom_target(check ${CMAKE_COMMAND} -E env CTEST_OUTPUT_ON_FAILURE=1
                  ${CMAKE_CTEST_COMMAND} -C $<CONFIG> --verbose
                  WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
+2

All Articles