[CMake] cmake trouble

Eric Clark eclark at ara.com
Mon Oct 22 13:35:22 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:11 PM
> To: cmake at cmake.org
> Subject: Re: [CMake] cmake trouble
> 
> Eric Clark wrote:
> > Hello,
> >
> > First off, you cannot call both add_executable and add_library in the
> > same CMakeLists file. Here is what I can say about your other questions:
> 
> Of course you can.

Yes, but only if you call project() twice, correct? Maybe I should have been more specific. What I meant was that you cannot create two targets for the same project (i.e you cannot build an executable and a dll in the same project). In the code that was posted, there was no call to project between the call to add_library and add_executable. Certainly there is nothing wrong with calling project more than once in a list file, but I have found that it is a rare case that you want to do this... This could be just my experience, but I can only speak for what I know.

I should have been more specific, but if you are going to say "of course you can", you should probably also explain that this means you need two calls to project() as well because the code that was posted did not have two calls to project as far as what he posted...

Please, feel free to correct me if I am wrong here... But, I tried this once and it did not work and after seeing what I had done, it didn't make sense either...

Thanks,
Eric

> 
> > 1.       All commands that require a target have to come after you have
> > created the target via add_executable or add_library. This is simply
> > because you need to have a target before you can adds things to it.
> 
> That is indeed correct.
> 
> Eike
> 
> --


More information about the CMake mailing list