CMake学习(五) —— 打印信息

为了可以显示编译信息,CMake设置了message语句,语法如下:

message([<mode>] "message to display" ...)

关于 mode 选项:

(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.

例如 CMake学习(四) 中的隐式变量test_4_BINARY_DIR 和 test_4_SOURCE_DIR 可以打印输出。

project(test_4)
message("test_4_BINARY_DIR = ${test_4_BINARY_DIR}")
message("test_4_SOURCE_DIR = ${test_4_SOURCE_DIR}")

结果为:
please write description of the picture here please write description of the picture here please write description of the picture here please write description of the picture here

参考:
https://cmake.org/cmake/help/v3.14/command/message.html?highlight=message
https://www.jianshu.com/p/a2102347d464

发布了72 篇原创文章 · 获赞 87 · 访问量 20万+

猜你喜欢

转载自blog.csdn.net/maizousidemao/article/details/104098433