[CMake] IF(TARGET var) fails on cmake 2.6.0

Brad King brad.king at kitware.com
Wed Jul 7 16:49:05 EDT 2010


On 7/7/2010 7:45 AM, Marcel Loose wrote:
> My pragmatic question is: is there a different way to check whether a
> target has already been defined, or not.

Try this:

   get_target_property(mytarget_exists mytarget TYPE)
   if(mytarget_exists)
     message("YES")
   else()
     message("NO")
   endif()

The if(TARGET) mode was added in 2.6.2 to make the
test more readable.

-Brad


More information about the CMake mailing list