[CMake] How to create a custom solution with Visual Studio 2010 generator?

Golebiewski, Jakub Jakub.Golebiewski at dnvgl.com
Tue Sep 22 02:49:57 EDT 2015


> -----Original Message-----
> From: J Decker [mailto:d3ck0r at gmail.com]
> Sent: Tuesday, September 22, 2015 8:12 AM
> To: Golebiewski, Jakub
> Cc: cmake at cmake.org
> Subject: Re: [CMake] How to create a custom solution with Visual Studio
> 2010 generator?
>
> On Mon, Sep 21, 2015 at 10:39 PM, Golebiewski, Jakub
> <Jakub.Golebiewski at dnvgl.com> wrote:
> > This may be a solution, I will check this asap.
> >
> > This should be clearer, I have something like this:
> >
> > Main Project - PROJECT()
> >                 \Sub Project 1 - PROJECT()
> >                                \target 1 - ADD_LIBRARY()
> >                                \target 2 - ADD_LIBRARY()
> >                 \Sub Project 2 - PROJECT()
> >                                \target 3 - ADD_LIBRARY()
> >                                \target 4 - ADD_LIBRARY()
> >                 \Sub Project 3 - PROJECT()
> >                                \target 5 - ADD_LIBRARY()
> >                                \target 6 - ADD_LIBRARY()
> >
> > Targets  5 and 6 depend on 1, 2, 3 and 4.
> >
> > Now when I run cmake on Main Project I will get .sln files for Main Project
> and each Sub Project.
> > .sln file for Sub Project 3 will contain all the targets (So I will get .sln with
> projects for target 1 – 6 in VS terminology).
> > What I need to have is for Sub Project 3 to have only target 5 and target 6
> in .sln without dependencies from other Sub Projects.
> >
> > So I worry that with your solution I will get unknown targets error? Is there
> any way to ignore missing targets errors?
> >
>
> For each invokation of cmake you only get one .sln file.  It's name comes

When I run cmake on Main Project I get .sln for the Main Project and every Sub Project.

> from the last PROJECT in the root CMakeLists.txt If you run cmake for each
> subproject I suppose one could set a variable like

I've tried running cmake independently for each subproject but I get errors about unknown
Targets since every Sub Project depends on targets from 'earlier' one.

I have about 620 targets (VS projects) so when I open Main Project.sln (with 620 projects) in VS it is impossible to work with.
Currently cmake produces .sln for each Sub Project but includes dependencies from other projects and that's something I don’t want
Since the amount of projects in each .sln increases the further I go and most of them (later in the dependency chain) are not possible to work
with either. I'm trying to divide it into .slns that developers could work with in VS.

>
> IF( NOT PROJECT_ROOT )
>    SET( PROJECT_ROOT SomeName )
> ENDIF()
>
> and later test
> if( PROJECT_ROOT STREQUAL SomeName )
>    add_subdirectory( "../Sub Project3" Sub3 )
> endif()
>
> or the not of that and don't include the others...
>
> and the root would unconditionally add_subdirectory for all of those...
>
> I'd probably just make like
> OPTION( BUILD_EXTRAS "enable building extras" OFF ) in the root and test
> for BUILD_EXTRAS to include other things... and make them cmake
> configuration options that would show as check boxes in cmake-gui.
>
> In my case I have a core set of libraries that get built and then various
> projects that use those libraries.  I build it in two steps in two separate build
> directories using two separate cmake invoations...
> and then I have a super-project that can build the core plus all extras in one
> fell swoop by just building each one.  (uses custom macro that's a few dozen
> lines to do each build)
>
>
>
> > Thanks for help,
> > JG
> >
> > -----Original Message-----
> > From: J Decker [mailto:d3ck0r at gmail.com]
> > Sent: Monday, September 21, 2015 4:50 PM
> > To: Golebiewski, Jakub
> > Cc: cmake at cmake.org
> > Subject: Re: [CMake] How to create a custom solution with Visual Studio
> 2010 generator?
> >
> > CMake's PROJECT directive maps to 'Solution'  (should only be one
> > project() per chain) ... use set( PROJECT projectname) and then reference
> ${PROJECT} later instead of ${PROJECT_NAME} for easy conversion.
> >
> > add_library, add_executable map to 'project'
> >
> > from http://www.cmake.org/Wiki/CMake_Useful_Variables
> >
> > you can wrap the projects you want to omit with If's
> >
> > if( NOT MSVC10 )
> >    add_library( one I don't want in 2010) endif( NOT MSVC10 )
> >
> >
> >
> >
> > On Sun, Sep 20, 2015 at 11:20 PM, Golebiewski, Jakub
> <Jakub.Golebiewski at dnvgl.com> wrote:
> >> Hi,
> >>
> >>
> >>
> >> I’m trying to create a solution with custom set of projects (in VS
> >> sense) for Visual Studio 2010.
> >>
> >> I have a top level CMakeLists.txt with PROJECT() declared and then
> >> several CMakeLists.txt below in a tree also with PROJECT() in each of
> them.
> >>
> >> However for lower level PROJECT() directives I get all the targets
> >> that I specify in CMakeLists.txt and all the targets that they depend on.
> >>
> >>
> >>
> >> My goal is to have a solution only with a specific set of targets,
> >> without dependencies.
> >>
> >>
> >>
> >> Is there a  way to do that in cmake?
> >>
> >>
> >>
> >> Thanks for help,
> >>
> >> Jakub
> >>
> >>
> >>
> *******************************************************************
> **
> >> *
> >> **************** This e-mail and any attachments thereto may contain
> >> confidential information and/or information protected by intellectual
> >> property rights for the exclusive attention of the intended
> >> addressees named above. If you have received this transmission in
> >> error, please immediately notify the sender by return e-mail and
> >> delete this message and its attachments. Unauthorized use, copying or
> >> further full or partial distribution of this e-mail or its contents is
> prohibited.
> >>
> *******************************************************************
> **
> >> *
> >> ****************
> >>
> >> --
> >>
> >> Powered by www.kitware.com
> >>
> >> Please keep messages on-topic and check the CMake FAQ at:
> >> http://www.cmake.org/Wiki/CMake_FAQ
> >>
> >> Kitware offers various services to support the CMake community. For
> >> more information on each offering, please visit:
> >>
> >> CMake Support: http://cmake.org/cmake/help/support.html
> >> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> >> CMake Training Courses: http://cmake.org/cmake/help/training.html
> >>
> >> Visit other Kitware open-source projects at
> >> http://www.kitware.com/opensource/opensource.html
> >>
> >> Follow this link to subscribe/unsubscribe:
> >> http://public.kitware.com/mailman/listinfo/cmake
> >
> >
> *******************************************************************
> ***
> > **************** This e-mail and any attachments thereto may contain
> > confidential information and/or information protected by intellectual
> property rights for the exclusive attention of the intended addressees
> named above. If you have received this transmission in error, please
> immediately notify the sender by return e-mail and delete this message
> and its attachments. Unauthorized use, copying or further full or partial
> distribution of this e-mail or its contents is prohibited.
> >
> *******************************************************************
> ***
> > ****************

**************************************************************************************
This e-mail and any attachments thereto may contain confidential information and/or information protected by intellectual property rights for the exclusive attention of the intended addressees named above. If you have received this transmission in error, please immediately notify the sender by return e-mail and delete this message and its attachments. Unauthorized use, copying or further full or partial distribution of this e-mail or its contents is prohibited.
**************************************************************************************


More information about the CMake mailing list