Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2024-06-11 05:21:11


I'm trying to figure out how to switch to CMake to build and test my
libraries. I have some experience with this as I've made such files on
sort of an experimental/prototype basis. However it's been some time
since I messed with this so a forgot a lot. Now I'm getting serious so I
have some questions. I've looked over the official CMake documentation.
  It seems complete but some stuff is not well explained. I've spent
some time studying https://github.com/boostorg/cmake at I'm beginning to
see what I have to do. Never-the-less, I still have a few questions:

1) The first lines show

mkdir __build
cd __build
cmake ..
cmake --build .

Does this presume that one starts from the library directory?
Does this syntax work for out of source tree builds? That is, would the
following work?

mkdir /temp/__build
cd /temp/__build
cmake ..
cmake --build .

(very confusing usage of leading __)

ahhhh - I see a problem. I'm thinking of starting from within the
directory of a particular library. I'm presuming "modular boost". Is
this supported?

2) BOOST_INCLUDE_LIBRARY

I would like my CMakeLists.txt file to explicitly list the direct
antecedent libraries (dependencies - bad word usage). So I'd expect to
see something like

add_directory(../filesystem)
add_directory(../regex)
...

So I could just
cd to .../libs/serialization
cmake --build

and have it build the antecedent if and only if required.

3) CMAKE_INSTALL_INCLUDEDIR

I would prefer not to "install" (copy) the include files but just use
the ones from their original locations.

4) BUILD_TESTING

I would prefer to have my library source to look like:

... libs/serialization
   CMakeLists.txt
     // includes add_directory for subdirectorys build, test, example,
profile and ...
     // includes add_directory for antecedent libraries like
add_directory(../libs/filesystem)
   include // directory with include files for users of serialization
library
   build(or src) // source files for library build
     CMakeLists.txt // to build library
   test
     CMakeLists.txt
   example
     CMakeLists.txt
   profile
     CMakeLists.txt

Maybe the add_directory would be conditioned on a CMAKE variable.

So if I invoke

CMake --build test_polymorphic_binary_archive

It would recursively (re)build everything necessary and nothing not
necessary

If I didn't specify a list of targets, it would recursively (re)build
everything that needs (re)building.

This seems totally reasonable and natural to me - it work like make -
but better. It would dovetail with efforts to "modularize" boost.
Users would only have to download libraries they actually use - if
that's what they want. I realized I've glossed over a couple of details,
in particular recursive inclusion of header files and likely some other
stuff. I've also experimented with CMake enough to have a feeling that
what I want to do is not possible. And this is the short version of
what I'd like to do.

Any thoughts on this?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk