【Cmake】打印(message)
打印(message)
-
基本用法
-
message([<mode>] "message text" ...) message(<checkState> "message text" ...)
-
用法一(打印信息)
-
mode usage -/NOTICE 无格式 STATUS 非重要消息; DEPRECATION CMake 轻微警告并打印报错地址; WARNING CMake 警告, 会继续执行; AUTHOR_WARNING CMake 警告 (dev), 会继续执行; SEND_ERROR CMake 错误, 继续执行,但是会跳过生成的步骤; FATAL_ERROR CMake 错误, 终止所有处理过程; -
message(1) message(STATUS 2) message(DEPRECATION 3) message(WARNING 4) message(AUTHOR_WARNING 5) message(SEND_ERROR 6) message(FATAL_ERROR 7) message_status
-
-
用法二(checkState)
-
checkState usage CHECK_START 检测开始 CHECK_PASS 检测成功 CHECK_FAIL 检测失败 -
message(CHECK_START "Finding my things") list(APPEND CMAKE_MESSAGE_INDENT " ") unset(missingComponents) message(CHECK_START "Finding partA") # ... do check, assume we find A message(CHECK_PASS "found") message(CHECK_START "Finding partB") # ... do check, assume we don't find B list(APPEND missingComponents B) message(CHECK_FAIL "not found") list(POP_BACK CMAKE_MESSAGE_INDENT) if(missingComponents) message(CHECK_FAIL "missing components: ${missingComponents}") else() message(CHECK_PASS "all components found") endif()
-
-- Finding my things -- Finding partA -- Finding partA - found -- Finding partB -- Finding partB - not found -- Finding my things - missing components: B
-
-
-
循环打印宏
# define a macro loopPrint macro(loopPrint items) # 传入list的时候${items}只等于第一个 # ${ARGV}==整个list # ${ARGN}==整个list - ${items} # message(${items}) # message(${ARGV}) # message(${ARGN}) foreach(item ${ARGV}) message(--------${item}) endforeach(item) endmacro(loopPrint) loopPrint(1 2 3 4 5 6)
参考链接
cool😎!