Reputation: 346
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?
Upvotes: 3
Views: 2154
Reputation: 4190
You can try adjusting the CMAKE_MESSAGE_LOG_LEVEL variable:
set(_saved_CMAKE_MESSAGE_LOG_LEVEL ${CMAKE_MESSAGE_LOG_LEVEL})
set(CMAKE_MESSAGE_LOG_LEVEL NOTICE)
add_subdirectory(ExternalProject)
set(CMAKE_MESSAGE_LOG_LEVEL ${_saved_CMAKE_MESSAGE_LOG_LEVEL})
Upvotes: 1
Reputation: 42872
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.
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")
Upvotes: 8
Reputation: 23294
By including a subdirectory, you cannot suppress the output.
If it is a find script, you can call it with QUIET
. If you can call the script with cmake -P scriptToExecute
instead of including the sub-directory, you can redirect the output.
Upvotes: 1