This guide serves as a comprehensive, open-source cookbook for structuring, compiling, and distributing C++ projects using modern CMake. 1. Structural Blueprint for Multi-Module Projects
my_project/ ├── CMakeLists.txt ├── README.md ├── src/ │ ├── CMakeLists.txt │ └── main.cpp ├── tests/ │ ├── CMakeLists.txt │ └── test_main.cpp └── cmake/ └── FindSomething.cmake Use code with caution. Key Practices from the Cookbook:
include(FetchContent) FetchContent_Declare(pybind11 GIT_REPOSITORY https://github.com/pybind/pybind11.git GIT_TAG v2.10.4) FetchContent_MakeAvailable(pybind11) cmake cookbook pdf github work
The curated list of awesome CMake scripts, modules ... - GitHub
The CMake Cookbook is a comprehensive guide to mastering CMake, written by Philippe Faure and a team of experienced CMake developers. The book provides a collection of recipes, examples, and best practices for using CMake in various scenarios. The cookbook covers a wide range of topics, from basic CMake usage to advanced techniques, such as dependency management, cross-compiling, and optimizing build performance. This guide serves as a comprehensive, open-source cookbook
CMake fundamentals and project layout
You can still learn from the repository even without purchasing the book. Each example contains: The cookbook covers a wide range of topics,
To access the full book in PDF format, you must purchase or subscribe to it legally. Official sources include:
The code in the master branch may have evolved beyond the examples printed in the book. To work with code that exactly matches the 2018 publication, use the tagged version v1.0 :