Search⌘ K
AI Features

Navigate the Project Files: Directory Structure and Cache Variable

Explore the roles of key CMake project files including source and build directories, and cache variables. Understand how to organize your project structure, use CMakeLists.txt files, and manage build artifacts and configuration settings for a clean, maintainable build process.

CMake uses quite a few files to manage its projects. Let's attempt to get a general idea of what each file does before tinkering with the contents. It's important to realize that even though a file contains CMake language commands, it's not certain that it's meant for developers to edit:

  • Some files are generated to be used by subsequent tools, and any changes made to those files will be written over at some stage.

  • Other files are meant for advanced users to adjust the project according to their individual needs.

  • Finally, there are some temporary files that provide valuable information in specific contexts.

This lesson will also specify which of them should be in the ignore file of our version control system.

The source tree

This is the directory where our project will live (it is also called the project root). It contains all of the C++ sources and CMake project files.

Here are the key takeaways of this directory:

  • It is required that we provide a CMakeLists.txt configuration file in its top directory.

  • It should be managed with a ...