The basics of the CMake Language syntax
Composing CMake code is very much like writing in any other imperative language: lines are executed from top to bottom and from left to right, occasionally stepping into an included file or a called function. Depending on the mode (see the Mastering the command line section in Chapter 1, First Steps with CMake), the execution begins from the root file of the source tree (CMakeLists.txt
) or a .cmake
script file that was passed as an argument to cmake
.
As we discussed in the previous chapter, scripts support the majority of the CMake Language (with the exclusion of any project-related functionality). As a result, they're a great way to start practicing the CMake syntax itself, and that's why we'll be using them here. After becoming comfortable writing basic listfiles, we'll start preparing actual project files in the next chapter. If you remember, scripts can be run with the following command:
cmake -P script.cmake...