STYLE: Fixed line-too-long, fixed indentation, removed trailing whitespace, added function separator comment lines.

This commit is contained in:
Brad King 2007-07-02 13:32:41 -04:00
parent 930bb0cd37
commit cac79e92b8
2 changed files with 246 additions and 211 deletions

View File

@ -41,7 +41,7 @@ cmTarget::cmTarget()
this->IsImportedTarget = false; this->IsImportedTarget = false;
} }
// define properties //----------------------------------------------------------------------------
void cmTarget::DefineProperties(cmake *cm) void cmTarget::DefineProperties(cmake *cm)
{ {
cm->DefineProperty cm->DefineProperty
@ -666,6 +666,7 @@ void cmTarget::AddSources(std::vector<std::string> const& srcs)
} }
} }
//----------------------------------------------------------------------------
cmSourceFile* cmTarget::AddSource(const char* s) cmSourceFile* cmTarget::AddSource(const char* s)
{ {
std::string src = s; std::string src = s;
@ -679,6 +680,7 @@ cmSourceFile* cmTarget::AddSource(const char* s)
return sf; return sf;
} }
//----------------------------------------------------------------------------
void cmTarget::MergeLinkLibraries( cmMakefile& mf, void cmTarget::MergeLinkLibraries( cmMakefile& mf,
const char *selfname, const char *selfname,
const LinkLibraryVectorType& libs ) const LinkLibraryVectorType& libs )
@ -767,6 +769,7 @@ const std::vector<std::string>& cmTarget::GetLinkDirectories()
return this->LinkDirectories; return this->LinkDirectories;
} }
//----------------------------------------------------------------------------
void cmTarget::ClearDependencyInformation( cmMakefile& mf, void cmTarget::ClearDependencyInformation( cmMakefile& mf,
const char* target ) const char* target )
{ {
@ -794,8 +797,7 @@ void cmTarget::ClearDependencyInformation( cmMakefile& mf,
} }
} }
//----------------------------------------------------------------------------
void cmTarget::AddLinkLibrary(const std::string& lib, void cmTarget::AddLinkLibrary(const std::string& lib,
LinkLibraryType llt) LinkLibraryType llt)
{ {
@ -806,6 +808,7 @@ void cmTarget::AddLinkLibrary(const std::string& lib,
this->LinkLibraries.push_back(tmp); this->LinkLibraries.push_back(tmp);
} }
//----------------------------------------------------------------------------
bool cmTarget::AddFramework(const std::string& libname, LinkLibraryType llt) bool cmTarget::AddFramework(const std::string& libname, LinkLibraryType llt)
{ {
(void)llt; // TODO: What is this? (void)llt; // TODO: What is this?
@ -825,6 +828,8 @@ bool cmTarget::AddFramework(const std::string& libname, LinkLibraryType llt)
} }
return false; return false;
} }
//----------------------------------------------------------------------------
void cmTarget::AddLinkLibrary(cmMakefile& mf, void cmTarget::AddLinkLibrary(cmMakefile& mf,
const char *target, const char* lib, const char *target, const char* lib,
LinkLibraryType llt) LinkLibraryType llt)
@ -880,6 +885,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
} }
//----------------------------------------------------------------------------
void void
cmTarget::AnalyzeLibDependencies( const cmMakefile& mf ) cmTarget::AnalyzeLibDependencies( const cmMakefile& mf )
{ {
@ -952,82 +958,82 @@ cmTarget::AnalyzeLibDependencies( const cmMakefile& mf )
// cyclic dependencies, so this is probably not a big deal. Note that // cyclic dependencies, so this is probably not a big deal. Note that
// the link line is always correct, just not necessary optimal. // the link line is always correct, just not necessary optimal.
{ {
// Expand variables in link library names. This is for backwards // Expand variables in link library names. This is for backwards
// compatibility with very early CMake versions and should // compatibility with very early CMake versions and should
// eventually be removed. This code was moved here from the end of // eventually be removed. This code was moved here from the end of
// old source list processing code which was called just before this // old source list processing code which was called just before this
// method. // method.
for(LinkLibraryVectorType::iterator p = this->LinkLibraries.begin(); for(LinkLibraryVectorType::iterator p = this->LinkLibraries.begin();
p != this->LinkLibraries.end(); ++p) p != this->LinkLibraries.end(); ++p)
{ {
this->Makefile->ExpandVariablesInString(p->first, true, true); this->Makefile->ExpandVariablesInString(p->first, true, true);
} }
} }
typedef std::vector< std::string > LinkLine; typedef std::vector< std::string > LinkLine;
// The dependency map. // The dependency map.
DependencyMap dep_map; DependencyMap dep_map;
if ( this->OriginalLinkLibraries.size() == 0 ) if ( this->OriginalLinkLibraries.size() == 0 )
{ {
this->OriginalLinkLibraries = this->LinkLibraries; this->OriginalLinkLibraries = this->LinkLibraries;
} }
// 1. Build the dependency graph // 1. Build the dependency graph
// //
for(LinkLibraryVectorType::reverse_iterator lib for(LinkLibraryVectorType::reverse_iterator lib
= this->LinkLibraries.rbegin(); = this->LinkLibraries.rbegin();
lib != this->LinkLibraries.rend(); ++lib) lib != this->LinkLibraries.rend(); ++lib)
{ {
this->GatherDependencies( mf, *lib, dep_map); this->GatherDependencies( mf, *lib, dep_map);
} }
// 2. Remove any dependencies that are already satisfied in the original // 2. Remove any dependencies that are already satisfied in the original
// link line. // link line.
// //
for(LinkLibraryVectorType::iterator lib = this->LinkLibraries.begin(); for(LinkLibraryVectorType::iterator lib = this->LinkLibraries.begin();
lib != this->LinkLibraries.end(); ++lib) lib != this->LinkLibraries.end(); ++lib)
{ {
for( LinkLibraryVectorType::iterator lib2 = lib; for( LinkLibraryVectorType::iterator lib2 = lib;
lib2 != this->LinkLibraries.end(); ++lib2) lib2 != this->LinkLibraries.end(); ++lib2)
{ {
this->DeleteDependency( dep_map, *lib, *lib2); this->DeleteDependency( dep_map, *lib, *lib2);
} }
} }
// 3. Create the new link line by simply emitting any dependencies that are // 3. Create the new link line by simply emitting any dependencies that are
// missing. Start from the back and keep adding. // missing. Start from the back and keep adding.
// //
std::set<DependencyMap::key_type> done, visited; std::set<DependencyMap::key_type> done, visited;
std::vector<DependencyMap::key_type> newLinkLibraries; std::vector<DependencyMap::key_type> newLinkLibraries;
for(LinkLibraryVectorType::reverse_iterator lib = for(LinkLibraryVectorType::reverse_iterator lib =
this->LinkLibraries.rbegin(); this->LinkLibraries.rbegin();
lib != this->LinkLibraries.rend(); ++lib) lib != this->LinkLibraries.rend(); ++lib)
{ {
// skip zero size library entries, this may happen // skip zero size library entries, this may happen
// if a variable expands to nothing. // if a variable expands to nothing.
if (lib->first.size() != 0) if (lib->first.size() != 0)
{ {
this->Emit( *lib, dep_map, done, visited, newLinkLibraries ); this->Emit( *lib, dep_map, done, visited, newLinkLibraries );
} }
} }
// 4. Add the new libraries to the link line. // 4. Add the new libraries to the link line.
// //
for( std::vector<DependencyMap::key_type>::reverse_iterator k = for( std::vector<DependencyMap::key_type>::reverse_iterator k =
newLinkLibraries.rbegin(); newLinkLibraries.rbegin();
k != newLinkLibraries.rend(); ++k ) k != newLinkLibraries.rend(); ++k )
{ {
// get the llt from the dep_map // get the llt from the dep_map
this->LinkLibraries.push_back( std::make_pair(k->first,k->second) ); this->LinkLibraries.push_back( std::make_pair(k->first,k->second) );
} }
this->LinkLibrariesAnalyzed = true; this->LinkLibrariesAnalyzed = true;
} }
//----------------------------------------------------------------------------
void cmTarget::InsertDependency( DependencyMap& depMap, void cmTarget::InsertDependency( DependencyMap& depMap,
const LibraryID& lib, const LibraryID& lib,
const LibraryID& dep) const LibraryID& dep)
@ -1035,6 +1041,7 @@ void cmTarget::InsertDependency( DependencyMap& depMap,
depMap[lib].push_back(dep); depMap[lib].push_back(dep);
} }
//----------------------------------------------------------------------------
void cmTarget::DeleteDependency( DependencyMap& depMap, void cmTarget::DeleteDependency( DependencyMap& depMap,
const LibraryID& lib, const LibraryID& lib,
const LibraryID& dep) const LibraryID& dep)
@ -1055,6 +1062,7 @@ void cmTarget::DeleteDependency( DependencyMap& depMap,
} }
} }
//----------------------------------------------------------------------------
void cmTarget::Emit(const LibraryID lib, void cmTarget::Emit(const LibraryID lib,
const DependencyMap& dep_map, const DependencyMap& dep_map,
std::set<LibraryID>& emitted, std::set<LibraryID>& emitted,
@ -1117,7 +1125,7 @@ void cmTarget::Emit(const LibraryID lib,
} }
} }
//----------------------------------------------------------------------------
void cmTarget::GatherDependencies( const cmMakefile& mf, void cmTarget::GatherDependencies( const cmMakefile& mf,
const LibraryID& lib, const LibraryID& lib,
DependencyMap& dep_map) DependencyMap& dep_map)
@ -1177,7 +1185,7 @@ void cmTarget::GatherDependencies( const cmMakefile& mf,
} }
} }
//----------------------------------------------------------------------------
void cmTarget::SetProperty(const char* prop, const char* value) void cmTarget::SetProperty(const char* prop, const char* value)
{ {
if (!prop) if (!prop)
@ -1192,11 +1200,13 @@ void cmTarget::SetProperty(const char* prop, const char* value)
this->Properties.SetProperty(prop, value, cmProperty::TARGET); this->Properties.SetProperty(prop, value, cmProperty::TARGET);
} }
//----------------------------------------------------------------------------
void cmTarget::MarkAsImported() void cmTarget::MarkAsImported()
{ {
this->IsImportedTarget = true; this->IsImportedTarget = true;
} }
//----------------------------------------------------------------------------
const char* cmTarget::GetDirectory(const char* config, bool implib) const char* cmTarget::GetDirectory(const char* config, bool implib)
{ {
if (this->IsImported()) if (this->IsImported())
@ -1209,6 +1219,7 @@ const char* cmTarget::GetDirectory(const char* config, bool implib)
} }
} }
//----------------------------------------------------------------------------
const char* cmTarget::ImportedGetDirectory(const char* config, bool) const char* cmTarget::ImportedGetDirectory(const char* config, bool)
{ {
const char* location=this->GetLocation(config); const char* location=this->GetLocation(config);
@ -1216,6 +1227,7 @@ const char* cmTarget::ImportedGetDirectory(const char* config, bool)
return directory.c_str(); return directory.c_str();
} }
//----------------------------------------------------------------------------
const char* cmTarget::NormalGetDirectory(const char* config, bool implib) const char* cmTarget::NormalGetDirectory(const char* config, bool implib)
{ {
if(config && *config) if(config && *config)
@ -1232,6 +1244,7 @@ const char* cmTarget::NormalGetDirectory(const char* config, bool implib)
} }
} }
//----------------------------------------------------------------------------
const char* cmTarget::GetLocation(const char* config) const char* cmTarget::GetLocation(const char* config)
{ {
if (this->IsImported()) if (this->IsImported())
@ -1244,6 +1257,7 @@ const char* cmTarget::GetLocation(const char* config)
} }
} }
//----------------------------------------------------------------------------
const char* cmTarget::ImportedGetLocation(const char* config) const char* cmTarget::ImportedGetLocation(const char* config)
{ {
if ((config) && (strlen(config))) if ((config) && (strlen(config)))
@ -1260,6 +1274,7 @@ const char* cmTarget::ImportedGetLocation(const char* config)
return this->GetProperty("LOCATION"); return this->GetProperty("LOCATION");
} }
//----------------------------------------------------------------------------
const char* cmTarget::NormalGetLocation(const char* config) const char* cmTarget::NormalGetLocation(const char* config)
{ {
this->Location = this->GetDirectory(); this->Location = this->GetDirectory();
@ -1300,11 +1315,13 @@ void cmTarget::GetTargetVersion(int& major, int& minor)
} }
} }
//----------------------------------------------------------------------------
const char *cmTarget::GetProperty(const char* prop) const char *cmTarget::GetProperty(const char* prop)
{ {
return this->GetProperty(prop, cmProperty::TARGET); return this->GetProperty(prop, cmProperty::TARGET);
} }
//----------------------------------------------------------------------------
void cmTarget::ComputeObjectFiles() void cmTarget::ComputeObjectFiles()
{ {
if (this->IsImported()) if (this->IsImported())
@ -1352,7 +1369,7 @@ void cmTarget::ComputeObjectFiles()
#endif #endif
} }
//----------------------------------------------------------------------------
const char *cmTarget::GetProperty(const char* prop, const char *cmTarget::GetProperty(const char* prop,
cmProperty::ScopeType scope) cmProperty::ScopeType scope)
{ {
@ -1361,40 +1378,41 @@ const char *cmTarget::GetProperty(const char* prop,
return 0; return 0;
} }
// don't use GetLocation() for imported targets, because there this // don't use GetLocation() for imported targets, because there this
// calls GetProperty() to get the location... // calls GetProperty() to get the location...
if (!this->IsImported()) if (!this->IsImported())
{
// watch for special "computed" properties that are dependent on other
// properties or variables, always recompute them
if (!strcmp(prop,"LOCATION"))
{ {
// watch for special "computed" properties that are dependent on other // Set the LOCATION property of the target. Note that this
// properties or variables, always recompute them // cannot take into account the per-configuration name of the
if (!strcmp(prop,"LOCATION")) // target because the configuration type may not be known at
{ // CMake time. We should deprecate this feature and instead
// Set the LOCATION property of the target. Note that this cannot take // support transforming an executable target name given as the
// into account the per-configuration name of the target because the // command part of custom commands into the proper path at
// configuration type may not be known at CMake time. We should // build time. Alternatively we could put environment
// deprecate this feature and instead support transforming an executable // variable settings in all custom commands that hold the name
// target name given as the command part of custom commands into the // of the target for each configuration and then give a
// proper path at build time. Alternatively we could put environment // reference to the variable in the location.
// variable settings in all custom commands that hold the name of the this->SetProperty("LOCATION", this->GetLocation(0));
// target for each configuration and then give a reference to the
// variable in the location.
this->SetProperty("LOCATION", this->GetLocation(0));
}
// Per-configuration location can be computed.
int len = static_cast<int>(strlen(prop));
if(len > 9 && strcmp(prop+len-9, "_LOCATION") == 0)
{
std::string configName(prop, len-9);
this->SetProperty(prop, this->GetLocation(configName.c_str()));
}
if(strcmp(prop, "OBJECT_FILES") == 0)
{
this->ComputeObjectFiles();
}
} }
// Per-configuration location can be computed.
int len = static_cast<int>(strlen(prop));
if(len > 9 && strcmp(prop+len-9, "_LOCATION") == 0)
{
std::string configName(prop, len-9);
this->SetProperty(prop, this->GetLocation(configName.c_str()));
}
if(strcmp(prop, "OBJECT_FILES") == 0)
{
this->ComputeObjectFiles();
}
}
if (strcmp(prop,"IMPORTED") == 0) if (strcmp(prop,"IMPORTED") == 0)
{ {
return this->IsImported()?"TRUE":"FALSE"; return this->IsImported()?"TRUE":"FALSE";
@ -1445,11 +1463,13 @@ const char *cmTarget::GetProperty(const char* prop,
return retVal; return retVal;
} }
//----------------------------------------------------------------------------
bool cmTarget::GetPropertyAsBool(const char* prop) bool cmTarget::GetPropertyAsBool(const char* prop)
{ {
return cmSystemTools::IsOn(this->GetProperty(prop)); return cmSystemTools::IsOn(this->GetProperty(prop));
} }
//----------------------------------------------------------------------------
const char* cmTarget::GetLinkerLanguage(cmGlobalGenerator* gg) const char* cmTarget::GetLinkerLanguage(cmGlobalGenerator* gg)
{ {
if(this->GetProperty("HAS_CXX")) if(this->GetProperty("HAS_CXX"))
@ -1512,6 +1532,7 @@ const char* cmTarget::GetLinkerLanguage(cmGlobalGenerator* gg)
return this->GetProperty("LINKER_LANGUAGE"); return this->GetProperty("LINKER_LANGUAGE");
} }
//----------------------------------------------------------------------------
const char* cmTarget::GetCreateRuleVariable() const char* cmTarget::GetCreateRuleVariable()
{ {
switch(this->GetType()) switch(this->GetType())
@ -1534,6 +1555,7 @@ const char* cmTarget::GetCreateRuleVariable()
return ""; return "";
} }
//----------------------------------------------------------------------------
const char* cmTarget::GetSuffixVariableInternal(TargetType type, const char* cmTarget::GetSuffixVariableInternal(TargetType type,
bool implib) bool implib)
{ {
@ -1564,6 +1586,7 @@ const char* cmTarget::GetSuffixVariableInternal(TargetType type,
} }
//----------------------------------------------------------------------------
const char* cmTarget::GetPrefixVariableInternal(TargetType type, const char* cmTarget::GetPrefixVariableInternal(TargetType type,
bool implib) bool implib)
{ {
@ -1640,12 +1663,13 @@ std::string cmTarget::GetFullNameInternal(TargetType type, const char* config,
return prefix+base+suffix; return prefix+base+suffix;
} }
//----------------------------------------------------------------------------
void cmTarget::GetFullNameInternal(TargetType type, void cmTarget::GetFullNameInternal(TargetType type,
const char* config, const char* config,
bool implib, bool implib,
std::string& outPrefix, std::string& outPrefix,
std::string& outBase, std::string& outBase,
std::string& outSuffix) std::string& outSuffix)
{ {
if (this->IsImported()) if (this->IsImported())
{ {
@ -1659,12 +1683,13 @@ void cmTarget::GetFullNameInternal(TargetType type,
} }
} }
//----------------------------------------------------------------------------
void cmTarget::ImportedGetFullNameInternal(TargetType , void cmTarget::ImportedGetFullNameInternal(TargetType ,
const char* config, const char* config,
bool , bool ,
std::string& outPrefix, std::string& outPrefix,
std::string& outBase, std::string& outBase,
std::string& outSuffix) std::string& outSuffix)
{ {
// find the basename, suffix and prefix from getLocation() // find the basename, suffix and prefix from getLocation()
// implib ? // implib ?
@ -1810,6 +1835,7 @@ void cmTarget::NormalGetFullNameInternal(TargetType type,
outSuffix = targetSuffix?targetSuffix:""; outSuffix = targetSuffix?targetSuffix:"";
} }
//----------------------------------------------------------------------------
void cmTarget::GetLibraryNames(std::string& name, void cmTarget::GetLibraryNames(std::string& name,
std::string& soName, std::string& soName,
std::string& realName, std::string& realName,
@ -1822,6 +1848,7 @@ void cmTarget::GetLibraryNames(std::string& name,
this->GetType(), config); this->GetType(), config);
} }
//----------------------------------------------------------------------------
void cmTarget::GetLibraryCleanNames(std::string& staticName, void cmTarget::GetLibraryCleanNames(std::string& staticName,
std::string& sharedName, std::string& sharedName,
std::string& sharedSOName, std::string& sharedSOName,
@ -1858,6 +1885,7 @@ void cmTarget::GetLibraryCleanNames(std::string& staticName,
} }
} }
//----------------------------------------------------------------------------
void cmTarget::GetLibraryNamesInternal(std::string& name, void cmTarget::GetLibraryNamesInternal(std::string& name,
std::string& soName, std::string& soName,
std::string& realName, std::string& realName,
@ -1955,6 +1983,7 @@ void cmTarget::GetLibraryNamesInternal(std::string& name,
pdbName = prefix+base+".pdb"; pdbName = prefix+base+".pdb";
} }
//----------------------------------------------------------------------------
void cmTarget::GetExecutableNames(std::string& name, void cmTarget::GetExecutableNames(std::string& name,
std::string& realName, std::string& realName,
std::string& impName, std::string& impName,
@ -1966,6 +1995,7 @@ void cmTarget::GetExecutableNames(std::string& name,
this->GetType(), config); this->GetType(), config);
} }
//----------------------------------------------------------------------------
void cmTarget::GetExecutableCleanNames(std::string& name, void cmTarget::GetExecutableCleanNames(std::string& name,
std::string& realName, std::string& realName,
std::string& impName, std::string& impName,
@ -1977,6 +2007,7 @@ void cmTarget::GetExecutableCleanNames(std::string& name,
cmTarget::EXECUTABLE, config); cmTarget::EXECUTABLE, config);
} }
//----------------------------------------------------------------------------
void cmTarget::GetExecutableNamesInternal(std::string& name, void cmTarget::GetExecutableNamesInternal(std::string& name,
std::string& realName, std::string& realName,
std::string& impName, std::string& impName,

View File

@ -46,7 +46,7 @@ public:
*/ */
TargetType GetType() const TargetType GetType() const
{ {
return this->TargetTypeValue; return this->TargetTypeValue;
} }
/** /**
@ -99,7 +99,7 @@ public:
typedef std::vector<LibraryID > LinkLibraryVectorType; typedef std::vector<LibraryID > LinkLibraryVectorType;
const LinkLibraryVectorType &GetLinkLibraries() const { const LinkLibraryVectorType &GetLinkLibraries() const {
return this->LinkLibraries;} return this->LinkLibraries;}
const LinkLibraryVectorType &GetOriginalLinkLibraries() const const LinkLibraryVectorType &GetOriginalLinkLibraries() const
{return this->OriginalLinkLibraries;} {return this->OriginalLinkLibraries;}
@ -137,7 +137,7 @@ public:
*/ */
std::string GetRuntimeInstallPath() {return this->RuntimeInstallPath;} std::string GetRuntimeInstallPath() {return this->RuntimeInstallPath;}
void SetRuntimeInstallPath(const char *name) { void SetRuntimeInstallPath(const char *name) {
this->RuntimeInstallPath = name;} this->RuntimeInstallPath = name;}
/** /**
* Get/Set whether there is an install rule for this target. * Get/Set whether there is an install rule for this target.
@ -346,12 +346,16 @@ private:
const char* ImportedGetLocation(const char* config); const char* ImportedGetLocation(const char* config);
const char* NormalGetLocation(const char* config); const char* NormalGetLocation(const char* config);
void NormalGetFullNameInternal(TargetType type, const char* config, bool implib, void NormalGetFullNameInternal(TargetType type, const char* config,
std::string& outPrefix, std::string& outBase, bool implib,
std::string& outSuffix); std::string& outPrefix,
void ImportedGetFullNameInternal(TargetType type, const char* config, bool implib, std::string& outBase,
std::string& outPrefix, std::string& outBase, std::string& outSuffix);
std::string& outSuffix); void ImportedGetFullNameInternal(TargetType type, const char* config,
bool implib,
std::string& outPrefix,
std::string& outBase,
std::string& outSuffix);
const char* ImportedGetDirectory(const char* config, bool implib); const char* ImportedGetDirectory(const char* config, bool implib);
const char* NormalGetDirectory(const char* config, bool implib); const char* NormalGetDirectory(const char* config, bool implib);