[CMake] Testing for a Target

Eric Noulard eric.noulard at gmail.com
Wed Nov 26 16:34:24 EST 2008


2008/11/26 Michael Jackson <mike.jackson at bluequartz.net>:
> Is there a way to actually test to see if a target exists or has been
> created?
>
> I am working on the boost-cmake stuff and I would to implement a macro that
> takes in requirements for a target (regression test). As it checks those
> requirements the macro will need to check to see if one of its dependencies
> has already been created. For example say I have a regression test Foo and
> it depends on a static-multi_threaded-debug build of the boost_system
> library.
>   Now say the user has selected to NOT build static libraries. I need to
> check for the boost-system-static-multi-debug target and if it does not
> exists (which it will not in our example) add that target.
>
> Alternatively, what happens if I just add a new target and the new target
> already actually exists? Is that safe?

Did you try
if(TARGET target-name)

cf

cmake --help-command if




-- 
Erk


More information about the CMake mailing list