[CMake] Undefine a project()

Robert Dailey rcdailey.lists at gmail.com
Tue May 22 18:12:49 EDT 2012


Thanks for the information!

On Tue, May 22, 2012 at 3:27 PM, David Cole <david.cole at kitware.com> wrote:

> It is customary, but not enforced, to have only one project command in a
> CMakeLists.txt file.
>
> The project command maps to generated *.sln files for the Visual Studio
> generators.
>
> All targets defined after the project command in the same CMakeLists.txt
> file, or any included by virtue of add_subdirectory, will appear in the
> *.sln file that corresponds to that project command.
>
> To prevent this, simply organize things differently.
>
> There's no way with existing CMake to undefine a project or target.
>
>
> HTH,
> David
>
>
> On Tue, May 22, 2012 at 2:49 PM, Robert Dailey <rcdailey.lists at gmail.com>wrote:
>
>> Hi,
>>
>> I was wondering if there is a way to undefined a project(). I want to do
>> this to prevent projects from being included in a solution when I generate
>> for Visual Studio. Example:
>>
>> project( A )
>> add_executable( A a.cpp )
>> project( B )
>> add_executable( B b.cpp )
>> add_executable( C c.cpp )
>>
>> I don't want B to be in A's solution when I open A.sln. I'm assuming this
>> is the behavior, unless project(B) call cancels out project(A)?
>>
>> Also, I don't want project C to appear in either A or B solutions.
>>
>> The reason why I'm doing this is because I have setup my CMake scripts to
>> allow a solution file to be generated for executables (so I can open each
>> executable solution in different instances of visual studio, with ONLY that
>> executable + dependency projects in it). However, since sometimes multiple
>> executable projects can be defined in the same directory, or other
>> libraries that aren't a dependency of that executable, I do not want those
>> to be included in the project().
>>
>> --
>>
>> 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
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120522/e71eba7b/attachment.htm>


More information about the CMake mailing list