Boost logo

Boost :

From: Alexander Grund (alexander.grund_at_[hidden])
Date: 2021-05-31 07:24:04

> OK, I will bite <g>.
> // Beginning of rant
> The difficulty of specifying a compiler to use with CMake, compared
> with the elegance of b2's toolset definitions, makes me really wonder
> why the majority of the C++ world considers CMake anything but
> software gone terribly wrong. I know b2 has some abstruse weaknesses,
> but specifying a toolset/definition is not one of them. Maybe I have
> missed something but I certainly do not see how some CMake generator
> equates to a particular compiler other than the Visual C++ generators,
> where each generator name equates to a particular version of VC++.
> There must be more I am missing but there is not anything in the CMake
> documentation I can find which explains to me how I can specify, for
> instance, a particular version of mingw-w64 gcc or clang on Windows
> for CMake to use. The explanation for the CMake generators at
> is so pathetic that if I did not know the majority of C++ programmers
> swear by CMake I would really have thought that such software
> documentation would have doomed such software for popular use eons ago.
> // End of rant

I'll bite back ;-)

CMake has 2 levels of things you specify because CMake is not a build
system (as B2, make, ninja, ...) but a buildsystem generator.
In short:

- With "-G" you choose the build system to generate files for, e.g. VS
Solutions, Makefiles, Ninja configs, ...
- With CMAKE_<lang>_COMPILER you choose the compiler to use, e.g. `cmake

The defaults if unset are chosen reasonably. E.g. for make/ninja (make
is the default) it chooses $CC/$CXX (and maybe some fallbacks such es
`cc`) and for the VS generators it chooses the VS compiler for that version.

What do you gain from this? By switching the generator (and nothing
else) you can develop your project in whatever you want. E.g. VS,
VScode, vim (with a language server), ...
I find that quite powerful, especially if you need to develop on
Windows. So for that CMake is better than B2.

However I agree that for building/testing alone B2 is clearly superior.

So yeah, CMake is a tool, it has strengths and weaknesses and has some
historic backage due to the need to be backwards compatible (just as C++

Best, Alex

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