[CMake] Depending on all and custom targets

jens persson jens at persson.cx
Fri Oct 9 05:53:54 EDT 2009


Hello again,

I have some targets that are not build by default (using
EXCLUDE_FROM_ALL), these are build when a special target called
extras.

Now I want to add a target that builds both all and extras, but cant
seem to get it to work. For discussion I have these rules:

PROJECT (tester)
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
CMAKE_POLICY (VERSION 2.6)

add_executable(foo
        foo.c
)
add_executable(bar
        bar.c
)
set_target_properties(bar
        PROPERTIES EXCLUDE_FROM_ALL True
)
add_custom_target(extras
        DEPENDS bar
)

which builds foo when running make all and bar when make extras

I have tried to simply add:
add_custom_target(complete
        DEPENDS extras all
)

which gives the following error:
$ make complete
[100%] Built target bar
[100%] Built target extras
make[3]: *** No rule to make target `extras', needed by
`CMakeFiles/complete'.  Stop.
make[2]: *** [CMakeFiles/complete.dir/all] Error 2
make[1]: *** [CMakeFiles/complete.dir/rule] Error 2
make: *** [complete] Error 2

When removing extras from the DEPENDS line I get:
$ make complete
make[3]: *** No rule to make target `all', needed by
`CMakeFiles/complete'.  Stop.
make[2]: *** [CMakeFiles/complete.dir/all] Error 2
make[1]: *** [CMakeFiles/complete.dir/rule] Error 2
make: *** [complete] Error 2

I get the impression that I have two problems: depending on a
custom_target and depending on all.

Anyone know of a solution?

I'm running cmake version 2.6-patch 2 with make 3.81on a ubuntu 9.04
box  (all installed from ubuntu standard repositories)

Best regards and happy weekend
/jp
-- 
jens persson
<jens at persson.cx>
Mäster Olofsväg 24
S-224 66 LUND;SWEDEN


More information about the CMake mailing list