[CMake] project() and SLN files

Robert Dailey rcdailey at gmail.com
Fri Jul 3 18:09:08 EDT 2009


On Fri, Jul 3, 2009 at 5:02 PM, Miguel A. Figueroa-Villanueva <
miguelf at ieee.org> wrote:

> On Fri, Jul 3, 2009 at 4:33 PM, Robert Dailey wrote:
> > On Fri, Jul 3, 2009 at 3:31 PM, Robert Dailey wrote:
> >> On Fri, Jul 3, 2009 at 2:54 PM, James Bigler wrote:
> >>> On Wed, Jul 1, 2009 at 4:34 PM, Robert Dailey wrote:
> [...]
> > Interesting, this seems to work:
> > project( foo )
> > add_library( foo1 STATIC foo1.cpp )
> > add_library( foo2 STATIC foo2.cpp )
> > add_library( foo3 STATIC foo3.cpp )
> > This creates a solution called "foo.sln" and 3 projects: "foo1.vcproj",
> > "foo2.vcproj", "foo3.vcproj". Why does this work? I thought for every
> > add_library() there must be 1 call to project(). Since I didn't call
> > project() for foo1, foo2, or foo3, I don't know why it's letting me
> create
> > those libraries. Can someone explain this behavior?
>
> There is no place that I have read that indicates that you need more
> than one project. In fact, it doesn't make much sense to me to have
> more than one cmake project command per directory.
>
> I many times use multiple nested project commands so that in IDEs like
> MS Visual Studio I get a solution file for each (of course, each is in
> different directories). This allows me to load only a small number of
> Visual Studio Projects (*.vcproj), which are created per each CMake
> target.
>
> You might be confusing a CMake project with Visual Studio's notion of
> a project which would be created for each target as opposed to each
> cmake project instruction.
>
> Below is the help, which clearly states what the command is for:
>
> $ cmake --help-command project
> cmake version 2.7.20090329
>
> ------------------------------------------------------------------------------
> SingleItem
>
>  project
>       Set a name for the entire project.
>
>         project(<projectname> [languageName1 languageName2 ... ] )
>
>       Sets the name of the project.  Additionally this sets the variables
>       <projectName>_BINARY_DIR and <projectName>_SOURCE_DIR to the
>       respective values.
>
>       Optionally you can specify which languages your project supports.
>       Example languages are CXX (i.e.  C++), C, Fortran, etc.  By default C
>       and CXX are enabled.  E.g.  if you do not have a C++ compiler, you
> can
>       disable the check for it by explicitely listing the languages you
> want
>       to support, e.g.  C.  By using the special language "NONE" all checks
>       for any language can be disabled.


I've read this and I clearly understand it. However, this all comes down to
a misunderstanding. To me, a project() in CMake has always represented a
configuration set. For example, once I call project( foo ), I've now told
CMake that I plan to create a new build configuration called "foo", which
allows me to set project properties, apply source files, and other things.
However now that I think about it, you only set these things after
add_library() has been called.

Again, this is all just a misunderstanding on my part. It was a bit
misleading. What purpose does project() serve on other generators, like
XCode or Makefile? I'd test these myself if I had those platforms available.
I think the thing that would help me understand this to the fullest is how
project() affects the output of other generators.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090703/8aba207e/attachment.htm>


More information about the CMake mailing list