Subject: Re: [boost] CMake - one more time
From: Robert Ramey (ramey_at_[hidden])
Date: 2016-04-22 18:41:39


On 4/22/16 2:56 PM, Raffi Enficiaud wrote:
> Certainly, CMake can do everything with the appropriate effort. But so
> far, although I am a CMake user, I do not know how to do this:
>
> - having the same target name with different target properties: like
> set(PROJECT_SRC ....)
> add_library(myproject SHARED ${PROJECT_SRC})
> add_library(myproject STATIC ${PROJECT_SRC})
>
> how do you do that? how do you refer to the appropriate variant?

I know it's beside the point of your post, but I can't resist.

I do this in the following way.

a) I set up a cached boolean variable USE_STATIC
b) I use the CMake script

if(USE_STATIC)
   add_library(myproject STATIC ${PROJECT_SRC})
else()
   add_library(myproject SHARED ${PROJECT_SRC})
elseif()

Then I generate two different versions and can
switch back and forth between them.

You see this in the serialization library CMake files

Robert Ramey