This repository collects sources for the recipes contained in the CMake Cookbook published by Packt and authored by Radovan Bast and Roberto Di Remigio
- 1. Compiling a single source file into an executable
- 2. Switching generators
- 3. Building and linking static and shared libraries
- 4. Controlling compilation with conditionals
- 5. Presenting options to the user
- 6. Specifying the compiler
- 7. Switching the build type
- 8. Controlling compiler flags
- 9. Setting the standard for the language
- 10. Using control flow constructs
- 1. Discovering the operating system
- 2. Dealing with platform-dependent source code
- 3. Dealing with compiler-dependent source code
- 4. Discovering the host processor architecture
- 5. Discovering the host processor instruction set
- 6. Enabling vectorization for the Eigen library
- 1. Detecting the Python interpreter
- 2. Detecting the Python library
- 3. Detecting Python modules and packages
- 4. Detecting the BLAS and LAPACK math libraries
- 5. Detecting the OpenMP parallel environment
- 6. Detecting the MPI parallel environment
- 7. Detecting the Eigen library
- 8. Detecting the Boost libraries
- 9. Detecting external libraries: I. Using
pkg-config
- 10. Detecting external libraries: II. Writing a find-module
- 1. Creating a simple unit test
- 2. Defining a unit test using the Catch2 library
- 3. Defining a unit test and linking against Google Test
- 4. Defining a unit test and linking against Boost test
- 5. Using dynamic analysis to detect memory defects
- 6. Testing expected failures
- 7. Using timeouts for long tests
- 8. Running tests in parallel
- 9. Running a subset of tests
- 10. Using test fixtures
- 1. Using platform-independent file operations
- 2. Running a custom command at configure time
- 3. Running a custom command at build time: I. Using
add_custom_command
- 4. Running a custom command at build time: II. Using
add_custom_target
- 5. Running custom commands for specific targets at build time
- 6. Probing compilation and linking
- 7. Probing compiler flags
- 8. Probing execution
- 9. Fine-tuning configuration and compilation with generator expressions
- 1. Generating sources at configure time
- 2. Generating source code at configure time using Python
- 3. Generating source code at build time using Python
- 4. Recording the project version information for reproducibility
- 5. Recording the project version from a file
- 6. Recording the Git hash at configure time
- 7. Recording the Git hash at build time
- 1. Code reuse with functions and macros
- 2. Splitting CMake sources into modules
- 3. Writing a function to test and set compiler flags
- 4. Defining a function or macro with named arguments
- 5. Redefining functions and macros
- 6. Deprecating functions, macros, and variables
- 7. Limiting scope with
add_subdirectory
- 8. Avoiding global variables using
target_sources
- 9. Organizing Fortran projects
- 1. Using the superbuild pattern
- 2. Managing dependencies with a superbuild: I. The Boost libraries
- 3. Managing dependencies with a superbuild: II. The FFTW library
- 4. Managing dependencies with a superbuild: III. The Google Test framework
- 5. Managing your project as a superbuild
- 1. Building Fortran projects that use C/C++ libraries
- 2. Building C/C++ projects that use Fortran libraries
- 3. Building C++ and Python projects using Cython
- 4. Building C++ and Python projects using Boost.Python
- 5. Building C++ and Python projects using pybind11
- 6. Mixing C, C++, Fortran, and Python using Python CFFI
- 1. Installing your project
- 2. Generating export headers
- 3. Exporting your targets
- 4. Installing a superbuild
- 1. Generating source and binary packages
- 2. Distributing a C++/Python project built with CMake/pybind11 via PyPI
- 3. Distributing a C/Fortran/Python project built with CMake/CFFI via PyPI
- 4. Distributing a simple project as Conda package
- 5. Distributing a project with dependencies as Conda package
- 1. Building documentation using Doxygen
- 2. Building documentation using Sphinx
- 3. Combining Doxygen and Sphinx