[CMake] ADD_CUSTOM_COMMAND() cannot depend on ADD_CUSTOM_TARGET()
John McGehee
cmake at voom.net
Mon Feb 14 18:58:11 EST 2011
I have a custom command that depends on a custom target. In the example below, it is as if
ADD_CUSTOM_COMMAND(... DEPENDS t ...)
has no effect:
# CMakeLists.txt:
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
PROJECT(CUSTOMDEPENDS NONE)
ADD_CUSTOM_TARGET(t
${CMAKE_COMMAND} -E echo "Building target t"
VERBATIM)
ADD_CUSTOM_COMMAND(OUTPUT stamp
COMMAND ${CMAKE_COMMAND} -E touch stamp
DEPENDS t
VERBATIM)
ADD_CUSTOM_TARGET(main ALL
${CMAKE_COMMAND} -E echo "Building target main"
DEPENDS stamp
VERBATIM)
# Fedora 11 with CMake 2.8 generating GNU make
> make
Scanning dependencies of target t
Building target t
[ 0%] Built target t
Scanning dependencies of target main
make[2]: *** No rule to make target `t', needed by `stamp'. Stop.
make[1]: *** [CMakeFiles/main.dir/all] Error 2
make: *** [all] Error 2
Target t is built, and I can 'make t' myself, so the target is in fact there.
My particular situation is that I am,
1. Creating a language binding using SWIG
2. Compiling the resulting C#
If you look just beneath the surface, this is the same situation illustrated in the above example. SWIG and C# themselves are working fine.
Is there any way to work around this? Shall I enter this as a bug?
This issue was raised earlier as http://www.cmake.org/pipermail/cmake/2010-November/040541.html but no solution was given. The excellent example is from that earlier message.
John McGehee
http://www.voom.net
More information about the CMake
mailing list