Setting up a project
Although CMake can work with almost any file structure for a project, there are some good practices regarding how to organize files. The examples in this book follow the following common pattern:
├── CMakeLists.txt ├── build ├── include/project_name └── src
There are three folders and one file present in a minimal project structure. They are as follows:
build
: The folder where thebuild
files and binaries are placed. When checking out a fresh project, the build folder is usually not yet present as it will be generated by CMake. It is typically namedbuild
, but it can have any name.include/project_name
: This folder contains all the header files that are publicly accessible from outside the project. Adding a subfolder that contains the project’s name is helpful since includes are done with<project_name/somefile.h>
, making it easier to figure out which...