diff options
author | Brad King <brad.king@kitware.com> | 2014-06-27 13:42:42 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2014-06-27 13:42:42 (GMT) |
commit | 3138da6e675102af8bd81e8715abc7a57806377f (patch) | |
tree | cd36442a3edadf144a5b338bef3c3fa3144d3658 /Source | |
parent | feb44093bc1a5b503ef26fb633a58baeec144d0a (diff) | |
parent | d19b64d671e9f1e706218bd0acc6a727e7114158 (diff) | |
download | CMake-3138da6e675102af8bd81e8715abc7a57806377f.zip CMake-3138da6e675102af8bd81e8715abc7a57806377f.tar.gz CMake-3138da6e675102af8bd81e8715abc7a57806377f.tar.bz2 |
Merge topic 'install-messages'
d19b64d6 install(DIRECTORY): Add MESSAGE_NEVER option to avoid output (#13761)
c9568de5 install: Add CMAKE_INSTALL_MESSAGE variable (#13761)
ec7cf7ea install: Thread message level setting through internal API
abebcd23 file(INSTALL): Add undocumented options to control output verbosity
464567a5 file(INSTALL): Report existing DIRECTORY as Up-to-date
f701b0b7 file(INSTALL): Do not pre-create DESTINATION for DIRECTORY
f0a01962 cmInstallTargetGenerator: Drop default constructor arguments
67815894 Help: Add install() command document section headers
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmFileCommand.cxx | 87 | ||||
-rw-r--r-- | Source/cmInstallCommand.cxx | 31 | ||||
-rw-r--r-- | Source/cmInstallDirectoryGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmInstallDirectoryGenerator.h | 1 | ||||
-rw-r--r-- | Source/cmInstallExportGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmInstallExportGenerator.h | 1 | ||||
-rw-r--r-- | Source/cmInstallFilesCommand.cxx | 4 | ||||
-rw-r--r-- | Source/cmInstallFilesGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmInstallFilesGenerator.h | 1 | ||||
-rw-r--r-- | Source/cmInstallGenerator.cxx | 38 | ||||
-rw-r--r-- | Source/cmInstallGenerator.h | 16 | ||||
-rw-r--r-- | Source/cmInstallProgramsCommand.cxx | 4 | ||||
-rw-r--r-- | Source/cmInstallScriptGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmInstallTargetGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/cmInstallTargetGenerator.h | 10 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 23 |
16 files changed, 199 insertions, 35 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 655f3ba..61c6eb3 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)) @@ -1704,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. @@ -1725,6 +1729,9 @@ struct cmFileInstaller: public cmFileCopier protected: cmInstallType InstallType; bool Optional; + bool MessageAlways; + bool MessageLazy; + bool MessageNever; int DestDirLength; std::string Rename; @@ -1740,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. @@ -1828,6 +1838,16 @@ bool cmFileInstaller::Parse(std::vector<std::string> 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; } @@ -1879,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) @@ -2057,23 +2113,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; } diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 0041122..ec500d9 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::SelectMessageLevel(target.GetMakefile()); 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<std::string>& absFiles, const cmInstallCommandArguments& args, bool programs) { + cmInstallGenerator::MessageLevel message = + cmInstallGenerator::SelectMessageLevel(mf); 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()); } @@ -911,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; @@ -949,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. @@ -1208,6 +1230,9 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) return false; } + cmInstallGenerator::MessageLevel message = + cmInstallGenerator::SelectMessageLevel(this->Makefile, message_never); + // Create the directory install generator. this->Makefile->AddInstallGenerator( new cmInstallDirectoryGenerator(dirs, destination, @@ -1215,6 +1240,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) permissions_dir.c_str(), configurations, component.c_str(), + message, literal_args.c_str(), optional)); @@ -1333,13 +1359,16 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args) } } + cmInstallGenerator::MessageLevel message = + cmInstallGenerator::SelectMessageLevel(this->Makefile); + // 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<std::string> 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<std::string> 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<std::string> 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<std::string>& 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..f106e1a 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<std::string> no_configurations; + cmInstallGenerator::MessageLevel message = + cmInstallGenerator::SelectMessageLevel(this->Makefile); 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<std::string> 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<std::string> 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..b261cbf 100644 --- a/Source/cmInstallGenerator.cxx +++ b/Source/cmInstallGenerator.cxx @@ -11,16 +11,19 @@ ============================================================================*/ #include "cmInstallGenerator.h" +#include "cmMakefile.h" #include "cmSystemTools.h" //---------------------------------------------------------------------------- cmInstallGenerator ::cmInstallGenerator(const char* destination, std::vector<std::string> 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) { } @@ -96,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; @@ -180,3 +190,27 @@ std::string cmInstallGenerator::GetInstallDestination() const result += this->Destination; return result; } + +//---------------------------------------------------------------------------- +cmInstallGenerator::MessageLevel +cmInstallGenerator::SelectMessageLevel(cmMakefile* mf, bool never) +{ + if(never) + { + return MessageNever; + } + 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 c72e9e9..38aac91 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. @@ -24,9 +25,18 @@ class cmLocalGenerator; class cmInstallGenerator: public cmScriptGenerator { public: + enum MessageLevel + { + MessageDefault, + MessageAlways, + MessageLazy, + MessageNever + }; + cmInstallGenerator(const char* destination, std::vector<std::string> const& configurations, - const char* component); + const char* component, + MessageLevel message); virtual ~cmInstallGenerator(); void AddInstallRule( @@ -50,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 or 'never'. */ + static MessageLevel SelectMessageLevel(cmMakefile* mf, bool never = false); + protected: virtual void GenerateScript(std::ostream& os); @@ -58,6 +71,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..0405769 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<std::string> no_configurations; + cmInstallGenerator::MessageLevel message = + cmInstallGenerator::SelectMessageLevel(this->Makefile); 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<std::string>(), component), + cmInstallGenerator(0, std::vector<std::string>(), 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<std::string> 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 0f21da7..7e5cc71 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -24,11 +24,11 @@ class cmInstallTargetGenerator: public cmInstallGenerator public: cmInstallTargetGenerator( cmTarget& t, const char* dest, bool implib, - const char* file_permissions = "", - std::vector<std::string> const& configurations - = std::vector<std::string>(), - const char* component = "Unspecified", - bool optional = false + const char* file_permissions, + std::vector<std::string> const& configurations, + const char* component, + MessageLevel message, + bool optional ); virtual ~cmInstallTargetGenerator(); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index abfc3ed..5380d06 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2998,6 +2998,17 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local, } //---------------------------------------------------------------------------- +class cmInstallTargetGeneratorLocal: public cmInstallTargetGenerator +{ +public: + cmInstallTargetGeneratorLocal(cmTarget& t, const char* dest, bool implib): + cmInstallTargetGenerator( + t, dest, implib, "", std::vector<std::string>(), "Unspecified", + cmInstallGenerator::SelectMessageLevel(t.GetMakefile()), + false) {} +}; + +//---------------------------------------------------------------------------- void cmLocalGenerator ::GenerateTargetInstallRules( @@ -3042,7 +3053,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 +3064,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 } |