On 7. Oct, 2010, at 10:54 , edA-qa mort-ora-y wrote:

> How can I have CMake not build test targets when doing a "make install"?
> 
> I'd prefer that test targets are only ever built if "make test" is called.
> 
> -- 
> edA-qa mort-ora-y

That needs a bit of trickery:

function(add_test_executable name)
  add_executable(${name} EXCLUDE_FROM_ALL ${ARGN})
  if(NOT TARGET test-exes)
    add_custom_target(test-exes)
  endif()
  add_dependencies(test-exes ${name})
endfunction()

add_custom_target(check
  COMMAND ${CMAKE_CTEST_COMMAND}
  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
  COMMENT "Running ctest")
add_dependencies(check test-exes)


This way you can run "make check" to build all the test executables and to run 
ctest afterwards.

HTH

Michael

--
There is always a well-known solution to every human problem -- neat, 
plausible, and wrong.
H. L. Mencken

Attachment: PGP.sig
Description: This is a digitally signed message part

_______________________________________________
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

Reply via email to