Boost logo

Boost :

Subject: Re: [boost] [cmake] Minimum viable cmakeification for Boost
From: paul (pfultz2_at_[hidden])
Date: 2017-06-20 16:28:36

On Tue, 2017-06-20 at 16:08 +0100, Niall Douglas via Boost wrote:
> >
> > >
> > > Niall says that using the global BUILD_SHARED_LIBS is a cmake2ism, and
> > > that explicit targets are preferred nowadays.
> > Niall, can you point me to a reference stating this? Preferably some cmake
> > documentation telling me what the right(tm) thing to do is.
> Any cmake construct which requires you to write an if() in a
> non-root-level CMakeLists is a cmake2-ism.

So you mean like this is a cmake2-ism:

if(NOT TARGET boost::assert::hl)
  add_subdirectory("../assert" "boost_assert" EXCLUDE_FROM_ALL)

> There are a very few places
> in cmake3 remaining where no good alternative to global variables exist.
> BUILD_SHARED_LIBS is definitely not one of those.

You should just write `add_library` and let the clients decide. I find no
reference supporting your claim.

> Shared libraries usually have different settings to static libs and
> again to header only libs. They have different relationships to their
> dependencies, different usage requirements for consumers. You can use
> generator expressions to encode those differences,

There is no need to use generator expressions since `BUILD_SHARED_LIBS` is a
cmake variable.

> but then you've hard
> coded them so external cmake no longer can easily override them. You
> have just made your non-root CMakeLists hard to reuse by cmake you
> didn't write nor design.

I do not follow this at all. What I presented does not have these problems.

Boost list run by bdawes at, gregod at, cpdaniel at, john at