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
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake