Subject: Re: [boost] [cmake] Minimum viable cmakeification for Boost
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2017-06-20 15:08:19
>> 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. 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.
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, 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.
Generator expressions are also hard to write and debug, are
overwhelmingly confusing to read, and randomly don't work in some places
depending on which build system generator you are using. So best avoid
all of that complexity - place no complexity at all outside the
rootlevel CMakeLists. Declaration only. Place all custom logic solely in
rootlevel CMakeLists only.
> Any definite source on what a cmake2ism is or is not would be highly
> As a general observation, I see a lot of statements along the lines of "I
> state that XYZ is preferable over UVW", it would be nice to have to have
> background information (pros and cons anyone? what do the cmake
> authors/docs have to say about this?) on those statements so that everyone
> can form their own opinion instead of having to choose whom to trust about
> what's "standard" cmake.
I believe Stephen Kelly is negotiating a book deal on this. It'll be
some time before that book lands though.
-- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/