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 use 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.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 library a header file is coming from.src
: This folder contains all the source and header files that are private.CMakeLists.txt
: This is the root CMake file. ...