[CMake] Make project name a target

Jeroen Dierckx jeroen.dierckx at gmail.com
Fri Sep 11 10:34:40 EDT 2009


On Fri, Sep 11, 2009 at 4:22 PM, Marcel Loose <loose at astron.nl> wrote:
> Hi David,
>
> I don't see the exact difference between (1) and (2). And yes, I was
> thinking of using the project name as a target. You are right, that it
> might cause clashes with existing projects, though :-(
>
> We use the convention that project names are always capitalized, so we
> usually don't run into problems.
>
> Is there a nifty trick to wrap the 'project' command? I never succeeded
> in doing that.

I did this once inside a macro, and that should work as expected. The
code of the macro should behave just as if it was copy-pasted to the
place where you call the macro, so scope and such will be that of the
place where you call it.

Greetings,
JeDi


>
> Best regards,
> Marcel Loose.
>
>
> On Fri, 2009-09-11 at 07:09 -0400, David Cole wrote:
>> When you say "make the project name a target" what do you mean by
>> that?
>>
>>
>> (1) internally create a CMake target with the given name?
>> (2) create a makefile target with that name that builds all the cmake
>> targets in that cmake project?
>> (3) something else?
>>
>>
>> (1) is probably not feasible for most folks -- because many people use
>> the same name for their PROJECT statement and the main library or
>> executable for that project.... which is already a cmake target (and a
>> makefile target) with that name.
>>
>>
>>
>> On Fri, Sep 11, 2009 at 3:51 AM, Marcel Loose <loose at astron.nl> wrote:
>>         Hi all,
>>
>>         I was wondering whether it's a good idea to make the project
>>         name (i.e.
>>         the argument to the 'project' command) a target.
>>
>>         Rationale: I have a project that consists of numerous
>>         sub-projects and I
>>         would like to be able to build some of these separately.
>>         Wrapping the
>>         'project' command in a macro is not a solution, because AFAIK
>>         CMake
>>         *must* see a 'project' command in the top-level CMakeLists.txt
>>         file; a
>>         'myproject' macro, wrapping the 'project' command, will not
>>         do.
>>
>>         Any comments?
>>
>>         Best regards,
>>         Marcel Loose.
>>
>>
>>         _______________________________________________
>>         Powered by www.kitware.com
>>
>>         Visit other Kitware open-source projects at
>>         http://www.kitware.com/opensource/opensource.html
>>
>>         Please keep messages on-topic and check the CMake FAQ at:
>>         http://www.cmake.org/Wiki/CMake_FAQ
>>
>>         Follow this link to subscribe/unsubscribe:
>>         http://www.cmake.org/mailman/listinfo/cmake
>>
>>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>


More information about the CMake mailing list