Useful commands
CMake offers many, many scripting commands that allow you to work with variables and the environment. Some of them are covered extensively in the Appendix section, for example, list()
, string()
, and file()
(we'll leave these explanations there and concentrate on projects in the main chapters). Others, such as find_...()
, fit better in chapters that talk about managing dependencies. In this section, we'll briefly cover the most useful commands for scripts.
The message() command
We already know and love our trusty message()
command, which prints text to standard output. However, there's a lot more to it than meets the eye. By providing a MODE
argument, you can customize the style of the output, and in the case of an error, you can stop the execution of the code: message(<MODE> "text")
.
The recognized modes are as follows:
FATAL_ERROR
: This stops processing and generation.SEND_ERROR
: This continues processing, but skips...