[CMake] Re: ADD_DEPENDENCIES: "non-existent target"??
Matthew Woehlke
mw_triad at users.sourceforge.net
Tue Mar 20 14:20:26 EST 2007
(Trying again as this bounced...)
Bill Hoffman wrote:
> Matthew Woehlke wrote:
>> Matthew Woehlke wrote:
>>> Matthew Woehlke wrote:
>>>> I have a project with some Doxygen doc that has examples. I want to
>>>> add a non-default target to build the examples. I tried this:
>>>>
>>>> src/CMakeLists.txt:
>>>> ADD_CUSTOM_TARGET(examples)
>>>>
>>>> src/examples/CMakeLists.txt:
>>>> MACRO(ADD_EXAMPLE name)
>>>> ADD_EXECUTABLE(${name} EXCLUDE_FROM_ALL ${name}.c)
>>>> TARGET_LINK_LIBRARIES(${name} mylib)
>>>> ADD_TEST(${name} ${CMAKE_CURRENT_BINARY_DIR}/${name})
>>>> ADD_DEPENDENCIES(examples ${name})
>>>> ENDMACRO(ADD_EXAMPLE)
>>>> ADD_EXAMPLE(foo)
>>>>
>>>>
>>>> ...but I always get this error:
>>>> src/examples/CMakeLists.txt:5:
>>>> ADD_DEPENDENCIES Adding dependency to non-existent target: examples
>>>>
>>>>
>>>> What am I doing wrong?
>>>
>>> Ok, apparently ADD_DEPENDENCIES only works on targets *in the current
>>> directory*. So how do I add a dependency to a top-level target in the
>>> CMakeLists.txt of a subdirectory?
>
> Did you try ADD_SUBDIRECTORY instead of SUBDIRS? Also, what version
> of CMake are you using?
(For some reason, your reply is not showing up on gmane :-(.)
CMake 2.4.6.
I was able to achieve the effect I want with ADD_SUBDIRECTORY (bummer
that not taking multiple subdirs, although it would be trivial to
macro-ize that) by removing EXCLUDE_FROM_ALL from the examples targets
and adding the examples directory as EXCLUDE_FROM_ALL. This works great.
But even using ADD_DIRECTORY I can't seem to add dependencies to targets
from parent directories, which seems like an annoying (and unexpected)
limitation... especially since TARGET_LINK_LIBRARIES is perfectly
capable of creating dependencies across branches.
--
Matthew
"What a wonderful smell you've discovered!" -- Princess Leia Organa
More information about the CMake
mailing list