[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"
> 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:
> 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)

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