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:
parent
c9568de52c
commit
d19b64d671
|
@ -196,7 +196,7 @@ Installing Directories
|
||||||
install(DIRECTORY dirs... DESTINATION <dir>
|
install(DIRECTORY dirs... DESTINATION <dir>
|
||||||
[FILE_PERMISSIONS permissions...]
|
[FILE_PERMISSIONS permissions...]
|
||||||
[DIRECTORY_PERMISSIONS permissions...]
|
[DIRECTORY_PERMISSIONS permissions...]
|
||||||
[USE_SOURCE_PERMISSIONS] [OPTIONAL]
|
[USE_SOURCE_PERMISSIONS] [OPTIONAL] [MESSAGE_NEVER]
|
||||||
[CONFIGURATIONS [Debug|Release|...]]
|
[CONFIGURATIONS [Debug|Release|...]]
|
||||||
[COMPONENT <component>] [FILES_MATCHING]
|
[COMPONENT <component>] [FILES_MATCHING]
|
||||||
[[PATTERN <pattern> | REGEX <regex>]
|
[[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
|
directories will be given the default permissions specified in the
|
||||||
``PROGRAMS`` form of the command.
|
``PROGRAMS`` form of the command.
|
||||||
|
|
||||||
|
The ``MESSAGE_NEVER`` option disables file installation status output.
|
||||||
|
|
||||||
Installation of directories may be controlled with fine granularity
|
Installation of directories may be controlled with fine granularity
|
||||||
using the ``PATTERN`` or ``REGEX`` options. These "match" options specify a
|
using the ``PATTERN`` or ``REGEX`` options. These "match" options specify a
|
||||||
globbing pattern or regular expression to match directories or files
|
globbing pattern or regular expression to match directories or files
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
install-messages
|
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
|
* The :variable:`CMAKE_INSTALL_MESSAGE` variable was introduced to
|
||||||
optionally reduce output installation.
|
optionally reduce output installation.
|
||||||
|
|
|
@ -917,6 +917,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
|
||||||
Doing doing = DoingDirs;
|
Doing doing = DoingDirs;
|
||||||
bool in_match_mode = false;
|
bool in_match_mode = false;
|
||||||
bool optional = false;
|
bool optional = false;
|
||||||
|
bool message_never = false;
|
||||||
std::vector<std::string> dirs;
|
std::vector<std::string> dirs;
|
||||||
const char* destination = 0;
|
const char* destination = 0;
|
||||||
std::string permissions_file;
|
std::string permissions_file;
|
||||||
|
@ -955,6 +956,21 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
|
||||||
optional = true;
|
optional = true;
|
||||||
doing = DoingNone;
|
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")
|
else if(args[i] == "PATTERN")
|
||||||
{
|
{
|
||||||
// Switch to a new pattern match rule.
|
// Switch to a new pattern match rule.
|
||||||
|
@ -1215,7 +1231,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmInstallGenerator::MessageLevel message =
|
cmInstallGenerator::MessageLevel message =
|
||||||
cmInstallGenerator::SelectMessageLevel(this->Makefile);
|
cmInstallGenerator::SelectMessageLevel(this->Makefile, message_never);
|
||||||
|
|
||||||
// Create the directory install generator.
|
// Create the directory install generator.
|
||||||
this->Makefile->AddInstallGenerator(
|
this->Makefile->AddInstallGenerator(
|
||||||
|
|
|
@ -193,8 +193,12 @@ std::string cmInstallGenerator::GetInstallDestination() const
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmInstallGenerator::MessageLevel
|
cmInstallGenerator::MessageLevel
|
||||||
cmInstallGenerator::SelectMessageLevel(cmMakefile* mf)
|
cmInstallGenerator::SelectMessageLevel(cmMakefile* mf, bool never)
|
||||||
{
|
{
|
||||||
|
if(never)
|
||||||
|
{
|
||||||
|
return MessageNever;
|
||||||
|
}
|
||||||
std::string m = mf->GetSafeDefinition("CMAKE_INSTALL_MESSAGE");
|
std::string m = mf->GetSafeDefinition("CMAKE_INSTALL_MESSAGE");
|
||||||
if(m == "ALWAYS")
|
if(m == "ALWAYS")
|
||||||
{
|
{
|
||||||
|
|
|
@ -60,8 +60,8 @@ public:
|
||||||
/** Test if this generator installs something for a given configuration. */
|
/** Test if this generator installs something for a given configuration. */
|
||||||
bool InstallsForConfig(const std::string& config);
|
bool InstallsForConfig(const std::string& config);
|
||||||
|
|
||||||
/** Select message level from CMAKE_INSTALL_MESSAGE. */
|
/** Select message level from CMAKE_INSTALL_MESSAGE or 'never'. */
|
||||||
static MessageLevel SelectMessageLevel(cmMakefile* mf);
|
static MessageLevel SelectMessageLevel(cmMakefile* mf, bool never = false);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void GenerateScript(std::ostream& os);
|
virtual void GenerateScript(std::ostream& os);
|
||||||
|
|
|
@ -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()
|
|
@ -0,0 +1,3 @@
|
||||||
|
set(CMAKE_INSTALL_MESSAGE "ALWAYS")
|
||||||
|
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/prefix")
|
||||||
|
install(DIRECTORY dir/ DESTINATION dir MESSAGE_NEVER)
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -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\)
|
|
@ -0,0 +1 @@
|
||||||
|
install(DIRECTORY src DESTINATION src PATTERN *.txt MESSAGE_NEVER)
|
|
@ -1,4 +1,6 @@
|
||||||
include(RunCMake)
|
include(RunCMake)
|
||||||
|
run_cmake(DIRECTORY-MESSAGE_NEVER)
|
||||||
|
run_cmake(DIRECTORY-PATTERN-MESSAGE_NEVER)
|
||||||
run_cmake(DIRECTORY-message)
|
run_cmake(DIRECTORY-message)
|
||||||
run_cmake(DIRECTORY-message-lazy)
|
run_cmake(DIRECTORY-message-lazy)
|
||||||
run_cmake(SkipInstallRulesWarning)
|
run_cmake(SkipInstallRulesWarning)
|
||||||
|
|
Loading…
Reference in New Issue