[CMake] Delaying building tests to "make test"
Nils Gladitz
nilsgladitz at gmail.com
Sun Mar 2 14:26:47 EST 2014
On 02.03.2014 20:11, Pierre Bourdon wrote:
> To avoid increasing compilation time of my project I would like to
> only build tests when they are going to be run, for example when using
> "make test". Is there any easy way to do this with CMake?
You can prevent your test executables from always building by using the
EXCLUDE_FROM_ALL flag in add_executable():
add_executable(mytest EXCLUDE_FROM_ALL ...)
Then you can create a custom target:
add_custom_target(build-my-tests)
And add your test executable targets as dependencies:
add_dependencies(build-my-tests mytest)
Then you can run "make" to build everything except your tests and "make
build-my-tests" to build the tests.
You could also add a command to your custom target to perform testing
itself.
Nils
More information about the CMake
mailing list