[CMake] cmake trouble

Eric Clark eclark at ara.com
Mon Oct 22 13:55:02 EDT 2012


> -----Original Message-----
> From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On
> Behalf Of Rolf Eike Beer
> Sent: Monday, October 22, 2012 12:51 PM
> To: cmake at cmake.org
> Subject: Re: [CMake] cmake trouble
> 
> Eric Clark wrote:
> > > -----Original Message-----
> > > From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org]
> On
> > > Behalf Of Rolf Eike Beer
> > > Sent: Monday, October 22, 2012 12:48 PM
> > > To: cmake at cmake.org
> > > Subject: Re: [CMake] cmake trouble
> > >
> > > Eric Clark wrote:
> > > > > From: Andreas Pakulat [mailto:apaku at gmx.de] On Mon, Oct 22, 2012
> > > > > at
> > > > >
> > > > > 6:04 PM, Eric Clark <eclark at ara.com> wrote:
> > > > > > First off, you cannot call both add_executable and add_library
> > > > > > in the same CMakeLists file.
> > > > >
> > > > > I think there's something missing here, but its perfectly
> > > > > possible to have one or more library and executable targets
> > > > > specified in the same cmake file. So this works just fine:
> > > > >
> > > > > add_library(foo bar.cpp)
> > > > > add_executable(bar foo.cpp)
> > > >
> > > > Sorry, me again, but I have a question... If I do use the above
> > > > code using a Visual Studio generator, will this create to separate
> > > > projects in Visual Studio?
> > >
> > > You will have one solution file, but 2 projects in it.
> >
> > Thank you Eike! Forgive my ignorance here... but what will it use to
> > name the two projects?
> 
> The name of the target, i.e. the first argument to add_library() and
> add_executable().

Awesome! Thank you for the answers and the quick reply! I have only been using CMake for a little over a year and again I am sorry for posting an incorrect answer. I always thought that I had to have one project() call for each add_executable and/or add_library. It is very good to know that that is not the case. However, I am curious if you think it is good practice to do such a thing?

> 
> Eike
> --


More information about the CMake mailing list