[CMake] How to tell if a target is already defined?

J Decker d3ck0r at gmail.com
Tue Oct 19 15:05:21 EDT 2010


WIthout adding a bunch of custom addtions, is there something I can
test to see if a target is already defined?

What I would like is although this whole project tree can build, I
really want to build sub-projects.  That is I have say 15
applications, all sharing a common 15 or so libraries (probably more,
maybe less), and I want to have each library include it's parts with
(often) out-of-source references on the add_subdirectory().  ALthough,
if I do specify to build the whole tree, then without testing somehow
if targets are defined already, so I don't re-process what's already
done for this build tree, multiple definintions end up happening.

example case


if( ? )

PROJECT( xyzz )
add_library( ${PROJECT_NAME} source.c )

endif()

is there something that will result from just the above code that I
can use to test for?


More information about the CMake mailing list