Improve signature of cmLocalGenerator::GetRealDependency

Allow file-level custom command dependencies to be skipped.
This commit is contained in:
Brad King 2010-12-08 16:51:16 -05:00
parent afc8906468
commit e30a775f68
7 changed files with 51 additions and 33 deletions

View File

@ -1334,11 +1334,13 @@ void cmGlobalXCodeGenerator
cc.GetDepends().begin();
d != cc.GetDepends().end(); ++d)
{
std::string dep =
this->CurrentLocalGenerator->GetRealDependency(d->c_str(),
configName);
makefileStream << "\\\n" << this
->ConvertToRelativeForMake(dep.c_str());
std::string dep;
if(this->CurrentLocalGenerator
->GetRealDependency(d->c_str(), configName, dep))
{
makefileStream << "\\\n" <<
this->ConvertToRelativeForMake(dep.c_str());
}
}
makefileStream << "\n";

View File

@ -1818,8 +1818,9 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
}
//----------------------------------------------------------------------------
std::string cmLocalGenerator::GetRealDependency(const char* inName,
const char* config)
bool cmLocalGenerator::GetRealDependency(const char* inName,
const char* config,
std::string& dep)
{
// Older CMake code may specify the dependency using the target
// output file rather than the target name. Such code would have
@ -1855,7 +1856,8 @@ std::string cmLocalGenerator::GetRealDependency(const char* inName,
// it is a full path to a depend that has the same name
// as a target but is in a different location so do not use
// the target as the depend
return inName;
dep = inName;
return true;
}
}
switch (target->GetType())
@ -1869,7 +1871,8 @@ std::string cmLocalGenerator::GetRealDependency(const char* inName,
// Get the location of the target's output file and depend on it.
if(const char* location = target->GetLocation(config))
{
return location;
dep = location;
return true;
}
}
break;
@ -1877,7 +1880,8 @@ std::string cmLocalGenerator::GetRealDependency(const char* inName,
case cmTarget::GLOBAL_TARGET:
// Depending on a utility target may not work but just trust
// the user to have given a valid name.
return inName;
dep = inName;
return true;
case cmTarget::INSTALL_FILES:
case cmTarget::INSTALL_PROGRAMS:
case cmTarget::INSTALL_DIRECTORY:
@ -1889,23 +1893,24 @@ std::string cmLocalGenerator::GetRealDependency(const char* inName,
if(cmSystemTools::FileIsFullPath(inName))
{
// This is a full path. Return it as given.
return inName;
dep = inName;
return true;
}
// Check for a source file in this directory that matches the
// dependency.
if(cmSourceFile* sf = this->Makefile->GetSource(inName))
{
name = sf->GetFullPath();
return name;
dep = sf->GetFullPath();
return true;
}
// Treat the name as relative to the source directory in which it
// was given.
name = this->Makefile->GetCurrentDirectory();
name += "/";
name += inName;
return name;
dep = this->Makefile->GetCurrentDirectory();
dep += "/";
dep += inName;
return true;
}
//----------------------------------------------------------------------------

View File

@ -164,8 +164,9 @@ public:
Otherwise the name is treated as a relative path with respect to
the source directory of this generator. This should only be
used for dependencies of custom commands. */
std::string GetRealDependency(const char* name, const char* config);
bool GetRealDependency(const char* name, const char* config,
std::string& dep);
/** Translate a command as given in CMake code to the location of the
executable if the command is the name of a CMake executable target.
If that's not the case, just return the original name. */

View File

@ -902,9 +902,12 @@ cmLocalUnixMakefileGenerator3
d != cc.GetDepends().end(); ++d)
{
// Lookup the real name of the dependency in case it is a CMake target.
std::string dep = this->GetRealDependency
(d->c_str(), this->ConfigurationName.c_str());
depends.push_back(dep);
std::string dep;
if(this->GetRealDependency(d->c_str(), this->ConfigurationName.c_str(),
dep))
{
depends.push_back(dep);
}
}
}

View File

@ -686,10 +686,12 @@ cmLocalVisualStudio6Generator
++d)
{
// Lookup the real name of the dependency in case it is a CMake target.
std::string dep = this->GetRealDependency(d->c_str(),
config.c_str());
fout << "\\\n\t" <<
this->ConvertToOptionallyRelativeOutputPath(dep.c_str());
std::string dep;
if(this->GetRealDependency(d->c_str(), config.c_str(), dep))
{
fout << "\\\n\t" <<
this->ConvertToOptionallyRelativeOutputPath(dep.c_str());
}
}
fout << "\n";

View File

@ -1624,9 +1624,12 @@ WriteCustomRule(std::ostream& fout,
++d)
{
// Get the real name of the dependency in case it is a CMake target.
std::string dep = this->GetRealDependency(d->c_str(), i->c_str());
fout << this->ConvertToXMLOutputPath(dep.c_str())
<< ";";
std::string dep;
if(this->GetRealDependency(d->c_str(), i->c_str(), dep))
{
fout << this->ConvertToXMLOutputPath(dep.c_str())
<< ";";
}
}
}
fout << "\"\n";

View File

@ -386,10 +386,12 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source,
d != command.GetDepends().end();
++d)
{
std::string dep = this->LocalGenerator->
GetRealDependency(d->c_str(), i->c_str());
this->ConvertToWindowsSlash(dep);
(*this->BuildFileStream ) << ";" << dep;
std::string dep;
if(this->LocalGenerator->GetRealDependency(d->c_str(), i->c_str(), dep))
{
this->ConvertToWindowsSlash(dep);
(*this->BuildFileStream ) << ";" << dep;
}
}
(*this->BuildFileStream ) << ";%(AdditionalInputs)</AdditionalInputs>\n";
this->WritePlatformConfigTag("Outputs", i->c_str(), 3);