From 67815894cabcba32b6afbf3438dc45a00f1a7406 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 24 Jun 2014 12:51:19 -0400 Subject: Help: Add install() command document section headers Use section headers instead of horizontal dividers so that one may link to the sections. --- Help/command/install.rst | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/Help/command/install.rst b/Help/command/install.rst index 47108f0..462a8a9 100644 --- a/Help/command/install.rst +++ b/Help/command/install.rst @@ -1,8 +1,15 @@ install ------- +.. only:: html + + .. contents:: + Specify rules to run at install time. +Introduction +^^^^^^^^^^^^ + This command generates installation rules for a project. Rules specified by calls to this command within a source directory are executed in order during installation. The order across directories @@ -52,7 +59,8 @@ signatures that specify them. The common options are: Specify that it is not an error if the file to be installed does not exist. ------------------------------------------------------------------------------- +Installing Targets +^^^^^^^^^^^^^^^^^^ :: @@ -147,7 +155,8 @@ file itself, call ``install(EXPORT)``, documented below. Installing a target with the :prop_tgt:`EXCLUDE_FROM_ALL` target property set to ``TRUE`` has undefined behavior. ------------------------------------------------------------------------------- +Installing Files +^^^^^^^^^^^^^^^^ :: @@ -175,7 +184,8 @@ The list of ``files...`` given to ``FILES`` or ``PROGRAMS`` may use However, if any item begins in a generator expression it must evaluate to a full path. ------------------------------------------------------------------------------- +Installing Directories +^^^^^^^^^^^^^^^^^^^^^^ :: @@ -247,7 +257,8 @@ will install the ``icons`` directory to ``share/myproj/icons`` and the file permissions, the scripts will be given specific permissions, and any ``CVS`` directories will be excluded. ------------------------------------------------------------------------------- +Custom Installation Logic +^^^^^^^^^^^^^^^^^^^^^^^^^ :: @@ -266,7 +277,8 @@ example, the code will print a message during installation. ------------------------------------------------------------------------------- +Installing Exports +^^^^^^^^^^^^^^^^^^ :: -- cgit v0.12 From f0a0196250de349e97fe579165f7a9b580ed63e8 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 24 Jun 2014 10:55:20 -0400 Subject: cmInstallTargetGenerator: Drop default constructor arguments They are used only in cmLocalGenerator::GenerateTargetInstallRules. Move the defaults to a local helper where the context justifies their values. --- Source/cmInstallTargetGenerator.h | 9 ++++----- Source/cmLocalGenerator.cxx | 22 ++++++++++++++++++---- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 0f21da7..d718dbc 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -24,11 +24,10 @@ class cmInstallTargetGenerator: public cmInstallGenerator public: cmInstallTargetGenerator( cmTarget& t, const char* dest, bool implib, - const char* file_permissions = "", - std::vector const& configurations - = std::vector(), - const char* component = "Unspecified", - bool optional = false + const char* file_permissions, + std::vector const& configurations, + const char* component, + bool optional ); virtual ~cmInstallTargetGenerator(); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 8ae1157..2243834 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2998,6 +2998,16 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector& local, } //---------------------------------------------------------------------------- +class cmInstallTargetGeneratorLocal: public cmInstallTargetGenerator +{ +public: + cmInstallTargetGeneratorLocal(cmTarget& t, const char* dest, bool implib): + cmInstallTargetGenerator( + t, dest, implib, "", std::vector(), "Unspecified", + false) {} +}; + +//---------------------------------------------------------------------------- void cmLocalGenerator ::GenerateTargetInstallRules( @@ -3042,7 +3052,8 @@ cmLocalGenerator case cmTarget::MODULE_LIBRARY: { // Use a target install generator. - cmInstallTargetGenerator g(l->second, destination.c_str(), false); + cmInstallTargetGeneratorLocal + g(l->second, destination.c_str(), false); g.Generate(os, config, configurationTypes); } break; @@ -3052,16 +3063,19 @@ cmLocalGenerator // Special code to handle DLL. Install the import library // to the normal destination and the DLL to the runtime // destination. - cmInstallTargetGenerator g1(l->second, destination.c_str(), true); + cmInstallTargetGeneratorLocal + g1(l->second, destination.c_str(), true); g1.Generate(os, config, configurationTypes); // We also skip over the leading slash given by the user. destination = l->second.GetRuntimeInstallPath().substr(1); cmSystemTools::ConvertToUnixSlashes(destination); - cmInstallTargetGenerator g2(l->second, destination.c_str(), false); + cmInstallTargetGeneratorLocal + g2(l->second, destination.c_str(), false); g2.Generate(os, config, configurationTypes); #else // Use a target install generator. - cmInstallTargetGenerator g(l->second, destination.c_str(), false); + cmInstallTargetGeneratorLocal + g(l->second, destination.c_str(), false); g.Generate(os, config, configurationTypes); #endif } -- cgit v0.12 From f701b0b7f7eb4a7cd6fe96f285835b03604fb477 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 23 Jun 2014 13:52:17 -0400 Subject: file(INSTALL): Do not pre-create DESTINATION for DIRECTORY When installing a DIRECTORY, do not pre-create the DESTINATION. The cmFileCopier::InstallDirectory method will create the directory anyway. Give it a chance to detect whether the directory already exists or not. --- Source/cmFileCommand.cxx | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 655f3ba..83f356a 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2057,23 +2057,26 @@ bool cmFileInstaller::HandleInstallDestination() this->DestDirLength = int(sdestdir.size()); } - if ( !cmSystemTools::FileExists(destination.c_str()) ) + if(this->InstallType != cmInstallType_DIRECTORY) { - if ( !cmSystemTools::MakeDirectory(destination.c_str()) ) + if ( !cmSystemTools::FileExists(destination.c_str()) ) { - std::string errstring = "cannot create directory: " + destination + + if ( !cmSystemTools::MakeDirectory(destination.c_str()) ) + { + std::string errstring = "cannot create directory: " + destination + ". Maybe need administrative privileges."; + this->FileCommand->SetError(errstring); + return false; + } + } + if ( !cmSystemTools::FileIsDirectory(destination.c_str()) ) + { + std::string errstring = "INSTALL destination: " + destination + + " is not a directory."; this->FileCommand->SetError(errstring); return false; } } - if ( !cmSystemTools::FileIsDirectory(destination.c_str()) ) - { - std::string errstring = "INSTALL destination: " + destination + - " is not a directory."; - this->FileCommand->SetError(errstring); - return false; - } return true; } -- cgit v0.12 From 464567a577555659610b2a26f9c1733d672583de Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 23 Jun 2014 13:54:52 -0400 Subject: file(INSTALL): Report existing DIRECTORY as Up-to-date Teach cmFileCopier::InstallDirectory to detect whether the destination directory exists. If so, report it as "Up-to-date" instead of "Installing". This resolves message asymmetry with file installations. Extend the RunCMake.file and RunCMake.install tests to check the installation output on both the first and second run. Suggested-by: J Decker --- Source/cmFileCommand.cxx | 3 ++- Tests/RunCMake/file/INSTALL-DIRECTORY-stdout.txt | 6 +++++ Tests/RunCMake/file/INSTALL-DIRECTORY.cmake | 7 ++++++ Tests/RunCMake/file/RunCMakeTest.cmake | 1 + Tests/RunCMake/file/dir/empty.txt | 0 .../RunCMake/install/DIRECTORY-message-check.cmake | 28 ++++++++++++++++++++++ Tests/RunCMake/install/DIRECTORY-message.cmake | 2 ++ Tests/RunCMake/install/RunCMakeTest.cmake | 1 + Tests/RunCMake/install/dir/empty.txt | 0 9 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/file/INSTALL-DIRECTORY-stdout.txt create mode 100644 Tests/RunCMake/file/INSTALL-DIRECTORY.cmake create mode 100644 Tests/RunCMake/file/dir/empty.txt create mode 100644 Tests/RunCMake/install/DIRECTORY-message-check.cmake create mode 100644 Tests/RunCMake/install/DIRECTORY-message.cmake create mode 100644 Tests/RunCMake/install/dir/empty.txt diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 83f356a..99c7ad1 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -1613,7 +1613,8 @@ bool cmFileCopier::InstallDirectory(const char* source, MatchProperties const& match_properties) { // Inform the user about this directory installation. - this->ReportCopy(destination, TypeDir, true); + this->ReportCopy(destination, TypeDir, + !cmSystemTools::FileIsDirectory(destination)); // Make sure the destination directory exists. if(!cmSystemTools::MakeDirectory(destination)) diff --git a/Tests/RunCMake/file/INSTALL-DIRECTORY-stdout.txt b/Tests/RunCMake/file/INSTALL-DIRECTORY-stdout.txt new file mode 100644 index 0000000..d2e6f4d --- /dev/null +++ b/Tests/RunCMake/file/INSTALL-DIRECTORY-stdout.txt @@ -0,0 +1,6 @@ +-- Before Installing +-- Installing: .*/Tests/RunCMake/file/INSTALL-DIRECTORY-build/dir +-- Installing: .*/Tests/RunCMake/file/INSTALL-DIRECTORY-build/dir/empty.txt +-- Up-to-date: .*/Tests/RunCMake/file/INSTALL-DIRECTORY-build/dir +-- Up-to-date: .*/Tests/RunCMake/file/INSTALL-DIRECTORY-build/dir/empty.txt +-- After Installing diff --git a/Tests/RunCMake/file/INSTALL-DIRECTORY.cmake b/Tests/RunCMake/file/INSTALL-DIRECTORY.cmake new file mode 100644 index 0000000..8bcb077 --- /dev/null +++ b/Tests/RunCMake/file/INSTALL-DIRECTORY.cmake @@ -0,0 +1,7 @@ +set(src ${CMAKE_CURRENT_SOURCE_DIR}/dir) +set(dst ${CMAKE_CURRENT_BINARY_DIR}/dir) +file(REMOVE RECURSE ${dst}) +message(STATUS "Before Installing") +file(INSTALL FILES ${src}/ DESTINATION ${dst} TYPE DIRECTORY) +file(INSTALL FILES ${src}/ DESTINATION ${dst} TYPE DIRECTORY) +message(STATUS "After Installing") diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index 7b05229..09e3629 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -1,3 +1,4 @@ include(RunCMake) +run_cmake(INSTALL-DIRECTORY) run_cmake(FileOpenFailRead) diff --git a/Tests/RunCMake/file/dir/empty.txt b/Tests/RunCMake/file/dir/empty.txt new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/install/DIRECTORY-message-check.cmake b/Tests/RunCMake/install/DIRECTORY-message-check.cmake new file mode 100644 index 0000000..857681f --- /dev/null +++ b/Tests/RunCMake/install/DIRECTORY-message-check.cmake @@ -0,0 +1,28 @@ +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) +set(expect " +-- Installing: [^\n]*/prefix/dir\r? +-- Installing: [^\n]*/prefix/dir/empty.txt\r? +") +if(NOT out MATCHES "${expect}") + string(REGEX REPLACE "\n" "\n " out " ${out}") + set(RunCMake_TEST_FAILED + "${RunCMake_TEST_FAILED}First install did not say 'Installing' as expected:\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() +execute_process(COMMAND ${CMAKE_COMMAND} -P ${RunCMake_TEST_BINARY_DIR}/cmake_install.cmake + OUTPUT_VARIABLE out ERROR_VARIABLE err) +set(expect " +-- Up-to-date: [^\n]*/prefix/dir\r? +-- Up-to-date: [^\n]*/prefix/dir/empty.txt\r? +") +if(NOT out MATCHES "${expect}") + string(REGEX REPLACE "\n" "\n " out " ${out}") + set(RunCMake_TEST_FAILED + "${RunCMake_TEST_FAILED}Second install did not say 'Up-to-date' as expected:\n${out}") +endif() diff --git a/Tests/RunCMake/install/DIRECTORY-message.cmake b/Tests/RunCMake/install/DIRECTORY-message.cmake new file mode 100644 index 0000000..548e0df --- /dev/null +++ b/Tests/RunCMake/install/DIRECTORY-message.cmake @@ -0,0 +1,2 @@ +set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/prefix") +install(DIRECTORY dir/ DESTINATION dir) diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake index c8dc379..39d2c1d 100644 --- a/Tests/RunCMake/install/RunCMakeTest.cmake +++ b/Tests/RunCMake/install/RunCMakeTest.cmake @@ -1,4 +1,5 @@ include(RunCMake) +run_cmake(DIRECTORY-message) run_cmake(SkipInstallRulesWarning) run_cmake(SkipInstallRulesNoWarning1) run_cmake(SkipInstallRulesNoWarning2) diff --git a/Tests/RunCMake/install/dir/empty.txt b/Tests/RunCMake/install/dir/empty.txt new file mode 100644 index 0000000..e69de29 -- cgit v0.12 From abebcd235c94e05a20003430981a1b46b0fb7f95 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 24 Jun 2014 11:42:39 -0400 Subject: file(INSTALL): Add undocumented options to control output verbosity Create options "MESSAGE_ALWAYS", "MESSAGE_LAZY", and "MESSAGE_NEVER" to specify whether to print the "Installing" and "Up-to-date" messages. Extend the RunCMake.file test with cases covering these options. --- Source/cmFileCommand.cxx | 61 ++++++++++++++++++++-- Tests/RunCMake/file/INSTALL-DIRECTORY-stdout.txt | 2 + Tests/RunCMake/file/INSTALL-DIRECTORY.cmake | 3 ++ Tests/RunCMake/file/INSTALL-MESSAGE-bad-result.txt | 1 + Tests/RunCMake/file/INSTALL-MESSAGE-bad-stderr.txt | 32 ++++++++++++ Tests/RunCMake/file/INSTALL-MESSAGE-bad.cmake | 6 +++ Tests/RunCMake/file/RunCMakeTest.cmake | 1 + 7 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 Tests/RunCMake/file/INSTALL-MESSAGE-bad-result.txt create mode 100644 Tests/RunCMake/file/INSTALL-MESSAGE-bad-stderr.txt create mode 100644 Tests/RunCMake/file/INSTALL-MESSAGE-bad.cmake diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 99c7ad1..61c6eb3 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -1705,6 +1705,9 @@ struct cmFileInstaller: public cmFileCopier cmFileCopier(command, "INSTALL"), InstallType(cmInstallType_FILES), Optional(false), + MessageAlways(false), + MessageLazy(false), + MessageNever(false), DestDirLength(0) { // Installation does not use source permissions by default. @@ -1726,6 +1729,9 @@ struct cmFileInstaller: public cmFileCopier protected: cmInstallType InstallType; bool Optional; + bool MessageAlways; + bool MessageLazy; + bool MessageNever; int DestDirLength; std::string Rename; @@ -1741,9 +1747,12 @@ protected: virtual void ReportCopy(const char* toFile, Type type, bool copy) { - std::string message = (copy? "Installing: " : "Up-to-date: "); - message += toFile; - this->Makefile->DisplayStatus(message.c_str(), -1); + if(!this->MessageNever && (copy || !this->MessageLazy)) + { + std::string message = (copy? "Installing: " : "Up-to-date: "); + message += toFile; + this->Makefile->DisplayStatus(message.c_str(), -1); + } if(type != TypeDir) { // Add the file to the manifest. @@ -1829,6 +1838,16 @@ bool cmFileInstaller::Parse(std::vector const& args) return false; } + if(((this->MessageAlways?1:0) + + (this->MessageLazy?1:0) + + (this->MessageNever?1:0)) > 1) + { + this->FileCommand->SetError("INSTALL options MESSAGE_ALWAYS, " + "MESSAGE_LAZY, and MESSAGE_NEVER " + "are mutually exclusive."); + return false; + } + return true; } @@ -1880,6 +1899,42 @@ bool cmFileInstaller::CheckKeyword(std::string const& arg) this->Optional = true; } } + else if(arg == "MESSAGE_ALWAYS") + { + if(this->CurrentMatchRule) + { + this->NotAfterMatch(arg); + } + else + { + this->Doing = DoingNone; + this->MessageAlways = true; + } + } + else if(arg == "MESSAGE_LAZY") + { + if(this->CurrentMatchRule) + { + this->NotAfterMatch(arg); + } + else + { + this->Doing = DoingNone; + this->MessageLazy = true; + } + } + else if(arg == "MESSAGE_NEVER") + { + if(this->CurrentMatchRule) + { + this->NotAfterMatch(arg); + } + else + { + this->Doing = DoingNone; + this->MessageNever = true; + } + } else if(arg == "PERMISSIONS") { if(this->CurrentMatchRule) diff --git a/Tests/RunCMake/file/INSTALL-DIRECTORY-stdout.txt b/Tests/RunCMake/file/INSTALL-DIRECTORY-stdout.txt index d2e6f4d..561a6b1 100644 --- a/Tests/RunCMake/file/INSTALL-DIRECTORY-stdout.txt +++ b/Tests/RunCMake/file/INSTALL-DIRECTORY-stdout.txt @@ -3,4 +3,6 @@ -- Installing: .*/Tests/RunCMake/file/INSTALL-DIRECTORY-build/dir/empty.txt -- Up-to-date: .*/Tests/RunCMake/file/INSTALL-DIRECTORY-build/dir -- Up-to-date: .*/Tests/RunCMake/file/INSTALL-DIRECTORY-build/dir/empty.txt +-- Up-to-date: .*/Tests/RunCMake/file/INSTALL-DIRECTORY-build/dir +-- Up-to-date: .*/Tests/RunCMake/file/INSTALL-DIRECTORY-build/dir/empty.txt -- After Installing diff --git a/Tests/RunCMake/file/INSTALL-DIRECTORY.cmake b/Tests/RunCMake/file/INSTALL-DIRECTORY.cmake index 8bcb077..0bc1d18 100644 --- a/Tests/RunCMake/file/INSTALL-DIRECTORY.cmake +++ b/Tests/RunCMake/file/INSTALL-DIRECTORY.cmake @@ -4,4 +4,7 @@ file(REMOVE RECURSE ${dst}) message(STATUS "Before Installing") file(INSTALL FILES ${src}/ DESTINATION ${dst} TYPE DIRECTORY) file(INSTALL FILES ${src}/ DESTINATION ${dst} TYPE DIRECTORY) +file(INSTALL FILES ${src}/ DESTINATION ${dst} TYPE DIRECTORY MESSAGE_NEVER) +file(INSTALL FILES ${src}/ DESTINATION ${dst} TYPE DIRECTORY MESSAGE_LAZY) +file(INSTALL FILES ${src}/ DESTINATION ${dst} TYPE DIRECTORY MESSAGE_ALWAYS) message(STATUS "After Installing") diff --git a/Tests/RunCMake/file/INSTALL-MESSAGE-bad-result.txt b/Tests/RunCMake/file/INSTALL-MESSAGE-bad-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/INSTALL-MESSAGE-bad-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/INSTALL-MESSAGE-bad-stderr.txt b/Tests/RunCMake/file/INSTALL-MESSAGE-bad-stderr.txt new file mode 100644 index 0000000..557b817 --- /dev/null +++ b/Tests/RunCMake/file/INSTALL-MESSAGE-bad-stderr.txt @@ -0,0 +1,32 @@ +CMake Error at INSTALL-MESSAGE-bad.cmake:1 \(file\): + file INSTALL options MESSAGE_ALWAYS, MESSAGE_LAZY, and MESSAGE_NEVER are + mutually exclusive. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at INSTALL-MESSAGE-bad.cmake:2 \(file\): + file INSTALL options MESSAGE_ALWAYS, MESSAGE_LAZY, and MESSAGE_NEVER are + mutually exclusive. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at INSTALL-MESSAGE-bad.cmake:3 \(file\): + file INSTALL options MESSAGE_ALWAYS, MESSAGE_LAZY, and MESSAGE_NEVER are + mutually exclusive. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at INSTALL-MESSAGE-bad.cmake:4 \(file\): + file option MESSAGE_ALWAYS may not appear after PATTERN or REGEX. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at INSTALL-MESSAGE-bad.cmake:5 \(file\): + file option MESSAGE_LAZY may not appear after PATTERN or REGEX. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at INSTALL-MESSAGE-bad.cmake:6 \(file\): + file option MESSAGE_NEVER may not appear after PATTERN or REGEX. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/file/INSTALL-MESSAGE-bad.cmake b/Tests/RunCMake/file/INSTALL-MESSAGE-bad.cmake new file mode 100644 index 0000000..f878c69 --- /dev/null +++ b/Tests/RunCMake/file/INSTALL-MESSAGE-bad.cmake @@ -0,0 +1,6 @@ +file(INSTALL DESTINATION dir MESSAGE_ALWAYS MESSAGE_LAZY) +file(INSTALL DESTINATION dir MESSAGE_ALWAYS MESSAGE_NEVER) +file(INSTALL DESTINATION dir MESSAGE_LAZY MESSAGE_NEVER) +file(INSTALL DESTINATION dir PATTERN *.txt MESSAGE_ALWAYS) +file(INSTALL DESTINATION dir PATTERN *.txt MESSAGE_LAZY) +file(INSTALL DESTINATION dir PATTERN *.txt MESSAGE_NEVER) diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index 09e3629..bf14263 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -1,4 +1,5 @@ include(RunCMake) run_cmake(INSTALL-DIRECTORY) +run_cmake(INSTALL-MESSAGE-bad) run_cmake(FileOpenFailRead) -- cgit v0.12 From ec7cf7ea1311adaf6eb8dd1ab5c2aa8e3745339e Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 24 Jun 2014 10:45:07 -0400 Subject: install: Thread message level setting through internal API Create a cmInstallGenerator::MessageLevel enumeration for future use in specifying install message verbosity. Thread values of the type through constructors and save the value as a member of cmInstallGenerator. Use only a "MessageDefault" value for now. --- Source/cmInstallCommand.cxx | 15 ++++++++++++++- Source/cmInstallDirectoryGenerator.cxx | 4 +++- Source/cmInstallDirectoryGenerator.h | 1 + Source/cmInstallExportGenerator.cxx | 3 ++- Source/cmInstallExportGenerator.h | 1 + Source/cmInstallFilesCommand.cxx | 4 +++- Source/cmInstallFilesGenerator.cxx | 3 ++- Source/cmInstallFilesGenerator.h | 1 + Source/cmInstallGenerator.cxx | 6 ++++-- Source/cmInstallGenerator.h | 9 ++++++++- Source/cmInstallProgramsCommand.cxx | 4 +++- Source/cmInstallScriptGenerator.cxx | 2 +- Source/cmInstallTargetGenerator.cxx | 6 ++++-- Source/cmInstallTargetGenerator.h | 1 + Source/cmLocalGenerator.cxx | 1 + 15 files changed, 49 insertions(+), 12 deletions(-) diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 0041122..d0eea35 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -25,9 +25,12 @@ static cmInstallTargetGenerator* CreateInstallTargetGenerator(cmTarget& target, const cmInstallCommandArguments& args, bool impLib, bool forceOpt = false) { + cmInstallGenerator::MessageLevel message = + cmInstallGenerator::MessageDefault; return new cmInstallTargetGenerator(target, args.GetDestination().c_str(), impLib, args.GetPermissions().c_str(), args.GetConfigurations(), args.GetComponent().c_str(), + message, args.GetOptional() || forceOpt); } @@ -36,10 +39,13 @@ static cmInstallFilesGenerator* CreateInstallFilesGenerator( const std::vector& absFiles, const cmInstallCommandArguments& args, bool programs) { + cmInstallGenerator::MessageLevel message = + cmInstallGenerator::MessageDefault; return new cmInstallFilesGenerator(mf, absFiles, args.GetDestination().c_str(), programs, args.GetPermissions().c_str(), args.GetConfigurations(), args.GetComponent().c_str(), + message, args.GetRename().c_str(), args.GetOptional()); } @@ -1208,6 +1214,9 @@ cmInstallCommand::HandleDirectoryMode(std::vector const& args) return false; } + cmInstallGenerator::MessageLevel message = + cmInstallGenerator::MessageDefault; + // Create the directory install generator. this->Makefile->AddInstallGenerator( new cmInstallDirectoryGenerator(dirs, destination, @@ -1215,6 +1224,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector const& args) permissions_dir.c_str(), configurations, component.c_str(), + message, literal_args.c_str(), optional)); @@ -1333,13 +1343,16 @@ bool cmInstallCommand::HandleExportMode(std::vector const& args) } } + cmInstallGenerator::MessageLevel message = + cmInstallGenerator::MessageDefault; + // Create the export install generator. cmInstallExportGenerator* exportGenerator = new cmInstallExportGenerator( exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(), ica.GetConfigurations(), - ica.GetComponent().c_str(), fname.c_str(), + ica.GetComponent().c_str(), message, fname.c_str(), name_space.GetCString(), exportOld.IsEnabled(), this->Makefile); this->Makefile->AddInstallGenerator(exportGenerator); diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx index ddf7d08..8c13bab 100644 --- a/Source/cmInstallDirectoryGenerator.cxx +++ b/Source/cmInstallDirectoryGenerator.cxx @@ -21,9 +21,11 @@ cmInstallDirectoryGenerator const char* dir_permissions, std::vector const& configurations, const char* component, + MessageLevel message, const char* literal_args, bool optional): - cmInstallGenerator(dest, configurations, component), Directories(dirs), + cmInstallGenerator(dest, configurations, component, message), + Directories(dirs), FilePermissions(file_permissions), DirPermissions(dir_permissions), LiteralArguments(literal_args), Optional(optional) { diff --git a/Source/cmInstallDirectoryGenerator.h b/Source/cmInstallDirectoryGenerator.h index d76ef3c..165ab91 100644 --- a/Source/cmInstallDirectoryGenerator.h +++ b/Source/cmInstallDirectoryGenerator.h @@ -26,6 +26,7 @@ public: const char* dir_permissions, std::vector const& configurations, const char* component, + MessageLevel message, const char* literal_args, bool optional = false); virtual ~cmInstallDirectoryGenerator(); diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 9a17052..ddfd6c5 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -32,10 +32,11 @@ cmInstallExportGenerator::cmInstallExportGenerator( const char* file_permissions, std::vector const& configurations, const char* component, + MessageLevel message, const char* filename, const char* name_space, bool exportOld, cmMakefile* mf) - :cmInstallGenerator(destination, configurations, component) + :cmInstallGenerator(destination, configurations, component, message) ,ExportSet(exportSet) ,FilePermissions(file_permissions) ,FileName(filename) diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h index 37b5593..eb8c28b 100644 --- a/Source/cmInstallExportGenerator.h +++ b/Source/cmInstallExportGenerator.h @@ -30,6 +30,7 @@ public: const char* dest, const char* file_permissions, const std::vector& configurations, const char* component, + MessageLevel message, const char* filename, const char* name_space, bool exportOld, cmMakefile* mf); ~cmInstallExportGenerator(); diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index 7eabbef..1d648c9 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -132,11 +132,13 @@ void cmInstallFilesCommand::CreateInstallGenerator() const std::string no_component = this->Makefile->GetSafeDefinition( "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"); std::vector no_configurations; + cmInstallGenerator::MessageLevel message = + cmInstallGenerator::MessageDefault; this->Makefile->AddInstallGenerator( new cmInstallFilesGenerator(this->Makefile, this->Files, destination.c_str(), false, no_permissions, no_configurations, - no_component.c_str(), no_rename)); + no_component.c_str(), message, no_rename)); } diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx index b2be82e..91b102a 100644 --- a/Source/cmInstallFilesGenerator.cxx +++ b/Source/cmInstallFilesGenerator.cxx @@ -23,9 +23,10 @@ cmInstallFilesGenerator const char* file_permissions, std::vector const& configurations, const char* component, + MessageLevel message, const char* rename, bool optional): - cmInstallGenerator(dest, configurations, component), + cmInstallGenerator(dest, configurations, component, message), Makefile(mf), Files(files), Programs(programs), FilePermissions(file_permissions), diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h index 23bf935..0dbd712 100644 --- a/Source/cmInstallFilesGenerator.h +++ b/Source/cmInstallFilesGenerator.h @@ -28,6 +28,7 @@ public: const char* file_permissions, std::vector const& configurations, const char* component, + MessageLevel message, const char* rename, bool optional = false); virtual ~cmInstallFilesGenerator(); diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx index 9370e48..0bc4073 100644 --- a/Source/cmInstallGenerator.cxx +++ b/Source/cmInstallGenerator.cxx @@ -17,10 +17,12 @@ cmInstallGenerator ::cmInstallGenerator(const char* destination, std::vector const& configurations, - const char* component): + const char* component, + MessageLevel message): cmScriptGenerator("CMAKE_INSTALL_CONFIG_NAME", configurations), Destination(destination? destination:""), - Component(component? component:"") + Component(component? component:""), + Message(message) { } diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h index c72e9e9..8e8db40 100644 --- a/Source/cmInstallGenerator.h +++ b/Source/cmInstallGenerator.h @@ -24,9 +24,15 @@ class cmLocalGenerator; class cmInstallGenerator: public cmScriptGenerator { public: + enum MessageLevel + { + MessageDefault, + }; + cmInstallGenerator(const char* destination, std::vector const& configurations, - const char* component); + const char* component, + MessageLevel message); virtual ~cmInstallGenerator(); void AddInstallRule( @@ -58,6 +64,7 @@ protected: // Information shared by most generator types. std::string Destination; std::string Component; + MessageLevel Message; }; #endif diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx index 597f7ee..18d7546 100644 --- a/Source/cmInstallProgramsCommand.cxx +++ b/Source/cmInstallProgramsCommand.cxx @@ -93,11 +93,13 @@ void cmInstallProgramsCommand::FinalPass() std::string no_component = this->Makefile->GetSafeDefinition( "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"); std::vector no_configurations; + cmInstallGenerator::MessageLevel message = + cmInstallGenerator::MessageDefault; this->Makefile->AddInstallGenerator( new cmInstallFilesGenerator(this->Makefile, this->Files, destination.c_str(), true, no_permissions, no_configurations, - no_component.c_str(), no_rename)); + no_component.c_str(), message, no_rename)); } /** diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx index 1ecf021..933aa07 100644 --- a/Source/cmInstallScriptGenerator.cxx +++ b/Source/cmInstallScriptGenerator.cxx @@ -15,7 +15,7 @@ cmInstallScriptGenerator ::cmInstallScriptGenerator(const char* script, bool code, const char* component) : - cmInstallGenerator(0, std::vector(), component), + cmInstallGenerator(0, std::vector(), component, MessageDefault), Script(script), Code(code) { } diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index ec2b518..85df91d 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -24,8 +24,10 @@ cmInstallTargetGenerator ::cmInstallTargetGenerator(cmTarget& t, const char* dest, bool implib, const char* file_permissions, std::vector const& configurations, - const char* component, bool optional): - cmInstallGenerator(dest, configurations, component), Target(&t), + const char* component, + MessageLevel message, + bool optional): + cmInstallGenerator(dest, configurations, component, message), Target(&t), ImportLibrary(implib), FilePermissions(file_permissions), Optional(optional) { this->ActionsPerConfig = true; diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index d718dbc..7e5cc71 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -27,6 +27,7 @@ public: const char* file_permissions, std::vector const& configurations, const char* component, + MessageLevel message, bool optional ); virtual ~cmInstallTargetGenerator(); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 2243834..ec89bde 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -3004,6 +3004,7 @@ public: cmInstallTargetGeneratorLocal(cmTarget& t, const char* dest, bool implib): cmInstallTargetGenerator( t, dest, implib, "", std::vector(), "Unspecified", + MessageDefault, false) {} }; -- cgit v0.12 From c9568de52c4e11c04a9f758ea9ecc1e72ea7cbfb Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 24 Jun 2014 11:18:43 -0400 Subject: install: Add CMAKE_INSTALL_MESSAGE variable (#13761) Create a variable to allow users to control which installation messages are printed. In particular, provide a "LAZY" setting that prints "Installing" messages but not "Up-to-date" messages. This is desirable for incremental re-installations. Suggested-by: J Decker --- Help/command/file.rst | 3 ++- Help/command/install.rst | 4 +++ Help/manual/cmake-variables.7.rst | 1 + Help/release/dev/install-messages.rst | 5 ++++ Help/variable/CMAKE_INSTALL_MESSAGE.rst | 30 ++++++++++++++++++++++ Source/cmInstallCommand.cxx | 8 +++--- Source/cmInstallFilesCommand.cxx | 2 +- Source/cmInstallGenerator.cxx | 28 ++++++++++++++++++++ Source/cmInstallGenerator.h | 7 +++++ Source/cmInstallProgramsCommand.cxx | 2 +- Source/cmLocalGenerator.cxx | 2 +- .../install/DIRECTORY-message-lazy-check.cmake | 24 +++++++++++++++++ .../RunCMake/install/DIRECTORY-message-lazy.cmake | 3 +++ Tests/RunCMake/install/DIRECTORY-message.cmake | 1 + Tests/RunCMake/install/RunCMakeTest.cmake | 1 + 15 files changed, 113 insertions(+), 8 deletions(-) create mode 100644 Help/release/dev/install-messages.rst create mode 100644 Help/variable/CMAKE_INSTALL_MESSAGE.rst create mode 100644 Tests/RunCMake/install/DIRECTORY-message-lazy-check.cmake create mode 100644 Tests/RunCMake/install/DIRECTORY-message-lazy.cmake diff --git a/Help/command/file.rst b/Help/command/file.rst index 869350a..58e3a26 100644 --- a/Help/command/file.rst +++ b/Help/command/file.rst @@ -298,6 +298,7 @@ See the :command:`install(DIRECTORY)` command for documentation of permissions, ``PATTERN``, ``REGEX``, and ``EXCLUDE`` options. The ``INSTALL`` signature differs slightly from ``COPY``: it prints -status messages, and ``NO_SOURCE_PERMISSIONS`` is default. +status messages (subject to the :variable:`CMAKE_INSTALL_MESSAGE` variable), +and ``NO_SOURCE_PERMISSIONS`` is default. Installation scripts generated by the :command:`install` command use this signature (with some undocumented options for internal use). diff --git a/Help/command/install.rst b/Help/command/install.rst index 462a8a9..00f722b 100644 --- a/Help/command/install.rst +++ b/Help/command/install.rst @@ -59,6 +59,10 @@ signatures that specify them. The common options are: Specify that it is not an error if the file to be installed does not exist. +Command signatures that install files may print messages during +installation. Use the :variable:`CMAKE_INSTALL_MESSAGE` variable +to control which messages are printed. + Installing Targets ^^^^^^^^^^^^^^^^^^ diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index df434c5..0e4c4a0 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -128,6 +128,7 @@ Variables that Change Behavior /variable/CMAKE_INCLUDE_DIRECTORIES_BEFORE /variable/CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE /variable/CMAKE_INSTALL_DEFAULT_COMPONENT_NAME + /variable/CMAKE_INSTALL_MESSAGE /variable/CMAKE_INSTALL_PREFIX /variable/CMAKE_LIBRARY_PATH /variable/CMAKE_MFC_FLAG diff --git a/Help/release/dev/install-messages.rst b/Help/release/dev/install-messages.rst new file mode 100644 index 0000000..c8aa456 --- /dev/null +++ b/Help/release/dev/install-messages.rst @@ -0,0 +1,5 @@ +install-messages +---------------- + +* The :variable:`CMAKE_INSTALL_MESSAGE` variable was introduced to + optionally reduce output installation. diff --git a/Help/variable/CMAKE_INSTALL_MESSAGE.rst b/Help/variable/CMAKE_INSTALL_MESSAGE.rst new file mode 100644 index 0000000..304df26 --- /dev/null +++ b/Help/variable/CMAKE_INSTALL_MESSAGE.rst @@ -0,0 +1,30 @@ +CMAKE_INSTALL_MESSAGE +--------------------- + +Specify verbosity of installation script code generated by the +:command:`install` command (using the :command:`file(INSTALL)` command). +For paths that are newly installed or updated, installation +may print lines like:: + + -- Installing: /some/destination/path + +For paths that are already up to date, installation may print +lines like:: + + -- Up-to-date: /some/destination/path + +The ``CMAKE_INSTALL_MESSAGE`` variable may be set to control +which messages are printed: + +``ALWAYS`` + Print both ``Installing`` and ``Up-to-date`` messages. + +``LAZY`` + Print ``Installing`` but not ``Up-to-date`` messages. + +``NEVER`` + Print neither ``Installing`` nor ``Up-to-date`` messages. + +Other values have undefined behavior and may not be diagnosed. + +If this variable is not set, the default behavior is ``ALWAYS``. diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index d0eea35..f4af460 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -26,7 +26,7 @@ static cmInstallTargetGenerator* CreateInstallTargetGenerator(cmTarget& target, const cmInstallCommandArguments& args, bool impLib, bool forceOpt = false) { cmInstallGenerator::MessageLevel message = - cmInstallGenerator::MessageDefault; + cmInstallGenerator::SelectMessageLevel(target.GetMakefile()); return new cmInstallTargetGenerator(target, args.GetDestination().c_str(), impLib, args.GetPermissions().c_str(), args.GetConfigurations(), args.GetComponent().c_str(), @@ -40,7 +40,7 @@ static cmInstallFilesGenerator* CreateInstallFilesGenerator( const cmInstallCommandArguments& args, bool programs) { cmInstallGenerator::MessageLevel message = - cmInstallGenerator::MessageDefault; + cmInstallGenerator::SelectMessageLevel(mf); return new cmInstallFilesGenerator(mf, absFiles, args.GetDestination().c_str(), programs, args.GetPermissions().c_str(), @@ -1215,7 +1215,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector const& args) } cmInstallGenerator::MessageLevel message = - cmInstallGenerator::MessageDefault; + cmInstallGenerator::SelectMessageLevel(this->Makefile); // Create the directory install generator. this->Makefile->AddInstallGenerator( @@ -1344,7 +1344,7 @@ bool cmInstallCommand::HandleExportMode(std::vector const& args) } cmInstallGenerator::MessageLevel message = - cmInstallGenerator::MessageDefault; + cmInstallGenerator::SelectMessageLevel(this->Makefile); // Create the export install generator. cmInstallExportGenerator* exportGenerator = diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index 1d648c9..f106e1a 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -133,7 +133,7 @@ void cmInstallFilesCommand::CreateInstallGenerator() const "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"); std::vector no_configurations; cmInstallGenerator::MessageLevel message = - cmInstallGenerator::MessageDefault; + cmInstallGenerator::SelectMessageLevel(this->Makefile); this->Makefile->AddInstallGenerator( new cmInstallFilesGenerator(this->Makefile, this->Files, destination.c_str(), false, diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx index 0bc4073..7c6c5ae 100644 --- a/Source/cmInstallGenerator.cxx +++ b/Source/cmInstallGenerator.cxx @@ -11,6 +11,7 @@ ============================================================================*/ #include "cmInstallGenerator.h" +#include "cmMakefile.h" #include "cmSystemTools.h" //---------------------------------------------------------------------------- @@ -98,6 +99,13 @@ void cmInstallGenerator { os << " OPTIONAL"; } + switch(this->Message) + { + case MessageDefault: break; + case MessageAlways: os << " MESSAGE_ALWAYS"; break; + case MessageLazy: os << " MESSAGE_LAZY"; break; + case MessageNever: os << " MESSAGE_NEVER"; break; + } if(permissions_file && *permissions_file) { os << " PERMISSIONS" << permissions_file; @@ -182,3 +190,23 @@ std::string cmInstallGenerator::GetInstallDestination() const result += this->Destination; return result; } + +//---------------------------------------------------------------------------- +cmInstallGenerator::MessageLevel +cmInstallGenerator::SelectMessageLevel(cmMakefile* mf) +{ + std::string m = mf->GetSafeDefinition("CMAKE_INSTALL_MESSAGE"); + if(m == "ALWAYS") + { + return MessageAlways; + } + if(m == "LAZY") + { + return MessageLazy; + } + if(m == "NEVER") + { + return MessageNever; + } + return MessageDefault; +} diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h index 8e8db40..e32276f 100644 --- a/Source/cmInstallGenerator.h +++ b/Source/cmInstallGenerator.h @@ -16,6 +16,7 @@ #include "cmScriptGenerator.h" class cmLocalGenerator; +class cmMakefile; /** \class cmInstallGenerator * \brief Support class for generating install scripts. @@ -27,6 +28,9 @@ public: enum MessageLevel { MessageDefault, + MessageAlways, + MessageLazy, + MessageNever }; cmInstallGenerator(const char* destination, @@ -56,6 +60,9 @@ 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); + protected: virtual void GenerateScript(std::ostream& os); diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx index 18d7546..0405769 100644 --- a/Source/cmInstallProgramsCommand.cxx +++ b/Source/cmInstallProgramsCommand.cxx @@ -94,7 +94,7 @@ void cmInstallProgramsCommand::FinalPass() "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"); std::vector no_configurations; cmInstallGenerator::MessageLevel message = - cmInstallGenerator::MessageDefault; + cmInstallGenerator::SelectMessageLevel(this->Makefile); this->Makefile->AddInstallGenerator( new cmInstallFilesGenerator(this->Makefile, this->Files, destination.c_str(), true, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index ec89bde..a1dbaa5 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -3004,7 +3004,7 @@ public: cmInstallTargetGeneratorLocal(cmTarget& t, const char* dest, bool implib): cmInstallTargetGenerator( t, dest, implib, "", std::vector(), "Unspecified", - MessageDefault, + cmInstallGenerator::SelectMessageLevel(t.GetMakefile()), false) {} }; diff --git a/Tests/RunCMake/install/DIRECTORY-message-lazy-check.cmake b/Tests/RunCMake/install/DIRECTORY-message-lazy-check.cmake new file mode 100644 index 0000000..c7e6018 --- /dev/null +++ b/Tests/RunCMake/install/DIRECTORY-message-lazy-check.cmake @@ -0,0 +1,24 @@ +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) +set(expect " +-- Installing: [^\n]*/prefix/dir\r? +-- Installing: [^\n]*/prefix/dir/empty.txt\r? +") +if(NOT out MATCHES "${expect}") + string(REGEX REPLACE "\n" "\n " out " ${out}") + set(RunCMake_TEST_FAILED + "${RunCMake_TEST_FAILED}First install did not say 'Installing' as expected:\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() +execute_process(COMMAND ${CMAKE_COMMAND} -P ${RunCMake_TEST_BINARY_DIR}/cmake_install.cmake + OUTPUT_VARIABLE out ERROR_VARIABLE err) +if(out MATCHES "(Installing|Up-to-date)") + string(REGEX REPLACE "\n" "\n " out " ${out}") + set(RunCMake_TEST_FAILED + "${RunCMake_TEST_FAILED}Second install was not silent as expected:\n${out}") +endif() diff --git a/Tests/RunCMake/install/DIRECTORY-message-lazy.cmake b/Tests/RunCMake/install/DIRECTORY-message-lazy.cmake new file mode 100644 index 0000000..ed43567 --- /dev/null +++ b/Tests/RunCMake/install/DIRECTORY-message-lazy.cmake @@ -0,0 +1,3 @@ +set(CMAKE_INSTALL_MESSAGE "LAZY") +set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/prefix") +install(DIRECTORY dir/ DESTINATION dir) diff --git a/Tests/RunCMake/install/DIRECTORY-message.cmake b/Tests/RunCMake/install/DIRECTORY-message.cmake index 548e0df..913ed15 100644 --- a/Tests/RunCMake/install/DIRECTORY-message.cmake +++ b/Tests/RunCMake/install/DIRECTORY-message.cmake @@ -1,2 +1,3 @@ +set(CMAKE_INSTALL_MESSAGE "ALWAYS") set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/prefix") install(DIRECTORY dir/ DESTINATION dir) diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake index 39d2c1d..8016801 100644 --- a/Tests/RunCMake/install/RunCMakeTest.cmake +++ b/Tests/RunCMake/install/RunCMakeTest.cmake @@ -1,5 +1,6 @@ include(RunCMake) run_cmake(DIRECTORY-message) +run_cmake(DIRECTORY-message-lazy) run_cmake(SkipInstallRulesWarning) run_cmake(SkipInstallRulesNoWarning1) run_cmake(SkipInstallRulesNoWarning2) -- cgit v0.12 From d19b64d671e9f1e706218bd0acc6a727e7114158 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 24 Jun 2014 11:40:26 -0400 Subject: 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 --- Help/command/install.rst | 4 +++- Help/release/dev/install-messages.rst | 3 +++ Source/cmInstallCommand.cxx | 18 +++++++++++++++++- Source/cmInstallGenerator.cxx | 6 +++++- Source/cmInstallGenerator.h | 4 ++-- .../install/DIRECTORY-MESSAGE_NEVER-check.cmake | 13 +++++++++++++ Tests/RunCMake/install/DIRECTORY-MESSAGE_NEVER.cmake | 3 +++ .../install/DIRECTORY-PATTERN-MESSAGE_NEVER-result.txt | 1 + .../install/DIRECTORY-PATTERN-MESSAGE_NEVER-stderr.txt | 4 ++++ .../install/DIRECTORY-PATTERN-MESSAGE_NEVER.cmake | 1 + Tests/RunCMake/install/RunCMakeTest.cmake | 2 ++ 11 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 Tests/RunCMake/install/DIRECTORY-MESSAGE_NEVER-check.cmake create mode 100644 Tests/RunCMake/install/DIRECTORY-MESSAGE_NEVER.cmake create mode 100644 Tests/RunCMake/install/DIRECTORY-PATTERN-MESSAGE_NEVER-result.txt create mode 100644 Tests/RunCMake/install/DIRECTORY-PATTERN-MESSAGE_NEVER-stderr.txt create mode 100644 Tests/RunCMake/install/DIRECTORY-PATTERN-MESSAGE_NEVER.cmake diff --git a/Help/command/install.rst b/Help/command/install.rst index 00f722b..4c52abf 100644 --- a/Help/command/install.rst +++ b/Help/command/install.rst @@ -196,7 +196,7 @@ Installing Directories install(DIRECTORY dirs... DESTINATION [FILE_PERMISSIONS permissions...] [DIRECTORY_PERMISSIONS permissions...] - [USE_SOURCE_PERMISSIONS] [OPTIONAL] + [USE_SOURCE_PERMISSIONS] [OPTIONAL] [MESSAGE_NEVER] [CONFIGURATIONS [Debug|Release|...]] [COMPONENT ] [FILES_MATCHING] [[PATTERN | 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 diff --git a/Help/release/dev/install-messages.rst b/Help/release/dev/install-messages.rst index c8aa456..e023ef7 100644 --- a/Help/release/dev/install-messages.rst +++ b/Help/release/dev/install-messages.rst @@ -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. diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index f4af460..ec500d9 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -917,6 +917,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector const& args) Doing doing = DoingDirs; bool in_match_mode = false; bool optional = false; + bool message_never = false; std::vector dirs; const char* destination = 0; std::string permissions_file; @@ -955,6 +956,21 @@ cmInstallCommand::HandleDirectoryMode(std::vector 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 const& args) } cmInstallGenerator::MessageLevel message = - cmInstallGenerator::SelectMessageLevel(this->Makefile); + cmInstallGenerator::SelectMessageLevel(this->Makefile, message_never); // Create the directory install generator. this->Makefile->AddInstallGenerator( diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx index 7c6c5ae..b261cbf 100644 --- a/Source/cmInstallGenerator.cxx +++ b/Source/cmInstallGenerator.cxx @@ -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") { diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h index e32276f..38aac91 100644 --- a/Source/cmInstallGenerator.h +++ b/Source/cmInstallGenerator.h @@ -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); diff --git a/Tests/RunCMake/install/DIRECTORY-MESSAGE_NEVER-check.cmake b/Tests/RunCMake/install/DIRECTORY-MESSAGE_NEVER-check.cmake new file mode 100644 index 0000000..2c716e1 --- /dev/null +++ b/Tests/RunCMake/install/DIRECTORY-MESSAGE_NEVER-check.cmake @@ -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() diff --git a/Tests/RunCMake/install/DIRECTORY-MESSAGE_NEVER.cmake b/Tests/RunCMake/install/DIRECTORY-MESSAGE_NEVER.cmake new file mode 100644 index 0000000..eefb837 --- /dev/null +++ b/Tests/RunCMake/install/DIRECTORY-MESSAGE_NEVER.cmake @@ -0,0 +1,3 @@ +set(CMAKE_INSTALL_MESSAGE "ALWAYS") +set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/prefix") +install(DIRECTORY dir/ DESTINATION dir MESSAGE_NEVER) diff --git a/Tests/RunCMake/install/DIRECTORY-PATTERN-MESSAGE_NEVER-result.txt b/Tests/RunCMake/install/DIRECTORY-PATTERN-MESSAGE_NEVER-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/install/DIRECTORY-PATTERN-MESSAGE_NEVER-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/install/DIRECTORY-PATTERN-MESSAGE_NEVER-stderr.txt b/Tests/RunCMake/install/DIRECTORY-PATTERN-MESSAGE_NEVER-stderr.txt new file mode 100644 index 0000000..166ba6f --- /dev/null +++ b/Tests/RunCMake/install/DIRECTORY-PATTERN-MESSAGE_NEVER-stderr.txt @@ -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\) diff --git a/Tests/RunCMake/install/DIRECTORY-PATTERN-MESSAGE_NEVER.cmake b/Tests/RunCMake/install/DIRECTORY-PATTERN-MESSAGE_NEVER.cmake new file mode 100644 index 0000000..de844f7 --- /dev/null +++ b/Tests/RunCMake/install/DIRECTORY-PATTERN-MESSAGE_NEVER.cmake @@ -0,0 +1 @@ +install(DIRECTORY src DESTINATION src PATTERN *.txt MESSAGE_NEVER) diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake index 8016801..53b91f3 100644 --- a/Tests/RunCMake/install/RunCMakeTest.cmake +++ b/Tests/RunCMake/install/RunCMakeTest.cmake @@ -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) -- cgit v0.12