2 Building C++ Projects

Important components:

  1. CMake (cmake?): systemic orchestration of C++ build processes.
  2. Scikit-build-core (scikit-build-core?): building python packages from CMake source code.
  3. Pybind11: binds C++ functions, classes, and objects to Python.

CMake

See tutorial for comprehensive guide.

  • CMake consumes CMakeLists.txt in the source tree. Outputs Makefile (or equivalents) for subsequent building.
  • Typical practice: create build directory, populate with cmake outputs, and run build.
  • It supports hierarchal specification and multiple build targets.

Installing CMake

Installing newest version of cmake: find latest version here, specify version and build (e.g. 4.0.3 is as below):

version=4.0
build=3
## don't modify from here
wget https://cmake.org/files/v$version/cmake-$version.$build.tar.gz
tar -xzvf cmake-$version.$build.tar.gz
cd cmake-$version.$build/

./bootstrap
make -j$(nproc)
sudo make install

This should have installed cmake to /usr/local/bin. If this is this not in system path (e.g. cmake is not found), run

echo 'export PATH=/usr/local/bin:$PATH' >> ~/.bashrc
source ~/.bashrc

Scikit-build-core

Scikit-build-core is a library for building Python packages from CMake source code.

  1. It consumes a pyproject.toml file, standard for python packaging.
  2. Running pip install . installs the python package.

It invokes build backends (e.g. CMake) under the hood to build the package, replacing the need for complicated setup.py.

Smart pointers

Great resources:

  1. David Olsen’s talk, CppCon 2022
  2. Mike Shah’s modern C++ series.

Smart Pointer deep research

Thanks! I’ll put together a detailed technical guide on modern C++ smart pointers aimed at an intermediate developer. It will cover how and why they came into use, the problems they solve, how to use them effectively in polymorphic contexts and function interfaces (including const and reference qualifiers), and best practices in modern C++.

I’ll let you know when it’s ready.