2 Building C++ Projects
Important components:
- CMake (cmake?): systemic orchestration of C++ build processes.
- Scikit-build-core (scikit-build-core?): building python packages from CMake source code.
- Pybind11: binds C++ functions, classes, and objects to Python.
CMake
See tutorial for comprehensive guide.
- CMake consumes
CMakeLists.txtin the source tree. OutputsMakefile(or equivalents) for subsequent building. - Typical practice: create
builddirectory, populate withcmakeoutputs, 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.
- It consumes a
pyproject.tomlfile, standard for python packaging. - 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:
- David Olsen’s talk, CppCon 2022
- 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.