[CMake] problem with add_custom_command / add_custom_target in different directories
Michael Wild
themiwi at gmail.com
Wed Feb 25 03:15:57 EST 2009
On 25. Feb, 2009, at 7:25, Philip Lowman wrote:
> I'm trying to come up with a way to have a custom target defined in
> the
> top-level directory execute a collection of custom commands previously
> defined in subdirectories throughout the code (to untar many
> tarballs).
> Unfortunately, the approach I'm trying isn't working.
>
> When I invoke add_custom_target() immediately after
> add_custom_command() in
> the same directory, it works fine. When I invoke
> add_custom_target() in the
> parent directory it causes an error in the makefiles.
>
> I've attached a small example of the problem I'm having. Not sure
> if this
> is a bug or just user error.
>
> lowman at locke:~/tmp/cmake_tests/CustomCommandProb/build$ make untar
> Scanning dependencies of target untar
> make[3]: *** No rule to make target `../foo-1.2.3', needed by
> `CMakeFiles/untar'. Stop.
> make[2]: *** [CMakeFiles/untar.dir/all] Error 2
> make[1]: *** [CMakeFiles/untar.dir/rule] Error 2
> make: *** [untar] Error 2
>
>
To me this appears to be a bug in the Makefile generator. I also tried
to make a "untarFoo" custom target in test/CMakeLists.txt, which
depended on the output of the custom command and then have the "untar"
target depend on "untarFoo", but that didn't work out either.
What works for me (CMake-CVS, Mac OS X 10.5, Makefile generator) is
the following:
- add an empty custom target "untar" with no dependencies to
CMakeLists.txt BEFORE any of the add_subdirectory calls
- in the test/CMakeLists.txt add a custom target "untarFoo" which
depends on the output of the custom command
- in the test/CMakeLists.txt add a dependency of the top-level "untar"
target on the "untarFoo" helper target
Find attached your modified test code.
Michael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CustomCommandProbModified.tar.gz
Type: application/x-gzip
Size: 736 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090225/fce9ceaf/attachment-0001.bin>
-------------- next part --------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090225/fce9ceaf/attachment-0001.pgp>
More information about the CMake
mailing list