On Sun, Mar 2, 2014 at 8:26 PM, Nils Gladitz <[email protected]> wrote: > 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.
Any way to reuse the "make test" target for that? Will adding dependencies to the "test" target work, or is "test" a special target? -- Pierre "delroth" Bourdon <[email protected]> Software Engineer @ Zürich, Switzerland http://code.delroth.net/ -- 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
