[CMake] Find out if a target exists?

Daniel daniel at connect2.com
Fri Oct 12 02:37:13 EDT 2007


Gonzalo Garramuño wrote:
> 
> I was wondering what's the best way to determine if a target exists.
> 
> I wanted to modify a target's properties but depending on the type of 
> build, it may not always exist.
> 

You could do this:

GET_TARGET_PROPERTY(target_location target_name LOCATION)

target_location will equal NOT-FOUND if target_name does not exist or the 
location of the target otherwise.
--
Daniel


More information about the CMake mailing list