Building and managing dependencies
All build processes follow the same procedure. We begin with the top-level listfile and progress downward through the project’s source tree. Figure 15.4 illustrates the project files involved in the build process, with numbers in parentheses indicating the order of CMake script execution.
Figure 15.4: Files used in the build stage
The top-level CMakeLists.txt
(1) listfile configures the project:
ch15/01-full-project/CMakeLists.txt
cmake_minimum_required(VERSION 3.26)
project(Calc VERSION 1.1.0 LANGUAGES CXX)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(NoInSourceBuilds)
include(CTest)
add_subdirectory(src bin)
add_subdirectory(test)
include(Packaging)
We start by specifying essential project details and setting the path to the CMake utility modules (the cmake
directory in our project). We then prevent in-source builds using a custom module. Following that, we enable testing with the...