[CMake] Re: ADD_DEPENDENCIES: "non-existent target"??

Matthew Woehlke mw_triad at users.sourceforge.net
Tue Mar 20 11:31:08 EST 2007


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?

-- 
Matthew
"What a wonderful smell you've discovered!" -- Princess Leia Organa



More information about the CMake mailing list