Hi all, I have looked and can't find the answer, so I turn to the list.
I have a CMakeLists.txt and a subdirectory called utils, which also has its own CMakeLists.txt In the parent CML.txt, I have something like: ENABLE_TESTING() add_subdirectory(utils) In my utils CML.txt, I have ADD_EXECUTABLE(unit_1 units/unit_1.cpp) ADD_TEST( unit_1 ${EXECUTABLE_OUTPUT_PATH}/unit_1 ) When I run "make test" on the command line, it will only run the tests, it doesn't build my tests. When I want to do some work and test it, I would like to do something like make build_run_tests and have it automatically build ALL of my unit tests, and then run ALL of my unit tests. But there doesn't seem to be any way other than something like make unit_1 unit_2 unit_3 && make test Which is very difficult to do, as the actual names of my unit tests are much longer, eg unit_string_numeric_utils I tried doing cmake --build-and-test but that seems to demand that I also tell it what the targets are too! I did the following hack, in parent CML.txt, it now reads: ENABLE_TESTING() set (UNIT_TESTS) add_subdirectory(utils) add_custom_target (build_tests ALL DEPENDS ${UNIT_TESTS}) add_custom_target (build_run_tests ALL DEPENDS ${UNIT_TESTS} test) and in utils/CML.txt it now reads: ADD_EXECUTABLE(unit_1 units/unit_1.cpp) ADD_TEST( unit_1 ${EXECUTABLE_OUTPUT_PATH}/unit_1 ) SET (UNIT_TESTS ${UNIT_TESTS} unit_1 PARENT_SCOPE) so I am MANUALLY adding every unit test into "UNIT_TESTS" variable, and then I add a custom target to build them all. But you can see that my attempt to make build_run_tests failed, as I can't seem to build the 'test' subproject directly. This hack is very verbose, I have to add SET (UNIT_TESTS ${UNIT_TESTS} unit_xyz PARENT_SCOPE) for EVERY unit test I write. WHY is it so annoying to do such a seemingly simple thing? thanks Paul
_______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake