From 7ced0732e875ab7cf4797ef33bd4b897bc41eb53 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sun, 13 May 2012 15:44:37 +0200 Subject: [PATCH] make default install component name configurable Until now an unnamed component was always named "Unspecified". Now this name is taken from the new cmake variable CMAKE_INSTALL_DEFAULT_COMPONENT_NAME, which is initialized to "Unspecified". But it can now be set to something project-specific, per directory Alex --- Modules/CMakeGenericSystem.cmake | 4 ++++ Source/cmInstallCommand.cxx | 33 +++++++++++++++++----------- Source/cmInstallCommand.h | 2 ++ Source/cmInstallCommandArguments.cxx | 7 ++++-- Source/cmInstallCommandArguments.h | 3 ++- Source/cmInstallFilesCommand.cxx | 8 ++++--- Source/cmInstallProgramsCommand.cxx | 8 ++++--- Source/cmInstallTargetsCommand.cxx | 3 ++- 8 files changed, 45 insertions(+), 23 deletions(-) diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake index 45d1fbff1..6c61d3d78 100644 --- a/Modules/CMakeGenericSystem.cmake +++ b/Modules/CMakeGenericSystem.cmake @@ -168,6 +168,10 @@ ELSE(CMAKE_HOST_UNIX) SET(CMAKE_GENERIC_PROGRAM_FILES) ENDIF(CMAKE_HOST_UNIX) +# Set a variable which will be used as component name in install() commands +# where no COMPONENT has been given: +SET(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "Unspecified") + MARK_AS_ADVANCED( CMAKE_SKIP_RPATH CMAKE_SKIP_INSTALL_RPATH diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index d8522ee1e..401673460 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -55,6 +55,13 @@ bool cmInstallCommand::InitialPass(std::vector const& args, this->Makefile->GetLocalGenerator() ->GetGlobalGenerator()->EnableInstallTarget(); + this->DefaultComponentName = this->Makefile->GetSafeDefinition( + "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"); + if (this->DefaultComponentName.empty()) + { + this->DefaultComponentName = "Unspecified"; + } + // Switch among the command modes. if(args[0] == "SCRIPT") { @@ -95,7 +102,7 @@ bool cmInstallCommand::InitialPass(std::vector const& args, //---------------------------------------------------------------------------- bool cmInstallCommand::HandleScriptMode(std::vector const& args) { - std::string component("Unspecified"); + std::string component = this->DefaultComponentName; int componentCount = 0; bool doing_script = false; bool doing_code = false; @@ -222,7 +229,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) // ARCHIVE, RUNTIME etc. (see above) // These generic args also contain the targets and the export stuff std::vector unknownArgs; - cmInstallCommandArguments genericArgs; + cmInstallCommandArguments genericArgs(this->DefaultComponentName); cmCAStringVector targetList(&genericArgs.Parser, "TARGETS"); cmCAString exports(&genericArgs.Parser,"EXPORT", &genericArgs.ArgumentGroup); targetList.Follows(0); @@ -230,14 +237,14 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) genericArgs.Parse(&genericArgVector.GetVector(), &unknownArgs); bool success = genericArgs.Finalize(); - cmInstallCommandArguments archiveArgs; - cmInstallCommandArguments libraryArgs; - cmInstallCommandArguments runtimeArgs; - cmInstallCommandArguments frameworkArgs; - cmInstallCommandArguments bundleArgs; - cmInstallCommandArguments privateHeaderArgs; - cmInstallCommandArguments publicHeaderArgs; - cmInstallCommandArguments resourceArgs; + cmInstallCommandArguments archiveArgs(this->DefaultComponentName); + cmInstallCommandArguments libraryArgs(this->DefaultComponentName); + cmInstallCommandArguments runtimeArgs(this->DefaultComponentName); + cmInstallCommandArguments frameworkArgs(this->DefaultComponentName); + cmInstallCommandArguments bundleArgs(this->DefaultComponentName); + cmInstallCommandArguments privateHeaderArgs(this->DefaultComponentName); + cmInstallCommandArguments publicHeaderArgs(this->DefaultComponentName); + cmInstallCommandArguments resourceArgs(this->DefaultComponentName); // now parse the args for specific parts of the target (e.g. LIBRARY, // RUNTIME, ARCHIVE etc. @@ -788,7 +795,7 @@ bool cmInstallCommand::HandleFilesMode(std::vector const& args) { // This is the FILES mode. bool programs = (args[0] == "PROGRAMS"); - cmInstallCommandArguments ica; + cmInstallCommandArguments ica(this->DefaultComponentName); cmCAStringVector files(&ica.Parser, programs ? "PROGRAMS" : "FILES"); files.Follows(0); ica.ArgumentGroup.Follows(&files); @@ -865,7 +872,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector const& args) std::string permissions_file; std::string permissions_dir; std::vector configurations; - std::string component = "Unspecified"; + std::string component = this->DefaultComponentName; std::string literal_args; for(unsigned int i=1; i < args.size(); ++i) { @@ -1179,7 +1186,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector const& args) bool cmInstallCommand::HandleExportMode(std::vector const& args) { // This is the EXPORT mode. - cmInstallCommandArguments ica; + cmInstallCommandArguments ica(this->DefaultComponentName); cmCAString exp(&ica.Parser, "EXPORT"); cmCAString name_space(&ica.Parser, "NAMESPACE", &ica.ArgumentGroup); cmCAString filename(&ica.Parser, "FILE", &ica.ArgumentGroup); diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h index ee2252380..bf9fd9ed3 100644 --- a/Source/cmInstallCommand.h +++ b/Source/cmInstallCommand.h @@ -341,6 +341,8 @@ private: const std::vector& relFiles, std::vector& absFiles); bool CheckCMP0006(bool& failure); + + std::string DefaultComponentName; }; diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx index f50859431..0ba21c7ad 100644 --- a/Source/cmInstallCommandArguments.cxx +++ b/Source/cmInstallCommandArguments.cxx @@ -23,7 +23,8 @@ const char* cmInstallCommandArguments::PermissionsTable[] = const std::string cmInstallCommandArguments::EmptyString; -cmInstallCommandArguments::cmInstallCommandArguments() +cmInstallCommandArguments::cmInstallCommandArguments( + const std::string& defaultComponent) :Parser() ,ArgumentGroup() ,Destination (&Parser, "DESTINATION" , &ArgumentGroup) @@ -35,7 +36,9 @@ cmInstallCommandArguments::cmInstallCommandArguments() ,NamelinkOnly (&Parser, "NAMELINK_ONLY" , &ArgumentGroup) ,NamelinkSkip (&Parser, "NAMELINK_SKIP" , &ArgumentGroup) ,GenericArguments(0) -{} +{ + this->Component.SetDefaultString(defaultComponent.c_str()); +} const std::string& cmInstallCommandArguments::GetDestination() const { diff --git a/Source/cmInstallCommandArguments.h b/Source/cmInstallCommandArguments.h index 53f13c0cd..321454a59 100644 --- a/Source/cmInstallCommandArguments.h +++ b/Source/cmInstallCommandArguments.h @@ -19,7 +19,7 @@ class cmInstallCommandArguments { public: - cmInstallCommandArguments(); + cmInstallCommandArguments(const std::string& defaultComponent); void SetGenericArguments(cmInstallCommandArguments* args) {this->GenericArguments = args;} void Parse(const std::vector* args, @@ -45,6 +45,7 @@ class cmInstallCommandArguments cmCommandArgumentsHelper Parser; cmCommandArgumentGroup ArgumentGroup; private: + cmInstallCommandArguments(); // disabled cmCAString Destination; cmCAString Component; cmCAString Rename; diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index 85400a1a0..cc62c4bac 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -55,7 +55,8 @@ bool cmInstallFilesCommand } this->Makefile->GetLocalGenerator()->GetGlobalGenerator() - ->AddInstallComponent("Unspecified"); + ->AddInstallComponent(this->Makefile->GetSafeDefinition( + "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME")); return true; } @@ -128,13 +129,14 @@ void cmInstallFilesCommand::CreateInstallGenerator() const // Use a file install generator. const char* no_permissions = ""; const char* no_rename = ""; - const char* no_component = "Unspecified"; + std::string no_component = this->Makefile->GetSafeDefinition( + "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"); std::vector no_configurations; this->Makefile->AddInstallGenerator( new cmInstallFilesGenerator(this->Files, destination.c_str(), false, no_permissions, no_configurations, - no_component, no_rename)); + no_component.c_str(), no_rename)); } diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx index 61ac74117..3a0a3223b 100644 --- a/Source/cmInstallProgramsCommand.cxx +++ b/Source/cmInstallProgramsCommand.cxx @@ -34,7 +34,8 @@ bool cmInstallProgramsCommand } this->Makefile->GetLocalGenerator()->GetGlobalGenerator() - ->AddInstallComponent("Unspecified"); + ->AddInstallComponent(this->Makefile->GetSafeDefinition( + "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME")); return true; } @@ -89,13 +90,14 @@ void cmInstallProgramsCommand::FinalPass() // Use a file install generator. const char* no_permissions = ""; const char* no_rename = ""; - const char* no_component = "Unspecified"; + std::string no_component = this->Makefile->GetSafeDefinition( + "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"); std::vector no_configurations; this->Makefile->AddInstallGenerator( new cmInstallFilesGenerator(this->Files, destination.c_str(), true, no_permissions, no_configurations, - no_component, no_rename)); + no_component.c_str(), no_rename)); } /** diff --git a/Source/cmInstallTargetsCommand.cxx b/Source/cmInstallTargetsCommand.cxx index 27fc175de..277ccea43 100644 --- a/Source/cmInstallTargetsCommand.cxx +++ b/Source/cmInstallTargetsCommand.cxx @@ -58,7 +58,8 @@ bool cmInstallTargetsCommand } this->Makefile->GetLocalGenerator()->GetGlobalGenerator() - ->AddInstallComponent("Unspecified"); + ->AddInstallComponent(this->Makefile->GetSafeDefinition( + "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME")); return true; }