ENH: Improved INSTALL_FILES and INSTALL_PROGRAMS commands to allow each call to the command in a single directory to specify a different install path.
This commit is contained in:
parent
7d2410097e
commit
3d86ad7237
|
@ -50,14 +50,16 @@ bool cmInstallFilesCommand::InitialPass(std::vector<std::string>& args)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmTargets &tgts = m_Makefile->GetTargets();
|
// Create an INSTALL_FILES target specifically for this path.
|
||||||
|
m_TargetName = "INSTALL_FILES_"+args[0];
|
||||||
|
cmTarget target;
|
||||||
|
target.SetInAll(false);
|
||||||
|
target.SetType(cmTarget::INSTALL_FILES);
|
||||||
|
target.SetInstallPath(args[0].c_str());
|
||||||
|
m_Makefile->GetTargets().insert(cmTargets::value_type(m_TargetName, target));
|
||||||
|
|
||||||
std::vector<std::string>::iterator s = args.begin();
|
std::vector<std::string>::iterator s = args.begin();
|
||||||
if (tgts.find("INSTALL_FILES") != tgts.end())
|
for (++s;s != args.end(); ++s)
|
||||||
{
|
|
||||||
tgts["INSTALL_FILES"].SetInstallPath(args[0].c_str());
|
|
||||||
}
|
|
||||||
++s;
|
|
||||||
for (;s != args.end(); ++s)
|
|
||||||
{
|
{
|
||||||
m_FinalArgs.push_back(*s);
|
m_FinalArgs.push_back(*s);
|
||||||
}
|
}
|
||||||
|
@ -67,14 +69,10 @@ bool cmInstallFilesCommand::InitialPass(std::vector<std::string>& args)
|
||||||
|
|
||||||
void cmInstallFilesCommand::FinalPass()
|
void cmInstallFilesCommand::FinalPass()
|
||||||
{
|
{
|
||||||
cmTargets &tgts = m_Makefile->GetTargets();
|
|
||||||
std::string testf;
|
std::string testf;
|
||||||
std::string ext = m_FinalArgs[0];
|
std::string ext = m_FinalArgs[0];
|
||||||
|
std::vector<std::string>& targetSourceLists =
|
||||||
if (tgts.find("INSTALL_FILES") == tgts.end())
|
m_Makefile->GetTargets()[m_TargetName].GetSourceLists();
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// two different options
|
// two different options
|
||||||
if (m_FinalArgs.size() > 1)
|
if (m_FinalArgs.size() > 1)
|
||||||
|
@ -98,7 +96,7 @@ void cmInstallFilesCommand::FinalPass()
|
||||||
{
|
{
|
||||||
testf = c->GetSourceName() + ext;
|
testf = c->GetSourceName() + ext;
|
||||||
// add to the result
|
// add to the result
|
||||||
tgts["INSTALL_FILES"].GetSourceLists().push_back(testf);
|
targetSourceLists.push_back(testf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if one wasn't found then assume it is a single class
|
// if one wasn't found then assume it is a single class
|
||||||
|
@ -106,7 +104,7 @@ void cmInstallFilesCommand::FinalPass()
|
||||||
{
|
{
|
||||||
testf = temps + ext;
|
testf = temps + ext;
|
||||||
// add to the result
|
// add to the result
|
||||||
tgts["INSTALL_FILES"].GetSourceLists().push_back(testf);
|
targetSourceLists.push_back(testf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,7 +120,7 @@ void cmInstallFilesCommand::FinalPass()
|
||||||
// for each argument, get the files
|
// for each argument, get the files
|
||||||
for (;s != files.end(); ++s)
|
for (;s != files.end(); ++s)
|
||||||
{
|
{
|
||||||
tgts["INSTALL_FILES"].GetSourceLists().push_back(*s);
|
targetSourceLists.push_back(*s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,6 +102,7 @@ public:
|
||||||
cmTypeMacro(cmInstallFilesCommand, cmCommand);
|
cmTypeMacro(cmInstallFilesCommand, cmCommand);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::string m_TargetName;
|
||||||
std::vector<std::string> m_FinalArgs;
|
std::vector<std::string> m_FinalArgs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -50,29 +50,27 @@ bool cmInstallProgramsCommand::InitialPass(std::vector<std::string>& args)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmTargets &tgts = m_Makefile->GetTargets();
|
// Create an INSTALL_PROGRAMS target specifically for this path.
|
||||||
|
m_TargetName = "INSTALL_PROGRAMS_"+args[0];
|
||||||
|
cmTarget target;
|
||||||
|
target.SetInAll(false);
|
||||||
|
target.SetType(cmTarget::INSTALL_PROGRAMS);
|
||||||
|
target.SetInstallPath(args[0].c_str());
|
||||||
|
m_Makefile->GetTargets().insert(cmTargets::value_type(m_TargetName, target));
|
||||||
|
|
||||||
std::vector<std::string>::iterator s = args.begin();
|
std::vector<std::string>::iterator s = args.begin();
|
||||||
if (tgts.find("INSTALL_PROGRAMS") != tgts.end())
|
for (++s;s != args.end(); ++s)
|
||||||
{
|
|
||||||
tgts["INSTALL_PROGRAMS"].SetInstallPath(args[0].c_str());
|
|
||||||
}
|
|
||||||
++s;
|
|
||||||
for (;s != args.end(); ++s)
|
|
||||||
{
|
{
|
||||||
m_FinalArgs.push_back(*s);
|
m_FinalArgs.push_back(*s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmInstallProgramsCommand::FinalPass()
|
void cmInstallProgramsCommand::FinalPass()
|
||||||
{
|
{
|
||||||
cmTargets &tgts = m_Makefile->GetTargets();
|
std::vector<std::string>& targetSourceLists =
|
||||||
|
m_Makefile->GetTargets()[m_TargetName].GetSourceLists();
|
||||||
if (tgts.find("INSTALL_PROGRAMS") == tgts.end())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// two different options
|
// two different options
|
||||||
if (m_FinalArgs.size() > 1)
|
if (m_FinalArgs.size() > 1)
|
||||||
|
@ -85,7 +83,7 @@ void cmInstallProgramsCommand::FinalPass()
|
||||||
std::string temps = *s;
|
std::string temps = *s;
|
||||||
m_Makefile->ExpandVariablesInString(temps);
|
m_Makefile->ExpandVariablesInString(temps);
|
||||||
// add to the result
|
// add to the result
|
||||||
tgts["INSTALL_PROGRAMS"].GetSourceLists().push_back(temps);
|
targetSourceLists.push_back(temps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // reg exp list
|
else // reg exp list
|
||||||
|
@ -98,7 +96,7 @@ void cmInstallProgramsCommand::FinalPass()
|
||||||
// for each argument, get the programs
|
// for each argument, get the programs
|
||||||
for (;s != programs.end(); ++s)
|
for (;s != programs.end(); ++s)
|
||||||
{
|
{
|
||||||
tgts["INSTALL_PROGRAMS"].GetSourceLists().push_back(*s);
|
targetSourceLists.push_back(*s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,6 +102,7 @@ public:
|
||||||
cmTypeMacro(cmInstallProgramsCommand, cmCommand);
|
cmTypeMacro(cmInstallProgramsCommand, cmCommand);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::string m_TargetName;
|
||||||
std::vector<std::string> m_FinalArgs;
|
std::vector<std::string> m_FinalArgs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -122,13 +122,6 @@ void cmMakefile::AddDefaultCommands()
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
this->AddDefinition("APPLE", "1");
|
this->AddDefinition("APPLE", "1");
|
||||||
#endif
|
#endif
|
||||||
// always creat an empty install targets for files and programs.
|
|
||||||
cmTarget target;
|
|
||||||
target.SetInAll(false);
|
|
||||||
target.SetType(cmTarget::INSTALL_FILES);
|
|
||||||
m_Targets.insert(cmTargets::value_type("INSTALL_FILES", target));
|
|
||||||
target.SetType(cmTarget::INSTALL_PROGRAMS);
|
|
||||||
m_Targets.insert(cmTargets::value_type("INSTALL_PROGRAMS", target));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmMakefile::~cmMakefile()
|
cmMakefile::~cmMakefile()
|
||||||
|
|
Loading…
Reference in New Issue