[CMake] Adding install dependency to test-target?

Eric Noulard eric.noulard at gmail.com
Thu Nov 20 06:55:27 EST 2008

2008/11/20 Hugo Heden <heden at foi.se>:
> Good day all,
> Is there any way that I can add 'install' dependency to the 'test'-target?
> Doing
>  add_dependencies( test install )
> does not seem to work:
>  CMake Error at ... (ADD_DEPENDENCIES):
>     add_dependencies Adding dependency to non-existent target: test

I don't think it's possible to add dependencies to "built-in" CMake target
(which deserve a feature request :-)

> Apparently neither 'test' nor 'install' counts as "top-level-targets"?

Precisely :=)

May be you can try to add a first "fake test" which does it:

ADD_TEST(00_Install ${CMAKE_BUILD_TOOL} install)

If this ADD_TEST is added in the top-level CMakeLists.txt
this should be the first test runned ?

However this will _SYSTEMATICALLY_ install before testing and not
add a "real dependency".


More information about the CMake mailing list