[CMake] Getting if custom target is set

Philip Lowman philip at yhbt.com
Wed Nov 5 20:02:29 EST 2008


On Wed, Nov 5, 2008 at 9:25 AM, <Alexander.Camek at elektrobit.com> wrote:

> Hi folks,
>
> I have got a project split up into a lot of single project.
> So in my ROOR dir I have got a CMakeLists.txt which defines a "master"
> PROJECT().
> Each subdirectory added by the master project adds in its CMakeLists.txt
> its own PROJECT() in order to build alone.
>
> Now I add a new command ADD_CUSTOM_TARGET(lint ) in my master project in
> order to do a make lint.
> This works fine if everybody uses the whole project. But if he uses only a
> subproject as standalone this doesn't work.
> It doesn't know the custom target. But if I add this to the subprojects
> cmake warns me about "CMP0002".
>
> What I want to do is now to check if my custom target was set and if not I
> want to set it in the subproject.
>
> Something like that:
> GET_TARGET_EXISTS(LINT_SET lint)
>
> IF(NOT LINT_SET)
>   ADD_CUSTOM_TARGET(lint )
> ENDIF(NOT LINT_SET)
>
> How can I do that?


I'm not completely sure what you're asking for, but the IF() command does
support checking for targets if that's what you're looking for:

if(TARGET target-name)
http://www.cmake.org/cmake/help/cmake2.6docs.html

-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20081105/09700e88/attachment.htm>


More information about the CMake mailing list