install(DIRECTORY): Add MESSAGE_NEVER option to avoid output (#13761)

Installing large directories, e.g., the output of a doxygen run, prints
one line per file resulting in too much noise in the build output.  Add
an option to the install(DIRECTORY) command to not print anything upon
make install.

Extend the RunCMake.install test with cases covering MESSAGE_NEVER
behavior of the install(DIRECTORY) command.

Suggested-by: Stefan Eilemann <Stefan.Eilemann@epfl.ch>
This commit is contained in:
Brad King 2014-06-24 11:40:26 -04:00
parent c9568de52c
commit d19b64d671
11 changed files with 54 additions and 5 deletions

View File

@ -196,7 +196,7 @@ Installing Directories
install(DIRECTORY dirs... DESTINATION <dir>
[FILE_PERMISSIONS permissions...]
[DIRECTORY_PERMISSIONS permissions...]
[USE_SOURCE_PERMISSIONS] [OPTIONAL]
[USE_SOURCE_PERMISSIONS] [OPTIONAL] [MESSAGE_NEVER]
[CONFIGURATIONS [Debug|Release|...]]
[COMPONENT <component>] [FILES_MATCHING]
[[PATTERN <pattern> | REGEX <regex>]
@ -219,6 +219,8 @@ permissions specified in the ``FILES`` form of the command, and the
directories will be given the default permissions specified in the
``PROGRAMS`` form of the command.
The ``MESSAGE_NEVER`` option disables file installation status output.
Installation of directories may be controlled with fine granularity
using the ``PATTERN`` or ``REGEX`` options. These "match" options specify a
globbing pattern or regular expression to match directories or files

View File

@ -1,5 +1,8 @@
install-messages
----------------
* The :command:`install` command learned a ``MESSAGE_NEVER`` option
to avoid output during installation.
* The :variable:`CMAKE_INSTALL_MESSAGE` variable was introduced to
optionally reduce output installation.

View File

@ -917,6 +917,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
Doing doing = DoingDirs;
bool in_match_mode = false;
bool optional = false;
bool message_never = false;
std::vector<std::string> dirs;
const char* destination = 0;
std::string permissions_file;
@ -955,6 +956,21 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
optional = true;
doing = DoingNone;
}
else if(args[i] == "MESSAGE_NEVER")
{
if(in_match_mode)
{
cmOStringStream e;
e << args[0] << " does not allow \""
<< args[i] << "\" after PATTERN or REGEX.";
this->SetError(e.str());
return false;
}
// Mark the rule as quiet.
message_never = true;
doing = DoingNone;
}
else if(args[i] == "PATTERN")
{
// Switch to a new pattern match rule.
@ -1215,7 +1231,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
}
cmInstallGenerator::MessageLevel message =
cmInstallGenerator::SelectMessageLevel(this->Makefile);
cmInstallGenerator::SelectMessageLevel(this->Makefile, message_never);
// Create the directory install generator.
this->Makefile->AddInstallGenerator(

View File

@ -193,8 +193,12 @@ std::string cmInstallGenerator::GetInstallDestination() const
//----------------------------------------------------------------------------
cmInstallGenerator::MessageLevel
cmInstallGenerator::SelectMessageLevel(cmMakefile* mf)
cmInstallGenerator::SelectMessageLevel(cmMakefile* mf, bool never)
{
if(never)
{
return MessageNever;
}
std::string m = mf->GetSafeDefinition("CMAKE_INSTALL_MESSAGE");
if(m == "ALWAYS")
{

View File

@ -60,8 +60,8 @@ public:
/** Test if this generator installs something for a given configuration. */
bool InstallsForConfig(const std::string& config);
/** Select message level from CMAKE_INSTALL_MESSAGE. */
static MessageLevel SelectMessageLevel(cmMakefile* mf);
/** Select message level from CMAKE_INSTALL_MESSAGE or 'never'. */
static MessageLevel SelectMessageLevel(cmMakefile* mf, bool never = false);
protected:
virtual void GenerateScript(std::ostream& os);

View File

@ -0,0 +1,13 @@
file(REMOVE_RECURSE ${RunCMake_TEST_BINARY_DIR}/prefix)
execute_process(COMMAND ${CMAKE_COMMAND} -P ${RunCMake_TEST_BINARY_DIR}/cmake_install.cmake
OUTPUT_VARIABLE out ERROR_VARIABLE err)
if(out MATCHES "-- Installing: [^\n]*prefix/dir")
string(REGEX REPLACE "\n" "\n " out " ${out}")
set(RunCMake_TEST_FAILED
"${RunCMake_TEST_FAILED}Installation output was not quiet:\n${out}")
endif()
set(f ${RunCMake_TEST_BINARY_DIR}/prefix/dir/empty.txt)
if(NOT EXISTS "${f}")
set(RunCMake_TEST_FAILED
"${RunCMake_TEST_FAILED}File was not installed:\n ${f}\n")
endif()

View File

@ -0,0 +1,3 @@
set(CMAKE_INSTALL_MESSAGE "ALWAYS")
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/prefix")
install(DIRECTORY dir/ DESTINATION dir MESSAGE_NEVER)

View File

@ -0,0 +1,4 @@
CMake Error at DIRECTORY-PATTERN-MESSAGE_NEVER.cmake:[0-9]+ \(install\):
install DIRECTORY does not allow "MESSAGE_NEVER" after PATTERN or REGEX.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -0,0 +1 @@
install(DIRECTORY src DESTINATION src PATTERN *.txt MESSAGE_NEVER)

View File

@ -1,4 +1,6 @@
include(RunCMake)
run_cmake(DIRECTORY-MESSAGE_NEVER)
run_cmake(DIRECTORY-PATTERN-MESSAGE_NEVER)
run_cmake(DIRECTORY-message)
run_cmake(DIRECTORY-message-lazy)
run_cmake(SkipInstallRulesWarning)