Each CMake project should have the following lines in their top-level CMakeLists.txt file:
cmake_minimum_required(VERSION 3.15...3.19)
project(
Customer
VERSION 0.0.1
LANGUAGES CXX)
Setting a minimum and a maximum supported version is important as it influences how CMake will behave by setting policies. You can also set them manually if needed.
The definition of our project specifies its name, version (which will be used to populate a few variables), and the programming languages that CMake will use to build the project (which populates many more variables and finds the required tools).
A typical C++ project has the following directories:
- cmake: For CMake scripts
- include: For public headers, usually with a subfolder named after the project
- src: For source files and private headers
- test: For tests
You can use the CMake directory to store your custom CMake modules. To have easy access to scripts from this directory, you can add it to CMake's include...