从包含的CMakeList.txt中删除邮件 [英] Remove messages from an included CMakeList.txt
问题描述
我通过使用一个简单的 add_subdirectory
将一个项目包含在我的项目中。
I'm including a project into mine by using a simple add_subdirectory
.
相当冗长和填充我的构建与许多消息。
不修改外部项目...是否可以删除所有(或部分)那些烦人的导入邮件?
However, that project is quite verbose and fill my build with many messages. Without modifying the external project... is it possible to remove all (or part) of those annoying imported messages?
推荐答案
如果外部项目本身不支持它(例如此处< a>),您仍然可以选择覆盖 message()
函数,并声明自己的算法/检查何时打印邮件。
If the external project itself does not support it (like e.g. here), you still have the option to overwrite the message()
function and declare your own algorithm/check when to print messages.
以下是一个简单检查名为 MESSAGE_QUIET
的变量的版本:
Here is a version with a simple check for a variable named MESSAGE_QUIET
:
CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project(MessageQuiet)
function(message)
if (NOT MESSAGE_QUIET)
_message(${ARGN})
endif()
endfunction()
set(MESSAGE_QUIET ON)
add_subdirectory(ExternalProject)
unset(MESSAGE_QUIET)
message(STATUS "Hello from my project")
ExternalProject\CMakeLists.txt
message("Hello from external project")
这篇关于从包含的CMakeList.txt中删除邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!