To display compilation information, CMake sets the message statement with the following syntax:
message([<mode>] "message to display"...).Copy the code
About the mode option:
(none) = Important information
STATUS = Incidental information
WARNING = CMake Warning, continue processing
AUTHOR_WARNING = CMake Warning (dev), continue processing
SEND_ERROR = CMake Error, continue processing, but skip generation
FATAL_ERROR = CMake Error, stop processing and generation
DEPRECATION = CMake Deprecation Error or Warning if variable
CMAKE_ERROR_DEPRECATED or CMAKE_WARN_DEPRECATED
is enabled, respectively, else no message.
Copy the code
For example, the implicit variables test_4_BINARY_DIR and test_4_SOURCE_DIR in CMake learn (4) can be printed.
project(test_4)
message("test_4_BINARY_DIR = ${test_4_BINARY_DIR}")
message("test_4_SOURCE_DIR = ${test_4_SOURCE_DIR}")
Copy the code
The result is:
Reference: cmake.org/cmake/help/… www.jianshu.com/p/a2102347d…