ENH: Fixed INSTALL_FILES and INSTALL_PROGRAMS commands to not create targets. No targets of type cmTarget::INSTALL_FILES or cmTarget::INSTALL_PROGRAMS are created, so we do not need to check for them everywhere anymore.

This commit is contained in:
Brad King 2007-05-23 15:40:12 -04:00
parent 303b4312b2
commit ba7780a3c4
14 changed files with 64 additions and 95 deletions

View File

@ -94,9 +94,6 @@ void cmExportLibraryDependenciesCommand::FinalPass()
for(cmTargets::iterator l = tgts.begin(); for(cmTargets::iterator l = tgts.begin();
l != tgts.end(); ++l) l != tgts.end(); ++l)
{ {
if ((l->second.GetType() != cmTarget::INSTALL_FILES)
&& (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
{
libDepName = l->first; libDepName = l->first;
libDepName += "_LIB_DEPENDS"; libDepName += "_LIB_DEPENDS";
const char* def = this->Makefile->GetDefinition(libDepName.c_str()); const char* def = this->Makefile->GetDefinition(libDepName.c_str());
@ -120,6 +117,5 @@ void cmExportLibraryDependenciesCommand::FinalPass()
} }
} }
} }
}
return; return;
} }

View File

@ -256,9 +256,6 @@ void cmGlobalVisualStudio6Generator
} }
else else
{ {
if ((l->second.GetType() != cmTarget::INSTALL_FILES)
&& (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
{
bool skip = false; bool skip = false;
// skip ALL_BUILD and RUN_TESTS if they have already been added // skip ALL_BUILD and RUN_TESTS if they have already been added
if(l->first == "ALL_BUILD" ) if(l->first == "ALL_BUILD" )
@ -335,7 +332,6 @@ void cmGlobalVisualStudio6Generator
} }
} }
} }
}
// Write the footer for the DSW file // Write the footer for the DSW file
this->WriteDSWFooter(fout); this->WriteDSWFooter(fout);

View File

@ -134,9 +134,6 @@ void cmGlobalVisualStudio71Generator
} }
else else
{ {
if ((l->second.GetType() != cmTarget::INSTALL_FILES)
&& (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
{
bool skip = false; bool skip = false;
if(l->first == "ALL_BUILD" ) if(l->first == "ALL_BUILD" )
{ {
@ -227,7 +224,6 @@ void cmGlobalVisualStudio71Generator
} }
} }
} }
}
fout << "Global\n"; fout << "Global\n";
this->WriteSolutionConfigurations(fout); this->WriteSolutionConfigurations(fout);
fout << "\tGlobalSection(" << this->ProjectConfigurationSectionName fout << "\tGlobalSection(" << this->ProjectConfigurationSectionName
@ -254,8 +250,7 @@ void cmGlobalVisualStudio71Generator
this->WriteProjectConfigurations(fout, project.c_str(), this->WriteProjectConfigurations(fout, project.c_str(),
true); true);
} }
else if ((l->second.GetType() != cmTarget::INSTALL_FILES) else
&& (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
{ {
bool partOfDefaultBuild = this->IsPartOfDefaultBuild( bool partOfDefaultBuild = this->IsPartOfDefaultBuild(
root->GetMakefile()->GetProjectName(), root->GetMakefile()->GetProjectName(),

View File

@ -341,9 +341,6 @@ void cmGlobalVisualStudio7Generator
} }
else else
{ {
if ((l->second.GetType() != cmTarget::INSTALL_FILES)
&& (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
{
bool skip = false; bool skip = false;
if(l->first == "ALL_BUILD" ) if(l->first == "ALL_BUILD" )
{ {
@ -423,7 +420,6 @@ void cmGlobalVisualStudio7Generator
} }
} }
} }
}
fout << "Global\n" fout << "Global\n"
<< "\tGlobalSection(SolutionConfiguration) = preSolution\n"; << "\tGlobalSection(SolutionConfiguration) = preSolution\n";
@ -476,8 +472,7 @@ void cmGlobalVisualStudio7Generator
depcount++; depcount++;
} }
} }
else if ((l->second.GetType() != cmTarget::INSTALL_FILES) else
&& (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
{ {
const char *dspname = const char *dspname =
l->second.GetProperty("GENERATOR_FILE_NAME"); l->second.GetProperty("GENERATOR_FILE_NAME");
@ -513,8 +508,7 @@ void cmGlobalVisualStudio7Generator
this->WriteProjectConfigurations(fout, name.c_str(), this->WriteProjectConfigurations(fout, name.c_str(),
true); true);
} }
else if ((l->second.GetType() != cmTarget::INSTALL_FILES) else
&& (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
{ {
bool partOfDefaultBuild = this->IsPartOfDefaultBuild( bool partOfDefaultBuild = this->IsPartOfDefaultBuild(
root->GetMakefile()->GetProjectName(), root->GetMakefile()->GetProjectName(),

View File

@ -596,12 +596,6 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
cmtarget.GetType() == cmTarget::GLOBAL_TARGET) cmtarget.GetType() == cmTarget::GLOBAL_TARGET)
{ {
targets.push_back(this->CreateUtilityTarget(cmtarget)); targets.push_back(this->CreateUtilityTarget(cmtarget));
}
if(cmtarget.GetType() == cmTarget::UTILITY ||
cmtarget.GetType() == cmTarget::GLOBAL_TARGET ||
cmtarget.GetType() == cmTarget::INSTALL_FILES ||
cmtarget.GetType() == cmTarget::INSTALL_PROGRAMS)
{
continue; continue;
} }
@ -2498,9 +2492,7 @@ cmGlobalXCodeGenerator::OutputXCodeProject(cmLocalGenerator* root,
for(cmTargets::iterator l = tgts.begin(); for(cmTargets::iterator l = tgts.begin();
l != tgts.end(); l++) l != tgts.end(); l++)
{ {
if ((l->second.GetType() != cmTarget::INSTALL_FILES) if ((strncmp(l->first.c_str(),
&& (l->second.GetType() != cmTarget::INSTALL_PROGRAMS)
&& (strncmp(l->first.c_str(),
"INCLUDE_EXTERNAL_MSPROJECT", 26) != 0) "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0)
&& banned.find(l->second.GetName()) == banned.end()) && banned.find(l->second.GetName()) == banned.end())
{ {

View File

@ -16,6 +16,8 @@
=========================================================================*/ =========================================================================*/
#include "cmInstallFilesCommand.h" #include "cmInstallFilesCommand.h"
#include "cmInstallFilesGenerator.h"
// cmExecutableCommand // cmExecutableCommand
bool cmInstallFilesCommand bool cmInstallFilesCommand
::InitialPass(std::vector<std::string> const& argsIn) ::InitialPass(std::vector<std::string> const& argsIn)
@ -33,13 +35,7 @@ bool cmInstallFilesCommand
std::vector<std::string> args; std::vector<std::string> args;
this->Makefile->ExpandSourceListArguments(argsIn, args, 2); this->Makefile->ExpandSourceListArguments(argsIn, args, 2);
// Create an INSTALL_FILES target specifically for this path. this->Destination = args[0];
this->TargetName = "INSTALL_FILES_"+args[0];
cmTarget& target = this->Makefile->GetTargets()[this->TargetName];
target.SetType(cmTarget::INSTALL_FILES, this->TargetName.c_str());
target.SetMakefile(this->Makefile);
target.SetProperty("EXCLUDE_FROM_ALL","TRUE");
target.SetInstallPath(args[0].c_str());
if((args.size() > 1) && (args[1] == "FILES")) if((args.size() > 1) && (args[1] == "FILES"))
{ {
@ -49,7 +45,7 @@ bool cmInstallFilesCommand
{ {
// Find the source location for each file listed. // Find the source location for each file listed.
std::string f = this->FindInstallSource(s->c_str()); std::string f = this->FindInstallSource(s->c_str());
target.GetSourceLists().push_back(f); this->Files.push_back(f);
} }
} }
else else
@ -75,8 +71,6 @@ void cmInstallFilesCommand::FinalPass()
std::string testf; std::string testf;
std::string ext = this->FinalArgs[0]; std::string ext = this->FinalArgs[0];
std::vector<std::string>& targetSourceLists =
this->Makefile->GetTargets()[this->TargetName].GetSourceLists();
// two different options // two different options
if (this->FinalArgs.size() > 1) if (this->FinalArgs.size() > 1)
@ -100,7 +94,7 @@ void cmInstallFilesCommand::FinalPass()
} }
// add to the result // add to the result
targetSourceLists.push_back(this->FindInstallSource(testf.c_str())); this->Files.push_back(this->FindInstallSource(testf.c_str()));
} }
} }
else // reg exp list else // reg exp list
@ -114,9 +108,20 @@ 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)
{ {
targetSourceLists.push_back(this->FindInstallSource(s->c_str())); this->Files.push_back(this->FindInstallSource(s->c_str()));
} }
} }
// Use a file install generator.
const char* no_permissions = "";
const char* no_rename = "";
const char* no_component = "";
std::vector<std::string> no_configurations;
this->Makefile->AddInstallGenerator(
new cmInstallFilesGenerator(this->Files,
this->Destination.c_str(), false,
no_permissions, no_configurations,
no_component, no_rename));
} }
/** /**

View File

@ -106,9 +106,10 @@ protected:
std::string FindInstallSource(const char* name) const; std::string FindInstallSource(const char* name) const;
private: private:
std::string TargetName;
std::vector<std::string> FinalArgs; std::vector<std::string> FinalArgs;
bool IsFilesForm; bool IsFilesForm;
std::string Destination;
std::vector<std::string> Files;
}; };

View File

@ -30,13 +30,7 @@ bool cmInstallProgramsCommand
this->Makefile->GetLocalGenerator() this->Makefile->GetLocalGenerator()
->GetGlobalGenerator()->EnableInstallTarget(); ->GetGlobalGenerator()->EnableInstallTarget();
// Create an INSTALL_PROGRAMS target specifically for this path. this->Destination = args[0];
this->TargetName = "INSTALL_PROGRAMS_"+args[0];
cmTarget& target = this->Makefile->GetTargets()[this->TargetName];
target.SetType(cmTarget::INSTALL_PROGRAMS, this->TargetName.c_str());
target.SetMakefile(this->Makefile);
target.SetProperty("EXCLUDE_FROM_ALL","TRUE");
target.SetInstallPath(args[0].c_str());
std::vector<std::string>::const_iterator s = args.begin(); std::vector<std::string>::const_iterator s = args.begin();
for (++s;s != args.end(); ++s) for (++s;s != args.end(); ++s)
@ -49,9 +43,6 @@ bool cmInstallProgramsCommand
void cmInstallProgramsCommand::FinalPass() void cmInstallProgramsCommand::FinalPass()
{ {
std::vector<std::string>& targetSourceLists =
this->Makefile->GetTargets()[this->TargetName].GetSourceLists();
bool files_mode = false; bool files_mode = false;
if(!this->FinalArgs.empty() && this->FinalArgs[0] == "FILES") if(!this->FinalArgs.empty() && this->FinalArgs[0] == "FILES")
{ {
@ -71,7 +62,7 @@ void cmInstallProgramsCommand::FinalPass()
for(;s != this->FinalArgs.end(); ++s) for(;s != this->FinalArgs.end(); ++s)
{ {
// add to the result // add to the result
targetSourceLists.push_back(this->FindInstallSource(s->c_str())); this->Files.push_back(this->FindInstallSource(s->c_str()));
} }
} }
else // reg exp list else // reg exp list
@ -84,9 +75,20 @@ 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)
{ {
targetSourceLists.push_back(this->FindInstallSource(s->c_str())); this->Files.push_back(this->FindInstallSource(s->c_str()));
} }
} }
// Use a file install generator.
const char* no_permissions = "";
const char* no_rename = "";
const char* no_component = "";
std::vector<std::string> no_configurations;
this->Makefile->AddInstallGenerator(
new cmInstallFilesGenerator(this->Files,
this->Destination.c_str(), true,
no_permissions, no_configurations,
no_component, no_rename));
} }
/** /**

View File

@ -101,8 +101,9 @@ public:
protected: protected:
std::string FindInstallSource(const char* name) const; std::string FindInstallSource(const char* name) const;
private: private:
std::string TargetName;
std::vector<std::string> FinalArgs; std::vector<std::string> FinalArgs;
std::string Destination;
std::vector<std::string> Files;
}; };

View File

@ -145,10 +145,7 @@ void cmLocalGenerator::TraceDependencies()
{ {
// INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace
// so don't build a projectfile for it // so don't build a projectfile for it
if ((t->second.GetType() != cmTarget::INSTALL_FILES) if (strncmp(t->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0)
&& (t->second.GetType() != cmTarget::INSTALL_PROGRAMS)
&& (t->second.GetType() != cmTarget::INSTALL_DIRECTORY)
&& (strncmp(t->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0))
{ {
std::string projectFilename; std::string projectFilename;
if (this->IsMakefileGenerator == false) // only use of this variable if (this->IsMakefileGenerator == false) // only use of this variable

View File

@ -141,19 +141,13 @@ void cmLocalVisualStudio6Generator::OutputDSPFile()
case cmTarget::GLOBAL_TARGET: case cmTarget::GLOBAL_TARGET:
this->SetBuildType(UTILITY, l->first.c_str(), l->second); this->SetBuildType(UTILITY, l->first.c_str(), l->second);
break; break;
case cmTarget::INSTALL_FILES:
break;
case cmTarget::INSTALL_PROGRAMS:
break;
default: default:
cmSystemTools::Error("Bad target type", l->first.c_str()); cmSystemTools::Error("Bad target type", l->first.c_str());
break; break;
} }
// INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace
// so don't build a projectfile for it // so don't build a projectfile for it
if ((l->second.GetType() != cmTarget::INSTALL_FILES) if (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0)
&& (l->second.GetType() != cmTarget::INSTALL_PROGRAMS)
&& (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0))
{ {
// check to see if the dsp is going into a sub-directory // check to see if the dsp is going into a sub-directory
std::string::size_type pos = l->first.rfind('/'); std::string::size_type pos = l->first.rfind('/');

View File

@ -134,9 +134,7 @@ void cmLocalVisualStudio7Generator::OutputVCProjFile()
{ {
// INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace
// so don't build a projectfile for it // so don't build a projectfile for it
if ((l->second.GetType() != cmTarget::INSTALL_FILES) if (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0)
&& (l->second.GetType() != cmTarget::INSTALL_PROGRAMS)
&& (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0))
{ {
this->CreateSingleVCProj(l->first.c_str(),l->second); this->CreateSingleVCProj(l->first.c_str(),l->second);
} }

View File

@ -1317,8 +1317,6 @@ void cmMakefile::AddGlobalLinkInformation(const char* name, cmTarget& target)
{ {
case cmTarget::UTILITY: case cmTarget::UTILITY:
case cmTarget::GLOBAL_TARGET: case cmTarget::GLOBAL_TARGET:
case cmTarget::INSTALL_FILES:
case cmTarget::INSTALL_PROGRAMS:
return; return;
default:; default:;
} }

View File

@ -337,6 +337,12 @@ void cmTarget::DefineProperties(cmake *cm)
void cmTarget::SetType(TargetType type, const char* name) void cmTarget::SetType(TargetType type, const char* name)
{ {
this->Name = name; this->Name = name;
if(type == cmTarget::INSTALL_FILES ||
type == cmTarget::INSTALL_PROGRAMS ||
type == cmTarget::INSTALL_DIRECTORY)
{
abort();
}
// only add dependency information for library targets // only add dependency information for library targets
this->TargetTypeValue = type; this->TargetTypeValue = type;
if(this->TargetTypeValue >= STATIC_LIBRARY if(this->TargetTypeValue >= STATIC_LIBRARY
@ -664,12 +670,6 @@ void cmTarget::GenerateSourceFilesFromSourceLists( cmMakefile &mf)
{ {
return; return;
} }
// this is only done for non install targets
if ((this->TargetTypeValue == cmTarget::INSTALL_FILES)
|| (this->TargetTypeValue == cmTarget::INSTALL_PROGRAMS))
{
return;
}
// for each src lists add the classes // for each src lists add the classes
for (std::vector<std::string>::const_iterator s = this->SourceLists.begin(); for (std::vector<std::string>::const_iterator s = this->SourceLists.begin();
s != this->SourceLists.end(); ++s) s != this->SourceLists.end(); ++s)