[CMake] Running unit test as part of the build
Erik Johansson
erik at ejohansson.se
Mon Sep 12 15:06:50 EDT 2011
On Mon, Sep 12, 2011 at 20:30, Michael Wild <themiwi at gmail.com> wrote:
> How about using a custom command that runs the unit test using a
> wrapper script that upon successful completion creates a stamp-file and
> depends upon the unit-test executable target itself?
This seems to work:
add_executable(unittest ${test_SRCS})
set(unittest_stamp
"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/unittest.stamp")
add_custom_command(OUTPUT "${unittest_stamp}"
COMMAND ${CMAKE_CTEST_COMMAND} $(ARGS)
COMMAND ${CMAKE_COMMAND} -E touch "${unittest_stamp}"
COMMENT "Running unit test"
DEPENDS unittest)
add_custom_target(unittest_run ALL DEPENDS "${unittest_stamp}")
// Erik
--
Erik Johansson
Home Page: http://ejohansson.se/
PGP Key: http://ejohansson.se/erik.asc
More information about the CMake
mailing list