告诉cmake的安静 [英] tell cmake to be quiet

查看:167
本文介绍了告诉cmake的安静的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个变量,我可以在cmake的使用,使其像它传递的-q选项?这将是不错的,因为我有一个非常模块化的构建,获取凌乱cmakes输出。我使用它在C ++项目。


解决方案

有没有变化,我知道的。但是,您可以(在项目调用之前)下面的技巧添加到您顶级的CMakeLists.txt开始有所控制输出:

 函数(消息)
  列表(GET ARGV 0消息类型)
  如果(消息类型STREQUAL是fatal_error OR
     消息类型STREQUAL SEND_ERROR OR
     消息类型STREQUAL警告或
     消息类型STREQUAL AUTHOR_WARNING)
    列表(REMOVE_AT ARGV 0)
    _message($ {}消息类型$ {} ARGV)
  万一()
endfunction可()

这将覆盖的CMake的内置的消息命令和SUP presses所有状态和非类型化的消息,留下更重要的类型正确地输出。

例如的输出一个警告消息将从

改变

  CMake的警告时的CMakeLists.txt:14(消息):
  这是一个虚警告消息。



  CMake的警告时的CMakeLists.txt:8(_message):
  这是一个虚警告消息。
(第一最近一次调用)调用堆栈:
  的CMakeLists.txt:14(消息)


请注意,凡生成警告消息在调用栈中列出而不是输出消息的第一行实际的行

最后,这对汇总输出,表明配置尝试的成功或失败没有影响。

Is there a variable I can use in cmake to make it act like it was passed the -q option? It would be nice because I have a very modular build that gets messy with cmakes output. I am using it in a c++ project.

解决方案

There's no variable that I know of. However, you can add the following hack to the start of your top-level CMakeLists.txt (before the project call) to control the output somewhat:

function(message)
  list(GET ARGV 0 MessageType)
  if(MessageType STREQUAL FATAL_ERROR OR
     MessageType STREQUAL SEND_ERROR OR
     MessageType STREQUAL WARNING OR
     MessageType STREQUAL AUTHOR_WARNING)
    list(REMOVE_AT ARGV 0)
    _message(${MessageType} "${ARGV}")
  endif()
endfunction()

This overrides CMake's built-in message command and suppresses all STATUS and untyped messages, leaving the more important types to output correctly.

The output of e.g. a WARNING message will change from

CMake Warning at CMakeLists.txt:14 (message):
  This is a dummy warning message.

to

CMake Warning at CMakeLists.txt:8 (_message):
  This is a dummy warning message.
Call Stack (most recent call first):
  CMakeLists.txt:14 (message)

Note that the actual line where the warning message was generated is listed in the call stack rather than being the first line of the output message.

Finally, this has no effect on the summary output which indicates success or failure of the configure attempt.

这篇关于告诉cmake的安静的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆