Merge topic 'MakeDefaultInstallComponentNameConfigurable'

b71e731 -add docs for ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}
7ced073 make default install component name configurable
b6fba35 -strip trailing whitespace
This commit is contained in:
David Cole 2012-05-24 13:37:54 -04:00 committed by CMake Topic Stage
commit 59bdb879e8
9 changed files with 111 additions and 79 deletions

View File

@ -170,6 +170,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

View File

@ -522,6 +522,16 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
false,
"Variables That Change Behavior");
cm->DefineProperty
("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME", cmProperty::VARIABLE,
"Default component used in install() commands.",
"If an install() command is used without the COMPONENT argument, "
"these files will be grouped into a default component. The name of this "
"default install component will be taken from this variable. "
"It defaults to \"Unspecified\". ",
false,
"Variables That Change Behavior");
cm->DefineProperty
("CMAKE_FIND_LIBRARY_PREFIXES", cmProperty::VARIABLE,
"Prefixes to prepend when looking for libraries.",

View File

@ -55,6 +55,13 @@ bool cmInstallCommand::InitialPass(std::vector<std::string> 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<std::string> const& args,
//----------------------------------------------------------------------------
bool cmInstallCommand::HandleScriptMode(std::vector<std::string> 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<std::string> const& args)
// ARCHIVE, RUNTIME etc. (see above)
// These generic args also contain the targets and the export stuff
std::vector<std::string> 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<std::string> 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<std::string> 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<std::string> const& args)
std::string permissions_file;
std::string permissions_dir;
std::vector<std::string> 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<std::string> const& args)
bool cmInstallCommand::HandleExportMode(std::vector<std::string> 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);

View File

@ -341,6 +341,8 @@ private:
const std::vector<std::string>& relFiles,
std::vector<std::string>& absFiles);
bool CheckCMP0006(bool& failure);
std::string DefaultComponentName;
};

View File

@ -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
{

View File

@ -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<std::string>* args,
@ -45,6 +45,7 @@ class cmInstallCommandArguments
cmCommandArgumentsHelper Parser;
cmCommandArgumentGroup ArgumentGroup;
private:
cmInstallCommandArguments(); // disabled
cmCAString Destination;
cmCAString Component;
cmCAString Rename;

View File

@ -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<std::string> 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));
}

View File

@ -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<std::string> 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));
}
/**

View File

@ -58,7 +58,8 @@ bool cmInstallTargetsCommand
}
this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
->AddInstallComponent("Unspecified");
->AddInstallComponent(this->Makefile->GetSafeDefinition(
"CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));
return true;
}