Merge topic 'use-generator-target'

79c3a2a8 cmGlobalGenerator: Remove map from cmTarget to cmGeneratorTarget
c389f8bb cmLocalGenerator: Port Find method away from GetGeneratorTarget
02533038 VS6: Port to FindGeneratorTarget
b6278e9f cmake: Port find_package mode away from GetGeneratorTarget
7a6caae1 cmMakefile: Add imported target accessor
0fb187cc CMP0026: Port away from GetGeneratorTarget
8caf1f36 cmGlobalGenerator: Add FindGeneratorTarget API
278ba2db cmGeneratorTarget: Add API for globally visible IMPORTED
79c11d23 Xcode: Port away from GetGeneratorTarget
9b244cc0 cmLocalGenerator: Store imported targets in a separate container.
def6da61 cmLocalGenerator: Port FindGeneratorTarget away from GetGeneratorTarget
a67231ac cmTarget: Implement ALIAS in terms of name mapping
d566f39a cmGlobalGenerator: Remove unneeded GetGeneratorTarget
0c97d32f cmGlobalGenerator: Remove direct storage of targets
383bfd95 cmTargetCollectLinkLanguages: Remove cmMakefile dependency
7f6bedda cmGeneratorTarget: Port cmOptionalLinkImplementation
...
This commit is contained in:
Brad King 2015-10-28 08:48:05 -04:00 committed by CMake Topic Stage
commit 1e8c920d04
49 changed files with 622 additions and 409 deletions

View File

@ -192,7 +192,7 @@ bool cmAddExecutableCommand
this->SetError(e.str());
return false;
}
this->Makefile->AddAlias(exename, aliasedTarget);
this->Makefile->AddAlias(exename, aliasedName);
return true;
}

View File

@ -314,7 +314,7 @@ bool cmAddLibraryCommand
this->SetError(e.str());
return false;
}
this->Makefile->AddAlias(libName, aliasedTarget);
this->Makefile->AddAlias(libName, aliasedName);
return true;
}

View File

@ -60,10 +60,10 @@ bool cmAuxSourceDirectoryCommand::InitialPass
std::string ext = file.substr(dotpos+1);
std::string base = file.substr(0, dotpos);
// Process only source files
if(!base.empty()
&& std::find( this->Makefile->GetSourceExtensions().begin(),
this->Makefile->GetSourceExtensions().end(), ext )
!= this->Makefile->GetSourceExtensions().end() )
std::vector<std::string> srcExts =
this->Makefile->GetCMakeInstance()->GetSourceExtensions();
if(!base.empty() &&
std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end())
{
std::string fullname = templateDirectory;
fullname += "/";

View File

@ -377,9 +377,9 @@ cmComputeLinkInformation
// Add the search path entries requested by the user to path ordering.
this->OrderLinkerSearchPath
->AddUserDirectories(this->Target->Target->GetLinkDirectories());
->AddUserDirectories(this->Target->GetLinkDirectories());
this->OrderRuntimeSearchPath
->AddUserDirectories(this->Target->Target->GetLinkDirectories());
->AddUserDirectories(this->Target->GetLinkDirectories());
// Set up the implicit link directories.
this->LoadImplicitLinkInfo();
@ -413,7 +413,7 @@ cmComputeLinkInformation
// Construct a mask to not bother with this behavior for link
// directories already specified by the user.
std::vector<std::string> const& dirs =
this->Target->Target->GetLinkDirectories();
this->Target->GetLinkDirectories();
this->OldLinkDirMask.insert(dirs.begin(), dirs.end());
}

View File

@ -382,7 +382,7 @@ void cmComputeTargetDepends::AddTargetDepend(
<< "\" of target \"" << depender->GetName() << "\" does not exist.";
cmListFileBacktrace const* backtrace =
depender->Target->GetUtilityBacktrace(dependee_name);
depender->GetUtilityBacktrace(dependee_name);
if(backtrace)
{
cm->IssueMessage(messageType, e.str(), *backtrace);

View File

@ -213,12 +213,8 @@ cmExportBuildFileGenerator
properties[prop] = value;
}
// Check whether this is a DLL platform.
bool dll_platform =
(mf->IsOn("WIN32") || mf->IsOn("CYGWIN") || mf->IsOn("MINGW"));
// Add the import library for windows DLLs.
if(dll_platform &&
if(target->IsDLLPlatform() &&
(target->GetType() == cmState::SHARED_LIBRARY ||
target->IsExecutableWithExports()) &&
mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"))

View File

@ -879,10 +879,7 @@ cmExportFileGenerator
if(target->GetType() == cmState::SHARED_LIBRARY ||
target->GetType() == cmState::MODULE_LIBRARY)
{
// Check whether this is a DLL platform.
bool dll_platform =
(mf->IsOn("WIN32") || mf->IsOn("CYGWIN") || mf->IsOn("MINGW"));
if(!dll_platform)
if(!target->IsDLLPlatform())
{
std::string prop;
std::string value;

View File

@ -105,16 +105,18 @@ cmExportTryCompileFileGenerator::PopulateProperties(
ImportPropertyMap& properties,
std::set<cmGeneratorTarget const*> &emitted)
{
cmPropertyMap props = target->Target->GetProperties();
for(cmPropertyMap::const_iterator i = props.begin(); i != props.end(); ++i)
std::vector<std::string> props = target->GetPropertyKeys();
for(std::vector<std::string>::const_iterator i = props.begin();
i != props.end(); ++i)
{
properties[i->first] = i->second.GetValue();
if(i->first.find("IMPORTED_LINK_INTERFACE_LIBRARIES") == 0
|| i->first.find("IMPORTED_LINK_DEPENDENT_LIBRARIES") == 0
|| i->first.find("INTERFACE_LINK_LIBRARIES") == 0)
properties[*i] = target->GetProperty(*i);
if(i->find("IMPORTED_LINK_INTERFACE_LIBRARIES") == 0
|| i->find("IMPORTED_LINK_DEPENDENT_LIBRARIES") == 0
|| i->find("INTERFACE_LINK_LIBRARIES") == 0)
{
std::string evalResult = this->FindTargets(i->first,
std::string evalResult = this->FindTargets(*i,
target, emitted);
std::vector<std::string> depends;

View File

@ -383,6 +383,9 @@ void cmExtraCodeBlocksGenerator
all_files_map_t allFiles;
std::vector<std::string> cFiles;
std::vector<std::string> srcExts =
this->GlobalGenerator->GetCMakeInstance()->GetSourceExtensions();
for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
lg!=lgs.end(); lg++)
{
@ -420,9 +423,7 @@ void cmExtraCodeBlocksGenerator
{
std::string srcext = (*si)->GetExtension();
for(std::vector<std::string>::const_iterator
ext = mf->GetSourceExtensions().begin();
ext != mf->GetSourceExtensions().end();
++ext)
ext = srcExts.begin(); ext != srcExts.end(); ++ext)
{
if (srcext == *ext)
{
@ -449,6 +450,9 @@ void cmExtraCodeBlocksGenerator
}
}
std::vector<std::string> headerExts =
this->GlobalGenerator->GetCMakeInstance()->GetHeaderExtensions();
// The following loop tries to add header files matching to implementation
// files to the project. It does that by iterating over all
// C/C++ source files,
@ -468,8 +472,8 @@ void cmExtraCodeBlocksGenerator
// check if there's a matching header around
for(std::vector<std::string>::const_iterator
ext = mf->GetHeaderExtensions().begin();
ext != mf->GetHeaderExtensions().end();
ext = headerExts.begin();
ext != headerExts.end();
++ext)
{
std::string hname=headerBasename;

View File

@ -149,6 +149,11 @@ void cmExtraCodeLiteGenerator
// which may have an acompanying header, one for all other files
std::string projectType;
std::vector<std::string> srcExts =
this->GlobalGenerator->GetCMakeInstance()->GetSourceExtensions();
std::vector<std::string> headerExts =
this->GlobalGenerator->GetCMakeInstance()->GetHeaderExtensions();
std::map<std::string, cmSourceFile*> cFiles;
std::set<std::string> otherFiles;
for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
@ -207,9 +212,7 @@ void cmExtraCodeLiteGenerator
{
std::string srcext = (*si)->GetExtension();
for(std::vector<std::string>::const_iterator
ext = mf->GetSourceExtensions().begin();
ext != mf->GetSourceExtensions().end();
++ext)
ext = srcExts.begin(); ext != srcExts.end(); ++ext)
{
if (srcext == *ext)
{
@ -253,8 +256,8 @@ void cmExtraCodeLiteGenerator
// check if there's a matching header around
for(std::vector<std::string>::const_iterator
ext = mf->GetHeaderExtensions().begin();
ext != mf->GetHeaderExtensions().end();
ext = headerExts.begin();
ext != headerExts.end();
++ext)
{
std::string hname=headerBasename;

View File

@ -393,7 +393,7 @@ struct CompilerIdNode : public cmGeneratorExpressionNode
if (cmsysString_strcasecmp(parameters.begin()->c_str(), compilerId) == 0)
{
switch(context->LG->GetMakefile()->GetPolicyStatus(cmPolicies::CMP0044))
switch(context->LG->GetPolicyStatus(cmPolicies::CMP0044))
{
case cmPolicies::WARN:
{
@ -999,7 +999,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
if (propertyName == "LINKER_LANGUAGE")
{
if (target->Target->LinkLanguagePropagatesToDependents() &&
if (target->LinkLanguagePropagatesToDependents() &&
dagCheckerParent && (dagCheckerParent->EvaluatingLinkLibraries()
|| dagCheckerParent->EvaluatingSources()))
{
@ -1100,7 +1100,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
"COMPILE_DEFINITIONS_"))
{
cmPolicies::PolicyStatus polSt =
context->LG->GetMakefile()->GetPolicyStatus(cmPolicies::CMP0043);
context->LG->GetPolicyStatus(cmPolicies::CMP0043);
if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD)
{
interfacePropertyName = "INTERFACE_COMPILE_DEFINITIONS";
@ -1442,7 +1442,7 @@ cmPolicies::PolicyStatus statusForTarget(cmGeneratorTarget const* tgt,
#define RETURN_POLICY(POLICY) \
if (strcmp(policy, #POLICY) == 0) \
{ \
return tgt->Target->GetPolicyStatus ## POLICY (); \
return tgt->GetPolicyStatus ## POLICY (); \
} \
CM_FOR_EACH_TARGET_POLICY(RETURN_POLICY)

View File

@ -796,7 +796,7 @@ std::set<cmLinkItem> const& cmGeneratorTarget::GetUtilityItems() const
if(!this->UtilityItemsDone)
{
this->UtilityItemsDone = true;
std::set<std::string> const& utilities = this->Target->GetUtilities();
std::set<std::string> const& utilities = this->GetUtilities();
for(std::set<std::string>::const_iterator i = utilities.begin();
i != utilities.end(); ++i)
{
@ -833,11 +833,34 @@ const char* cmGeneratorTarget::GetLocation(const std::string& config) const
return location.c_str();
}
std::vector<cmCustomCommand> const&
cmGeneratorTarget::GetPreBuildCommands() const
{
return this->Target->GetPreBuildCommands();
}
std::vector<cmCustomCommand> const&
cmGeneratorTarget::GetPreLinkCommands() const
{
return this->Target->GetPreLinkCommands();
}
std::vector<cmCustomCommand> const&
cmGeneratorTarget::GetPostBuildCommands() const
{
return this->Target->GetPostBuildCommands();
}
bool cmGeneratorTarget::IsImported() const
{
return this->Target->IsImported();
}
bool cmGeneratorTarget::IsImportedGloballyVisible() const
{
return this->Target->IsImportedGloballyVisible();
}
//----------------------------------------------------------------------------
const char* cmGeneratorTarget::GetLocationForBuild() const
{
@ -1623,7 +1646,7 @@ cmGeneratorTarget::GetFrameworkDirectory(const std::string& config,
if(!rootDir && !this->Makefile->PlatformIsAppleIos())
{
fpath += "/Versions/";
fpath += this->Target->GetFrameworkVersion();
fpath += this->GetFrameworkVersion();
}
return fpath;
}
@ -1714,6 +1737,22 @@ cmListFileBacktrace cmGeneratorTarget::GetBacktrace() const
return this->Target->GetBacktrace();
}
const std::vector<std::string>&cmGeneratorTarget::GetLinkDirectories() const
{
return this->Target->GetLinkDirectories();
}
const std::set<std::string>& cmGeneratorTarget::GetUtilities() const
{
return this->Target->GetUtilities();
}
const cmListFileBacktrace*
cmGeneratorTarget::GetUtilityBacktrace(const std::string& u) const
{
return this->Target->GetUtilityBacktrace(u);
}
//----------------------------------------------------------------------------
bool cmGeneratorTarget::HaveWellDefinedOutputFiles() const
{
@ -1759,7 +1798,7 @@ public:
UNORDERED_SET<std::string>& languages,
cmGeneratorTarget const* head):
Config(config), Languages(languages), HeadTarget(head),
Makefile(target->Target->GetMakefile()), Target(target)
Target(target)
{ this->Visited.insert(target); }
void Visit(cmLinkItem const& item)
@ -1771,7 +1810,8 @@ public:
bool noMessage = false;
cmake::MessageType messageType = cmake::FATAL_ERROR;
std::stringstream e;
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028))
switch(this->Target->GetLocalGenerator()
->GetPolicyStatus(cmPolicies::CMP0028))
{
case cmPolicies::WARN:
{
@ -1825,7 +1865,6 @@ private:
std::string Config;
UNORDERED_SET<std::string>& Languages;
cmGeneratorTarget const* HeadTarget;
cmMakefile* Makefile;
const cmGeneratorTarget* Target;
std::set<cmGeneratorTarget const*> Visited;
};
@ -2267,11 +2306,11 @@ cmTargetTraceDependencies
// Queue pre-build, pre-link, and post-build rule dependencies.
this->CheckCustomCommands(
this->GeneratorTarget->Target->GetPreBuildCommands());
this->GeneratorTarget->GetPreBuildCommands());
this->CheckCustomCommands(
this->GeneratorTarget->Target->GetPreLinkCommands());
this->GeneratorTarget->GetPreLinkCommands());
this->CheckCustomCommands(
this->GeneratorTarget->Target->GetPostBuildCommands());
this->GeneratorTarget->GetPostBuildCommands());
}
//----------------------------------------------------------------------------
@ -3313,7 +3352,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name,
if(!this->Makefile->PlatformIsAppleIos())
{
realName += "Versions/";
realName += this->Target->GetFrameworkVersion();
realName += this->GetFrameworkVersion();
realName += "/";
}
realName += base;
@ -4217,9 +4256,11 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
PropertyType *)
{
PropertyType propContent = getTypedProperty<PropertyType>(tgt, p);
const bool explicitlySet = tgt->Target->GetProperties()
.find(p)
!= tgt->Target->GetProperties().end();
std::vector<std::string> headPropKeys = tgt->GetPropertyKeys();
const bool explicitlySet =
std::find(headPropKeys.begin(), headPropKeys.end(),
p) != headPropKeys.end();
const bool impliedByUse =
tgt->IsNullImpliedByLinkLibraries(p);
assert((impliedByUse ^ explicitlySet)
@ -4264,9 +4305,11 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
cmGeneratorTarget const* theTarget = *li;
const bool ifaceIsSet = theTarget->Target->GetProperties()
.find(interfaceProperty)
!= theTarget->Target->GetProperties().end();
std::vector<std::string> propKeys = theTarget->GetPropertyKeys();
const bool ifaceIsSet =
std::find(propKeys.begin(), propKeys.end(),
interfaceProperty) != propKeys.end();
PropertyType ifacePropContent =
getTypedProperty<PropertyType>(theTarget,
interfaceProperty);
@ -4507,6 +4550,25 @@ void cmGeneratorTarget::GetTargetVersion(bool soversion,
}
}
//----------------------------------------------------------------------------
std::string cmGeneratorTarget::GetFrameworkVersion() const
{
assert(this->GetType() != cmState::INTERFACE_LIBRARY);
if(const char* fversion = this->GetProperty("FRAMEWORK_VERSION"))
{
return fversion;
}
else if(const char* tversion = this->GetProperty("VERSION"))
{
return tversion;
}
else
{
return "A";
}
}
//----------------------------------------------------------------------------
void cmGeneratorTarget::ComputeVersionedName(std::string& vName,
std::string const& prefix,
@ -4524,6 +4586,19 @@ void cmGeneratorTarget::ComputeVersionedName(std::string& vName,
vName += this->Makefile->IsOn("APPLE") ? suffix : std::string();
}
std::vector<std::string> cmGeneratorTarget::GetPropertyKeys() const
{
cmPropertyMap propsObject = this->Target->GetProperties();
std::vector<std::string> props;
props.reserve(propsObject.size());
for (cmPropertyMap::const_iterator it = propsObject.begin();
it != propsObject.end(); ++it)
{
props.push_back(it->first);
}
return props;
}
//----------------------------------------------------------------------------
void
cmGeneratorTarget::ReportPropertyOrigin(const std::string &p,
@ -4717,7 +4792,7 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config,
iface.WrongConfigLibraries = impl->WrongConfigLibraries;
}
if(this->Target->LinkLanguagePropagatesToDependents())
if(this->LinkLanguagePropagatesToDependents())
{
// Targets using this archive need its language runtime libraries.
if(cmLinkImplementation const* impl =
@ -5432,7 +5507,7 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
}
// Get the link languages.
if(this->Target->LinkLanguagePropagatesToDependents())
if(this->LinkLanguagePropagatesToDependents())
{
std::string linkProp = "IMPORTED_LINK_INTERFACE_LANGUAGES";
linkProp += suffix;
@ -5490,7 +5565,7 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const
}
std::string CONFIG = cmSystemTools::UpperCase(config);
cmOptionalLinkImplementation& impl = this->LinkImplMap[CONFIG][this->Target];
cmOptionalLinkImplementation& impl = this->LinkImplMap[CONFIG][this];
if(!impl.LibrariesDone)
{
impl.LibrariesDone = true;
@ -5770,7 +5845,7 @@ cmGeneratorTarget::GetLinkImplementationLibrariesInternal(
return &hm.begin()->second;
}
cmOptionalLinkImplementation& impl = hm[head->Target];
cmOptionalLinkImplementation& impl = hm[head];
if(!impl.LibrariesDone)
{
impl.LibrariesDone = true;

View File

@ -31,8 +31,13 @@ public:
cmLocalGenerator* GetLocalGenerator() const;
bool IsImported() const;
bool IsImportedGloballyVisible() const;
const char *GetLocation(const std::string& config) const;
std::vector<cmCustomCommand> const &GetPreBuildCommands() const;
std::vector<cmCustomCommand> const &GetPreLinkCommands() const;
std::vector<cmCustomCommand> const &GetPostBuildCommands() const;
#define DECLARE_TARGET_POLICY(POLICY) \
cmPolicies::PolicyStatus GetPolicyStatus ## POLICY () const \
{ return this->PolicyMap.Get(cmPolicies::POLICY); }
@ -53,6 +58,7 @@ public:
std::string GetName() const;
std::string GetExportName() const;
std::vector<std::string> GetPropertyKeys() const;
const char *GetProperty(const std::string& prop) const;
bool GetPropertyAsBool(const std::string& prop) const;
void GetSourceFiles(std::vector<cmSourceFile*>& files,
@ -161,6 +167,10 @@ public:
std::string GetFrameworkDirectory(const std::string& config,
bool rootDir) const;
/** Return the framework version string. Undefined if
IsFrameworkOnApple returns false. */
std::string GetFrameworkVersion() const;
/** @return the Mac CFBundle directory without the base */
std::string GetCFBundleDirectory(const std::string& config,
bool contentOnly) const;
@ -176,6 +186,14 @@ public:
cmListFileBacktrace GetBacktrace() const;
const std::vector<std::string>& GetLinkDirectories() const;
std::set<std::string>const& GetUtilities() const;
cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const;
bool LinkLanguagePropagatesToDependents() const
{ return this->GetType() == cmState::STATIC_LIBRARY; }
/** Get the macro to define when building sources in this target.
If no macro should be defined null is returned. */
const char* GetExportMacro() const;
@ -630,7 +648,7 @@ private:
const std::string& config) const;
struct HeadToLinkImplementationMap:
public std::map<cmTarget const*, cmOptionalLinkImplementation> {};
public std::map<cmGeneratorTarget const*, cmOptionalLinkImplementation> {};
typedef std::map<std::string,
HeadToLinkImplementationMap> LinkImplMapType;
mutable LinkImplMapType LinkImplMap;

View File

@ -392,10 +392,10 @@ void cmGhsMultiTargetGenerator::WriteTargetLinkLibraries()
void cmGhsMultiTargetGenerator::WriteCustomCommands()
{
WriteCustomCommandsHelper(
this->GeneratorTarget->Target->GetPreBuildCommands(),
this->GeneratorTarget->GetPreBuildCommands(),
cmTarget::PRE_BUILD);
WriteCustomCommandsHelper(
this->GeneratorTarget->Target->GetPostBuildCommands(),
this->GeneratorTarget->GetPostBuildCommands(),
cmTarget::POST_BUILD);
}

View File

@ -1208,8 +1208,6 @@ void cmGlobalGenerator::Configure()
void cmGlobalGenerator::CreateGenerationObjects(TargetTypes targetTypes)
{
this->CreateLocalGenerators();
cmDeleteAll(this->GeneratorTargets);
this->GeneratorTargets.clear();
this->CreateGeneratorTargets(targetTypes);
this->ComputeBuildFileGenerators();
}
@ -1583,10 +1581,12 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
}
//----------------------------------------------------------------------------
void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes,
cmLocalGenerator *lg)
void cmGlobalGenerator::CreateGeneratorTargets(
TargetTypes targetTypes,
cmMakefile *mf,
cmLocalGenerator *lg,
std::map<cmTarget*, cmGeneratorTarget*> const& importedMap)
{
cmMakefile* mf = lg->GetMakefile();
if (targetTypes == AllTargets)
{
cmTargets& targets = mf->GetTargets();
@ -1595,27 +1595,42 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes,
{
cmTarget* t = &ti->second;
cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg);
this->GeneratorTargets[t] = gt;
lg->AddGeneratorTarget(gt);
}
}
std::vector<cmTarget*> itgts = mf->GetImportedTargets();
for(std::vector<cmTarget*>::const_iterator
j = mf->GetOwnedImportedTargets().begin();
j != mf->GetOwnedImportedTargets().end(); ++j)
j = itgts.begin(); j != itgts.end(); ++j)
{
cmGeneratorTarget* gt = new cmGeneratorTarget(*j, lg);
this->GeneratorTargets[*j] = gt;
lg->AddImportedGeneratorTarget(importedMap.find(*j)->second);
}
}
//----------------------------------------------------------------------------
void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes)
{
std::map<cmTarget*, cmGeneratorTarget*> importedMap;
for(unsigned int i=0; i < this->Makefiles.size(); ++i)
{
cmMakefile* mf = this->Makefiles[i];
for(std::vector<cmTarget*>::const_iterator
j = mf->GetOwnedImportedTargets().begin();
j != mf->GetOwnedImportedTargets().end(); ++j)
{
cmLocalGenerator* lg = this->LocalGenerators[i];
cmGeneratorTarget* gt = new cmGeneratorTarget(*j, lg);
lg->AddOwnedImportedGeneratorTarget(gt);
importedMap[*j] = gt;
}
}
// Construct per-target generator information.
for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
{
this->CreateGeneratorTargets(targetTypes, this->LocalGenerators[i]);
this->CreateGeneratorTargets(targetTypes, this->Makefiles[i],
this->LocalGenerators[i], importedMap);
}
}
@ -1623,9 +1638,6 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes)
//----------------------------------------------------------------------------
void cmGlobalGenerator::ClearGeneratorMembers()
{
cmDeleteAll(this->GeneratorTargets);
this->GeneratorTargets.clear();
cmDeleteAll(this->BuildExportSets);
this->BuildExportSets.clear();
@ -1637,28 +1649,12 @@ void cmGlobalGenerator::ClearGeneratorMembers()
this->ExportSets.clear();
this->TargetDependencies.clear();
this->TotalTargets.clear();
this->ImportedTargets.clear();
this->ProjectMap.clear();
this->RuleHashes.clear();
this->DirectoryContentMap.clear();
this->BinaryDirectories.clear();
}
//----------------------------------------------------------------------------
cmGeneratorTarget*
cmGlobalGenerator::GetGeneratorTarget(cmTarget const* t) const
{
cmGeneratorTargetsType::const_iterator ti = this->GeneratorTargets.find(t);
if(ti == this->GeneratorTargets.end())
{
this->CMakeInstance->IssueMessage(
cmake::INTERNAL_ERROR, "Missing cmGeneratorTarget instance!");
return 0;
}
return ti->second;
}
//----------------------------------------------------------------------------
void cmGlobalGenerator::ComputeTargetObjectDirectory(cmGeneratorTarget*) const
{
@ -2169,9 +2165,10 @@ cmGlobalGenerator::FindLocalGenerator(const std::string& start_dir) const
}
//----------------------------------------------------------------------------
void cmGlobalGenerator::AddAlias(const std::string& name, cmTarget *tgt)
void cmGlobalGenerator::AddAlias(const std::string& name,
std::string const& tgtName)
{
this->AliasTargets[name] = tgt;
this->AliasTargets[name] = tgtName;
}
//----------------------------------------------------------------------------
@ -2180,6 +2177,79 @@ bool cmGlobalGenerator::IsAlias(const std::string& name) const
return this->AliasTargets.find(name) != this->AliasTargets.end();
}
cmTarget* cmGlobalGenerator::FindTargetImpl(std::string const& name) const
{
for (unsigned int i = 0; i < this->Makefiles.size(); ++i)
{
cmTargets& tgts = this->Makefiles[i]->GetTargets();
for (cmTargets::iterator it = tgts.begin(); it != tgts.end(); ++it)
{
if (it->second.GetName() == name)
{
return &it->second;
}
}
}
return 0;
}
cmGeneratorTarget*
cmGlobalGenerator::FindGeneratorTargetImpl(std::string const& name) const
{
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
{
std::vector<cmGeneratorTarget*> tgts =
this->LocalGenerators[i]->GetGeneratorTargets();
for (std::vector<cmGeneratorTarget*>::iterator it = tgts.begin();
it != tgts.end(); ++it)
{
if ((*it)->GetName() == name)
{
return *it;
}
}
}
return 0;
}
cmTarget*
cmGlobalGenerator::FindImportedTargetImpl(std::string const& name) const
{
for (unsigned int i = 0; i < this->Makefiles.size(); ++i)
{
std::vector<cmTarget*> tgts =
this->Makefiles[i]->GetOwnedImportedTargets();
for (std::vector<cmTarget*>::iterator it = tgts.begin();
it != tgts.end(); ++it)
{
if ((*it)->GetName() == name && (*it)->IsImportedGloballyVisible())
{
return *it;
}
}
}
return 0;
}
cmGeneratorTarget* cmGlobalGenerator::FindImportedGeneratorTargetImpl(
std::string const& name) const
{
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
{
std::vector<cmGeneratorTarget*> tgts =
this->LocalGenerators[i]->GetImportedGeneratorTargets();
for (std::vector<cmGeneratorTarget*>::iterator it = tgts.begin();
it != tgts.end(); ++it)
{
if ((*it)->IsImportedGloballyVisible() && (*it)->GetName() == name)
{
return *it;
}
}
}
return 0;
}
//----------------------------------------------------------------------------
cmTarget*
cmGlobalGenerator::FindTarget(const std::string& name,
@ -2187,23 +2257,28 @@ cmGlobalGenerator::FindTarget(const std::string& name,
{
if (!excludeAliases)
{
TargetMap::const_iterator ai = this->AliasTargets.find(name);
std::map<std::string, std::string>::const_iterator ai =
this->AliasTargets.find(name);
if (ai != this->AliasTargets.end())
{
return ai->second;
return this->FindTargetImpl(ai->second);
}
}
TargetMap::const_iterator i = this->TotalTargets.find ( name );
if ( i != this->TotalTargets.end() )
if (cmTarget* tgt = this->FindTargetImpl(name))
{
return i->second;
return tgt;
}
i = this->ImportedTargets.find(name);
if ( i != this->ImportedTargets.end() )
return this->FindImportedTargetImpl(name);
}
cmGeneratorTarget*
cmGlobalGenerator::FindGeneratorTarget(const std::string& name) const
{
if (cmGeneratorTarget* tgt = this->FindGeneratorTargetImpl(name))
{
return i->second;
return tgt;
}
return 0;
return this->FindImportedGeneratorTargetImpl(name);
}
//----------------------------------------------------------------------------
@ -2217,8 +2292,7 @@ cmGlobalGenerator::NameResolvesToFramework(const std::string& libname) const
if(cmTarget* tgt = this->FindTarget(libname))
{
cmGeneratorTarget* gt = this->GetGeneratorTarget(tgt);
if(gt->IsFrameworkOnApple())
if(tgt->IsFrameworkOnApple())
{
return true;
}
@ -2622,18 +2696,6 @@ cmGlobalGenerator::GetTargetDirectDepends(cmGeneratorTarget const* target)
return this->TargetDependencies[target];
}
void cmGlobalGenerator::AddTarget(cmTarget* t)
{
if(t->IsImported())
{
this->ImportedTargets[t->GetName()] = t;
}
else
{
this->TotalTargets[t->GetName()] = t;
}
}
bool cmGlobalGenerator::IsReservedTarget(std::string const& name)
{
// The following is a list of targets reserved
@ -2939,17 +3001,20 @@ void cmGlobalGenerator::WriteSummary()
fname += "/TargetDirectories.txt";
cmGeneratedFileStream fout(fname.c_str());
// Generate summary information files for each target.
for(TargetMap::const_iterator ti =
this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti)
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
{
if ((ti->second)->GetType() == cmState::INTERFACE_LIBRARY)
std::vector<cmGeneratorTarget*> tgts =
this->LocalGenerators[i]->GetGeneratorTargets();
for (std::vector<cmGeneratorTarget*>::iterator it = tgts.begin();
it != tgts.end(); ++it)
{
continue;
if ((*it)->GetType() == cmState::INTERFACE_LIBRARY)
{
continue;
}
this->WriteSummary(*it);
fout << (*it)->GetSupportDirectory() << "\n";
}
cmGeneratorTarget* gt = this->GetGeneratorTarget(ti->second);
this->WriteSummary(gt);
fout << gt->GetSupportDirectory() << "\n";
}
}

View File

@ -42,10 +42,6 @@ class cmInstallTargetGenerator;
class cmInstallFilesGenerator;
class cmExportBuildFileGenerator;
typedef std::map<cmTarget const*,
cmGeneratorTarget*,
cmTarget::StrictTargetComparison> cmGeneratorTargetsType;
/** \class cmGlobalGenerator
* \brief Responsible for overseeing the generation process for the entire tree
*
@ -254,7 +250,9 @@ public:
cmTarget* FindTarget(const std::string& name,
bool excludeAliases = false) const;
void AddAlias(const std::string& name, cmTarget *tgt);
cmGeneratorTarget* FindGeneratorTarget(const std::string& name) const;
void AddAlias(const std::string& name, const std::string& tgtName);
bool IsAlias(const std::string& name) const;
/** Determine if a name resolves to a framework on disk or a built target
@ -280,8 +278,6 @@ public:
std::set<std::string> const& GetDirectoryContent(std::string const& dir,
bool needDisk = true);
void AddTarget(cmTarget* t);
static bool IsReservedTarget(std::string const& name);
virtual const char* GetAllTargetName() const { return "ALL_BUILD"; }
@ -307,14 +303,6 @@ public:
TargetDependSet const& GetTargetDirectDepends(
const cmGeneratorTarget* target);
/** Get per-target generator information. */
cmGeneratorTarget* GetGeneratorTarget(cmTarget const*) const;
void AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt)
{
this->GeneratorTargets[t] = gt;
}
const std::map<std::string, std::vector<cmLocalGenerator*> >& GetProjectMap()
const {return this->ProjectMap;}
@ -429,19 +417,14 @@ protected:
std::map<std::string, cmExportBuildFileGenerator*> BuildExportSets;
std::map<std::string, cmExportBuildFileGenerator*> BuildExportExportSets;
// All targets in the entire project.
#if defined(CMAKE_BUILD_WITH_CMAKE)
#ifdef CMake_HAVE_CXX11_UNORDERED_MAP
typedef std::unordered_map<std::string, cmTarget*> TargetMap;
#else
typedef cmsys::hash_map<std::string, cmTarget*> TargetMap;
#endif
#else
typedef std::map<std::string,cmTarget *> TargetMap;
#endif
TargetMap TotalTargets;
TargetMap AliasTargets;
TargetMap ImportedTargets;
std::map<std::string, std::string> AliasTargets;
cmTarget* FindTargetImpl(std::string const& name) const;
cmTarget* FindImportedTargetImpl(std::string const& name) const;
cmGeneratorTarget* FindGeneratorTargetImpl(std::string const& name) const;
cmGeneratorTarget*
FindImportedGeneratorTargetImpl(std::string const& name) const;
const char* GetPredefinedTargetsFolder();
virtual bool UseFolderProperty();
@ -487,10 +470,10 @@ private:
typedef std::map<cmGeneratorTarget const*, TargetDependSet> TargetDependMap;
TargetDependMap TargetDependencies;
// Per-target generator information.
cmGeneratorTargetsType GeneratorTargets;
friend class cmake;
void CreateGeneratorTargets(TargetTypes targetTypes, cmLocalGenerator* lg);
void CreateGeneratorTargets(TargetTypes targetTypes, cmMakefile* mf,
cmLocalGenerator* lg,
std::map<cmTarget*, cmGeneratorTarget*> const& importedMap);
void CreateGeneratorTargets(TargetTypes targetTypes);
void ClearGeneratorMembers();

View File

@ -105,6 +105,9 @@ bool cmGlobalKdevelopGenerator
std::set<std::string> files;
std::string tmp;
std::vector<std::string> hdrExts =
this->GlobalGenerator->GetCMakeInstance()->GetHeaderExtensions();
for (std::vector<cmLocalGenerator*>::const_iterator it=lgs.begin();
it!=lgs.end(); it++)
{
@ -160,8 +163,7 @@ bool cmGlobalKdevelopGenerator
// check if there's a matching header around
for(std::vector<std::string>::const_iterator
ext = makefile->GetHeaderExtensions().begin();
ext != makefile->GetHeaderExtensions().end(); ++ext)
ext = hdrExts.begin(); ext != hdrExts.end(); ++ext)
{
std::string hname=headerBasename;
hname += ".";

View File

@ -965,7 +965,7 @@ cmGlobalNinjaGenerator
if (target->GetType() == cmState::GLOBAL_TARGET) {
// Global targets only depend on other utilities, which may not appear in
// the TargetDepends set (e.g. "all").
std::set<std::string> const& utils = target->Target->GetUtilities();
std::set<std::string> const& utils = target->GetUtilities();
std::copy(utils.begin(), utils.end(), std::back_inserter(outputs));
} else {
cmTargetDependSet const& targetDeps = this->GetTargetDirectDepends(target);

View File

@ -523,7 +523,7 @@ cmGlobalUnixMakefileGenerator3
cmLocalUnixMakefileGenerator3* lg)
{
// Only subdirectories need these rules.
if(lg->GetMakefile()->IsRootMakefile())
if(lg->IsRootMakefile())
{
return;
}
@ -1084,7 +1084,7 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule
static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[i]);
// for the passed in makefile or if this is the top Makefile wripte out
// the targets
if (lg2 == lg || lg->GetMakefile()->IsRootMakefile())
if (lg2 == lg || lg->IsRootMakefile())
{
// for each target Generate the rule files for each target.
std::vector<cmGeneratorTarget*> targets = lg2->GetGeneratorTargets();

View File

@ -235,7 +235,7 @@ void cmGlobalVisualStudio6Generator
std::string project = target->GetName();
std::string location = expath;
this->WriteExternalProject(fout, project.c_str(),
location.c_str(), target->Target->GetUtilities());
location.c_str(), target->GetUtilities());
}
else
{

View File

@ -401,7 +401,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
for(OrderedTargetDependSet::const_iterator tt =
projectTargets.begin(); tt != projectTargets.end(); ++tt)
{
cmTarget const* target = (*tt)->Target;
cmGeneratorTarget const* target = *tt;
if(target->GetType() == cmState::INTERFACE_LIBRARY)
{
continue;
@ -459,7 +459,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
project.c_str(),
location.c_str(),
target->GetProperty("VS_PROJECT_TYPE"),
target->Target->GetUtilities());
target->GetUtilities());
written = true;
}
else
@ -996,7 +996,8 @@ cmGlobalVisualStudio7Generator
std::set<std::string>
cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
std::vector<std::string> const& configs,
OrderedTargetDependSet const& projectTargets, cmTarget const* target)
OrderedTargetDependSet const& projectTargets,
cmGeneratorTarget const* target)
{
std::set<std::string> activeConfigs;
// if it is a utilitiy target then only make it part of the
@ -1011,13 +1012,13 @@ cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
for(std::vector<std::string>::const_iterator i = configs.begin();
i != configs.end(); ++i)
{
const char* propertyValue = target->GetMakefile()
const char* propertyValue = target->Target->GetMakefile()
->GetDefinition("CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD");
cmGeneratorExpression ge;
cmsys::auto_ptr<cmCompiledGeneratorExpression>
cge = ge.Parse(propertyValue);
cmGeneratorTarget* gt = this->GetGeneratorTarget(target);
if(cmSystemTools::IsOn(cge->Evaluate(gt->GetLocalGenerator(), *i)))
if(cmSystemTools::IsOn(cge->Evaluate(target->GetLocalGenerator(),
*i)))
{
activeConfigs.insert(*i);
}
@ -1029,13 +1030,12 @@ cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
{
return activeConfigs;
}
cmGeneratorTarget* gt = this->GetGeneratorTarget(target);
// inspect EXCLUDE_FROM_DEFAULT_BUILD[_<CONFIG>] properties
for(std::vector<std::string>::const_iterator i = configs.begin();
i != configs.end(); ++i)
{
const char* propertyValue =
gt->GetFeature("EXCLUDE_FROM_DEFAULT_BUILD", i->c_str());
target->GetFeature("EXCLUDE_FROM_DEFAULT_BUILD", i->c_str());
if(cmSystemTools::IsOff(propertyValue))
{
activeConfigs.insert(*i);
@ -1047,9 +1047,8 @@ cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
bool
cmGlobalVisualStudio7Generator
::IsDependedOn(OrderedTargetDependSet const& projectTargets,
cmTarget const* targetIn)
cmGeneratorTarget const* gtIn)
{
cmGeneratorTarget* gtIn = this->GetGeneratorTarget(targetIn);
for (OrderedTargetDependSet::const_iterator l = projectTargets.begin();
l != projectTargets.end(); ++l)
{

View File

@ -163,9 +163,9 @@ protected:
std::set<std::string>
IsPartOfDefaultBuild(std::vector<std::string> const& configs,
OrderedTargetDependSet const& projectTargets,
cmTarget const* target);
cmGeneratorTarget const* target);
bool IsDependedOn(OrderedTargetDependSet const& projectTargets,
cmTarget const* target);
cmGeneratorTarget const* target);
std::map<std::string, std::string> GUIDMap;
virtual void WriteFolders(std::ostream& fout);

View File

@ -257,7 +257,6 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg);
lg->AddGeneratorTarget(gt);
this->AddGeneratorTarget(tgt, gt);
// Organize in the "predefined targets" folder:
//
@ -354,14 +353,18 @@ void cmGlobalVisualStudio8Generator::AddExtraIDETargets()
cmGlobalVisualStudio7Generator::AddExtraIDETargets();
if(this->AddCheckTarget())
{
// All targets depend on the build-system check target.
for(TargetMap::const_iterator
ti = this->TotalTargets.begin();
ti != this->TotalTargets.end(); ++ti)
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
{
if(ti->first != CMAKE_CHECK_BUILD_SYSTEM_TARGET)
std::vector<cmGeneratorTarget*> tgts =
this->LocalGenerators[i]->GetGeneratorTargets();
// All targets depend on the build-system check target.
for(std::vector<cmGeneratorTarget*>::iterator ti = tgts.begin();
ti != tgts.end(); ++ti)
{
ti->second->AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET);
if((*ti)->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET)
{
(*ti)->Target->AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET);
}
}
}
}
@ -464,8 +467,8 @@ bool cmGlobalVisualStudio8Generator::NeedLinkLibraryDependencies(
{
// Look for utility dependencies that magically link.
for(std::set<std::string>::const_iterator ui =
target->Target->GetUtilities().begin();
ui != target->Target->GetUtilities().end(); ++ui)
target->GetUtilities().begin();
ui != target->GetUtilities().end(); ++ui)
{
if(cmGeneratorTarget* depTarget =
target->GetLocalGenerator()->FindGeneratorTargetToUse(ui->c_str()))

View File

@ -88,7 +88,6 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets()
cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]);
gen[0]->AddGeneratorTarget(gt);
this->AddGeneratorTarget(allBuild, gt);
#if 0
// Can't activate this code because we want ALL_BUILD

View File

@ -460,7 +460,6 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root);
root->AddGeneratorTarget(allBuildGt);
root->GetGlobalGenerator()->AddGeneratorTarget(allbuild, allBuildGt);
// Refer to the main build configuration file for easy editing.
std::string listfile = root->GetCurrentSourceDirectory();
@ -496,7 +495,6 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root);
root->AddGeneratorTarget(checkGt);
root->GetGlobalGenerator()->AddGeneratorTarget(check, checkGt);
}
// now make the allbuild depend on all the non-utility targets
@ -1362,12 +1360,17 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
//----------------------------------------------------------------------------
void cmGlobalXCodeGenerator::ForceLinkerLanguages()
{
// This makes sure all targets link using the proper language.
for(TargetMap::const_iterator
ti = this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti)
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
{
cmGeneratorTarget* gt = this->GetGeneratorTarget(ti->second);
this->ForceLinkerLanguage(gt);
std::vector<cmGeneratorTarget*> tgts =
this->LocalGenerators[i]->GetGeneratorTargets();
// All targets depend on the build-system check target.
for(std::vector<cmGeneratorTarget*>::const_iterator ti = tgts.begin();
ti != tgts.end(); ++ti)
{
// This makes sure all targets link using the proper language.
this->ForceLinkerLanguage(*ti);
}
}
}
@ -1420,7 +1423,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt)
bool cmGlobalXCodeGenerator::IsHeaderFile(cmSourceFile* sf)
{
const std::vector<std::string>& hdrExts =
this->CurrentMakefile->GetHeaderExtensions();
this->CMakeInstance->GetHeaderExtensions();
return (std::find(hdrExts.begin(), hdrExts.end(), sf->GetExtension()) !=
hdrExts.end());
}
@ -1469,11 +1472,11 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases,
cmGeneratorTarget* gtgt)
{
std::vector<cmCustomCommand> const & prebuild
= gtgt->Target->GetPreBuildCommands();
= gtgt->GetPreBuildCommands();
std::vector<cmCustomCommand> const & prelink
= gtgt->Target->GetPreLinkCommands();
= gtgt->GetPreLinkCommands();
std::vector<cmCustomCommand> postbuild
= gtgt->Target->GetPostBuildCommands();
= gtgt->GetPostBuildCommands();
if(gtgt->GetType() == cmState::SHARED_LIBRARY &&
!gtgt->IsFrameworkOnApple())
@ -2141,7 +2144,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
{
if(gtgt->GetPropertyAsBool("FRAMEWORK"))
{
std::string fw_version = gtgt->Target->GetFrameworkVersion();
std::string fw_version = gtgt->GetFrameworkVersion();
buildSettings->AddAttribute("FRAMEWORK_VERSION",
this->CreateString(fw_version.c_str()));
@ -2486,13 +2489,13 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
// put this last so it can override existing settings
// Convert "XCODE_ATTRIBUTE_*" properties directly.
{
cmPropertyMap const& props = gtgt->Target->GetProperties();
for(cmPropertyMap::const_iterator i = props.begin();
std::vector<std::string> const& props = gtgt->GetPropertyKeys();
for(std::vector<std::string>::const_iterator i = props.begin();
i != props.end(); ++i)
{
if(i->first.find("XCODE_ATTRIBUTE_") == 0)
if(i->find("XCODE_ATTRIBUTE_") == 0)
{
std::string attribute = i->first.substr(16);
std::string attribute = i->substr(16);
// Handle [variant=<config>] condition explicitly here.
std::string::size_type beginVariant =
attribute.find("[variant=");
@ -2523,7 +2526,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
if (!attribute.empty())
{
cmGeneratorExpression ge;
std::string processed = ge.Parse(i->second.GetValue())
std::string processed = ge.Parse(gtgt->GetProperty(*i))
->Evaluate(this->CurrentLocalGenerator, configName);
buildSettings->AddAttribute(attribute.c_str(),
this->CreateString(processed));

View File

@ -51,6 +51,8 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg,
this->Makefile = makefile;
this->AliasTargets = makefile->GetAliasTargets();
this->EmitUniversalBinaryFlags = true;
this->BackwardsCompatibility = 0;
this->BackwardsCompatibilityFinal = false;
@ -60,6 +62,8 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg,
cmLocalGenerator::~cmLocalGenerator()
{
cmDeleteAll(this->GeneratorTargets);
cmDeleteAll(this->OwnedImportedGeneratorTargets);
}
void cmLocalGenerator::IssueMessage(cmake::MessageType t,
@ -453,11 +457,55 @@ void cmLocalGenerator::AddGeneratorTarget(cmGeneratorTarget* gt)
this->GeneratorTargets.push_back(gt);
}
void cmLocalGenerator::AddImportedGeneratorTarget(cmGeneratorTarget* gt)
{
this->ImportedGeneratorTargets.push_back(gt);
}
void cmLocalGenerator::AddOwnedImportedGeneratorTarget(cmGeneratorTarget* gt)
{
this->OwnedImportedGeneratorTargets.push_back(gt);
}
struct NamedGeneratorTargetFinder
{
NamedGeneratorTargetFinder(std::string const& name)
: Name(name)
{
}
bool operator()(cmGeneratorTarget* tgt)
{
return tgt->GetName() == this->Name;
}
private:
std::string Name;
};
cmGeneratorTarget* cmLocalGenerator::FindGeneratorTarget(
const std::string& name) const
{
return this->GetGlobalGenerator()->GetGeneratorTarget(
this->Makefile->FindTarget(name));
std::map<std::string, std::string>::const_iterator i =
this->AliasTargets.find(name);
if (i != this->AliasTargets.end())
{
std::vector<cmGeneratorTarget*>::const_iterator ai =
std::find_if(this->GeneratorTargets.begin(),
this->GeneratorTargets.end(),
NamedGeneratorTargetFinder(i->second));
return *ai;
}
std::vector<cmGeneratorTarget*>::const_iterator ti =
std::find_if(this->GeneratorTargets.begin(),
this->GeneratorTargets.end(),
NamedGeneratorTargetFinder(name));
if ( ti != this->GeneratorTargets.end() )
{
return *ti;
}
return 0;
}
//----------------------------------------------------------------------------
@ -490,6 +538,11 @@ void cmLocalGenerator::ComputeTargetManifest()
}
}
bool cmLocalGenerator::IsRootMakefile() const
{
return !this->StateSnapshot.GetBuildsystemDirectoryParent().IsValid();
}
cmState* cmLocalGenerator::GetState() const
{
return this->GlobalGenerator->GetCMakeInstance()->GetState();
@ -1775,11 +1828,21 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
cmGeneratorTarget*
cmLocalGenerator::FindGeneratorTargetToUse(const std::string& name) const
{
if (cmTarget *t = this->Makefile->FindTargetToUse(name))
std::vector<cmGeneratorTarget*>::const_iterator
imported = std::find_if(this->ImportedGeneratorTargets.begin(),
this->ImportedGeneratorTargets.end(),
NamedGeneratorTargetFinder(name));
if(imported != this->ImportedGeneratorTargets.end())
{
return this->GetGlobalGenerator()->GetGeneratorTarget(t);
return *imported;
}
return 0;
if(cmGeneratorTarget* t = this->FindGeneratorTarget(name))
{
return t;
}
return this->GetGlobalGenerator()->FindGeneratorTarget(name);
}
//----------------------------------------------------------------------------
@ -2028,7 +2091,7 @@ AddCompilerRequirementFlag(std::string &flags,
}
static void AddVisibilityCompileOption(std::string &flags,
cmTarget const* target,
cmGeneratorTarget const* target,
cmLocalGenerator *lg,
const std::string& lang,
std::string* warnCMP0063)
@ -2068,7 +2131,7 @@ static void AddVisibilityCompileOption(std::string &flags,
}
static void AddInlineVisibilityCompileOption(std::string &flags,
cmTarget const* target,
cmGeneratorTarget const* target,
cmLocalGenerator *lg,
std::string* warnCMP0063)
{
@ -2121,12 +2184,11 @@ void cmLocalGenerator
}
}
AddVisibilityCompileOption(flags, target->Target, this, lang, pWarnCMP0063);
AddVisibilityCompileOption(flags, target, this, lang, pWarnCMP0063);
if(lang == "CXX")
{
AddInlineVisibilityCompileOption(flags, target->Target,
this, pWarnCMP0063);
AddInlineVisibilityCompileOption(flags, target, this, pWarnCMP0063);
}
if (!warnCMP0063.empty() &&
@ -2201,7 +2263,7 @@ bool cmLocalGenerator::GetShouldUseOldFlags(bool shared,
if (flags && flags != originalFlags)
{
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0018))
switch (this->GetPolicyStatus(cmPolicies::CMP0018))
{
case cmPolicies::WARN:
{
@ -2949,7 +3011,7 @@ bool cmLocalGenerator::NeedBackwardsCompatibility_2_4()
{
// Check the policy to decide whether to pay attention to this
// variable.
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0001))
switch(this->GetPolicyStatus(cmPolicies::CMP0001))
{
case cmPolicies::WARN:
// WARN is just OLD without warning because user code does not
@ -2976,6 +3038,12 @@ bool cmLocalGenerator::NeedBackwardsCompatibility_2_4()
actual_compat <= CMake_VERSION_ENCODE(2, 4, 255));
}
cmPolicies::PolicyStatus
cmLocalGenerator::GetPolicyStatus(cmPolicies::PolicyID id) const
{
return this->Makefile->GetPolicyStatus(id);
}
//----------------------------------------------------------------------------
bool cmLocalGenerator::CheckDefinition(std::string const& define) const
{

View File

@ -67,6 +67,8 @@ public:
*/
void ComputeTargetManifest();
bool IsRootMakefile() const;
///! Get the makefile for this generator
cmMakefile *GetMakefile() {
return this->Makefile; }
@ -118,7 +120,14 @@ public:
return this->GeneratorTargets;
}
const std::vector<cmGeneratorTarget*> &GetImportedGeneratorTargets() const
{
return this->ImportedGeneratorTargets;
}
void AddGeneratorTarget(cmGeneratorTarget* gt);
void AddImportedGeneratorTarget(cmGeneratorTarget* gt);
void AddOwnedImportedGeneratorTarget(cmGeneratorTarget* gt);
cmGeneratorTarget* FindGeneratorTarget(const std::string& name) const;
cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const;
@ -265,6 +274,8 @@ public:
*/
bool NeedBackwardsCompatibility_2_4();
cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id) const;
cmake* GetCMakeInstance() const;
const char* GetSourceDirectory() const;
@ -369,6 +380,9 @@ protected:
std::set<cmGeneratorTarget const*> WarnCMP0063;
std::vector<cmGeneratorTarget*> GeneratorTargets;
std::vector<cmGeneratorTarget*> ImportedGeneratorTargets;
std::vector<cmGeneratorTarget*> OwnedImportedGeneratorTargets;
std::map<std::string, std::string> AliasTargets;
bool EmitUniversalBinaryFlags;

View File

@ -56,7 +56,7 @@ void cmLocalNinjaGenerator::Generate()
#endif
// We do that only once for the top CMakeLists.txt file.
if(this->Makefile->IsRootMakefile())
if(this->IsRootMakefile())
{
this->WriteBuildFileTop();
@ -277,7 +277,7 @@ void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os)
<< "# Write statements declared in CMakeLists.txt:" << std::endl
<< "# "
<< this->Makefile->GetDefinition("CMAKE_CURRENT_LIST_FILE") << std::endl;
if(this->Makefile->IsRootMakefile())
if(this->IsRootMakefile())
os << "# Which is the root file." << std::endl;
cmGlobalNinjaGenerator::WriteDivider(os);
os << std::endl;

View File

@ -254,7 +254,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
return;
}
// always write the top makefile
if (!this->GetMakefile()->IsRootMakefile())
if (!this->IsRootMakefile())
{
ruleFileStream.SetCopyIfDifferent(true);
}
@ -265,7 +265,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
// only write local targets unless at the top Keep track of targets already
// listed.
std::set<std::string> emittedTargets;
if (!this->GetMakefile()->IsRootMakefile())
if (!this->IsRootMakefile())
{
// write our targets, and while doing it collect up the object
// file rules
@ -880,7 +880,7 @@ void cmLocalUnixMakefileGenerator3
std::vector<std::string> no_depends;
std::vector<std::string> commands;
commands.push_back(runRule);
if(!this->GetMakefile()->IsRootMakefile())
if(!this->IsRootMakefile())
{
this->CreateCDCommand(commands,
this->GetBinaryDirectory(),
@ -1778,8 +1778,8 @@ void cmLocalUnixMakefileGenerator3
{
text = "Running external command ...";
}
depends.insert(depends.end(), (*glIt)->Target->GetUtilities().begin(),
(*glIt)->Target->GetUtilities().end());
depends.insert(depends.end(), (*glIt)->GetUtilities().begin(),
(*glIt)->GetUtilities().end());
this->AppendEcho(commands, text,
cmLocalUnixMakefileGenerator3::EchoGlobal);
@ -1787,15 +1787,15 @@ void cmLocalUnixMakefileGenerator3
// Global targets store their rules in pre- and post-build commands.
this->AppendCustomDepends(depends,
gt->Target->GetPreBuildCommands());
gt->GetPreBuildCommands());
this->AppendCustomDepends(depends,
gt->Target->GetPostBuildCommands());
gt->GetPostBuildCommands());
this->AppendCustomCommands(commands,
gt->Target->GetPreBuildCommands(),
gt->GetPreBuildCommands(),
gt,
cmLocalGenerator::START_OUTPUT);
this->AppendCustomCommands(commands,
gt->Target->GetPostBuildCommands(),
gt->GetPostBuildCommands(),
gt,
cmLocalGenerator::START_OUTPUT);
std::string targetName = gt->GetName();

View File

@ -266,21 +266,21 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
// depend only on the previous rule.
if ((target->GetType() == cmState::UTILITY ||
target->GetType() == cmState::GLOBAL_TARGET) &&
(!target->Target->GetPreBuildCommands().empty() ||
!target->Target->GetPostBuildCommands().empty()))
(!target->GetPreBuildCommands().empty() ||
!target->GetPostBuildCommands().empty()))
{
// Accumulate the dependencies of all the commands.
std::vector<std::string> depends;
for (std::vector<cmCustomCommand>::const_iterator cr =
target->Target->GetPreBuildCommands().begin();
cr != target->Target->GetPreBuildCommands().end(); ++cr)
target->GetPreBuildCommands().begin();
cr != target->GetPreBuildCommands().end(); ++cr)
{
depends.insert(depends.end(),
cr->GetDepends().begin(), cr->GetDepends().end());
}
for (std::vector<cmCustomCommand>::const_iterator cr =
target->Target->GetPostBuildCommands().begin();
cr != target->Target->GetPostBuildCommands().end(); ++cr)
target->GetPostBuildCommands().begin();
cr != target->GetPostBuildCommands().end(); ++cr)
{
depends.insert(depends.end(),
cr->GetDepends().begin(), cr->GetDepends().end());
@ -289,14 +289,14 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
// Add the pre- and post-build commands in order.
int count = 1;
for (std::vector<cmCustomCommand>::const_iterator cr =
target->Target->GetPreBuildCommands().begin();
cr != target->Target->GetPreBuildCommands().end(); ++cr)
target->GetPreBuildCommands().begin();
cr != target->GetPreBuildCommands().end(); ++cr)
{
this->AddUtilityCommandHack(target, count++, depends, *cr);
}
for (std::vector<cmCustomCommand>::const_iterator cr =
target->Target->GetPostBuildCommands().begin();
cr != target->Target->GetPostBuildCommands().end(); ++cr)
target->GetPostBuildCommands().begin();
cr != target->GetPostBuildCommands().end(); ++cr)
{
this->AddUtilityCommandHack(target, count++, depends, *cr);
}
@ -838,8 +838,8 @@ cmLocalVisualStudio6Generator::CreateTargetRules(cmGeneratorTarget *target,
// Write the pre-build and pre-link together (VS6 does not support both).
event.Start("PreLink");
event.Write(target->Target->GetPreBuildCommands());
event.Write(target->Target->GetPreLinkCommands());
event.Write(target->GetPreBuildCommands());
event.Write(target->GetPreLinkCommands());
cmsys::auto_ptr<cmCustomCommand> pcc(
this->MaybeCreateImplibDir(target, configName, false));
if(pcc.get())
@ -855,7 +855,7 @@ cmLocalVisualStudio6Generator::CreateTargetRules(cmGeneratorTarget *target,
// Write the post-build rules.
event.Start("PostBuild");
event.Write(target->Target->GetPostBuildCommands());
event.Write(target->GetPostBuildCommands());
event.Finish();
customRuleCode += "# End Special Build Tool\n";
@ -1052,7 +1052,7 @@ void cmLocalVisualStudio6Generator
}
std::vector<std::string>::const_iterator i;
const std::vector<std::string>& libdirs =
target->Target->GetLinkDirectories();
target->GetLinkDirectories();
for(i = libdirs.begin(); i != libdirs.end(); ++i)
{
std::string path = *i;
@ -1112,15 +1112,14 @@ void cmLocalVisualStudio6Generator
// Compute the proper name to use to link this library.
std::string lib;
std::string libDebug;
cmTarget* tgt = this->GlobalGenerator->FindTarget(j->first.c_str());
cmGeneratorTarget* tgt =
this->GlobalGenerator->FindGeneratorTarget(j->first.c_str());
if(tgt)
{
cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(tgt);
lib = cmSystemTools::GetFilenameWithoutExtension
(gt->GetFullName().c_str());
(tgt->GetFullName().c_str());
libDebug = cmSystemTools::GetFilenameWithoutExtension
(gt->GetFullName("Debug").c_str());
(tgt->GetFullName("Debug").c_str());
lib += ".lib";
libDebug += ".lib";
}

View File

@ -783,10 +783,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
intermediateDir += "/";
intermediateDir += configName;
if (target->Target->GetType() < cmState::UTILITY)
if (target->GetType() < cmState::UTILITY)
{
std::string const& outDir =
target->Target->GetType() == cmState::OBJECT_LIBRARY?
target->GetType() == cmState::OBJECT_LIBRARY?
intermediateDir : target->GetDirectory(configName);
fout << "\t\t\tOutputDirectory=\""
<< this->ConvertToXMLOutputPathSingle(outDir.c_str()) << "\"\n";
@ -837,7 +837,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
if(this->FortranProject)
{
const char* target_mod_dir =
target->Target->GetProperty("Fortran_MODULE_DIRECTORY");
target->GetProperty("Fortran_MODULE_DIRECTORY");
std::string modDir;
if(target_mod_dir)
{
@ -877,7 +877,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
targetOptions.OutputFlagMap(fout, "\t\t\t\t");
targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n", "CXX");
fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n";
if(target->Target->GetType() <= cmState::OBJECT_LIBRARY)
if(target->GetType() <= cmState::OBJECT_LIBRARY)
{
// Specify the compiler program database file if configured.
std::string pdb = target->GetCompilePDBPath(configName);
@ -2021,7 +2021,7 @@ void cmLocalVisualStudio7Generator
const char* tool =
this->FortranProject? "VFPreBuildEventTool":"VCPreBuildEventTool";
event.Start(tool);
event.Write(target->Target->GetPreBuildCommands());
event.Write(target->GetPreBuildCommands());
event.Finish();
// Add pre-link event.
@ -2035,7 +2035,7 @@ void cmLocalVisualStudio7Generator
{
addedPrelink = true;
std::vector<cmCustomCommand> commands =
target->Target->GetPreLinkCommands();
target->GetPreLinkCommands();
cmGlobalVisualStudioGenerator* gg
= static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator);
gg->AddSymbolExportCommand(
@ -2045,7 +2045,7 @@ void cmLocalVisualStudio7Generator
}
if (!addedPrelink)
{
event.Write(target->Target->GetPreLinkCommands());
event.Write(target->GetPreLinkCommands());
}
cmsys::auto_ptr<cmCustomCommand> pcc(
this->MaybeCreateImplibDir(target,
@ -2059,7 +2059,7 @@ void cmLocalVisualStudio7Generator
// Add post-build event.
tool = this->FortranProject? "VFPostBuildEventTool":"VCPostBuildEventTool";
event.Start(tool);
event.Write(target->Target->GetPostBuildCommands());
event.Write(target->GetPostBuildCommands());
event.Finish();
}
@ -2219,17 +2219,18 @@ void cmLocalVisualStudio7Generator::WriteVCProjFooter(
{
fout << "\t<Globals>\n";
cmPropertyMap const& props = target->Target->GetProperties();
for(cmPropertyMap::const_iterator i = props.begin(); i != props.end(); ++i)
std::vector<std::string> const& props = target->GetPropertyKeys();
for(std::vector<std::string>::const_iterator i = props.begin();
i != props.end(); ++i)
{
if(i->first.find("VS_GLOBAL_") == 0)
if(i->find("VS_GLOBAL_") == 0)
{
std::string name = i->first.substr(10);
std::string name = i->substr(10);
if(name != "")
{
fout << "\t\t<Global\n"
<< "\t\t\tName=\"" << name << "\"\n"
<< "\t\t\tValue=\"" << i->second.GetValue() << "\"\n"
<< "\t\t\tValue=\"" << target->GetProperty(*i) << "\"\n"
<< "\t\t/>\n";
}
}

View File

@ -51,13 +51,11 @@ void cmLocalXCodeGenerator::Generate()
{
cmLocalGenerator::Generate();
cmTargets& targets = this->Makefile->GetTargets();
for(cmTargets::iterator iter = targets.begin();
std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
for(std::vector<cmGeneratorTarget*>::iterator iter = targets.begin();
iter != targets.end(); ++iter)
{
cmTarget* t = &iter->second;
cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(t);
gt->HasMacOSXRpathInstallNameDir("");
(*iter)->HasMacOSXRpathInstallNameDir("");
}
}
@ -66,13 +64,11 @@ void cmLocalXCodeGenerator::GenerateInstallRules()
{
cmLocalGenerator::GenerateInstallRules();
cmTargets& targets = this->Makefile->GetTargets();
for(cmTargets::iterator iter = targets.begin();
std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
for(std::vector<cmGeneratorTarget*>::iterator iter = targets.begin();
iter != targets.end(); ++iter)
{
cmTarget* t = &iter->second;
cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(t);
gt->HasMacOSXRpathInstallNameDir("");
(*iter)->HasMacOSXRpathInstallNameDir("");
}
}

View File

@ -57,31 +57,6 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
// Setup the default include complaint regular expression (match nothing).
this->ComplainFileRegularExpression = "^$";
// Source and header file extensions that we can handle
// Set up a list of source and header extensions
// these are used to find files when the extension
// is not given
// The "c" extension MUST precede the "C" extension.
this->SourceFileExtensions.push_back( "c" );
this->SourceFileExtensions.push_back( "C" );
this->SourceFileExtensions.push_back( "c++" );
this->SourceFileExtensions.push_back( "cc" );
this->SourceFileExtensions.push_back( "cpp" );
this->SourceFileExtensions.push_back( "cxx" );
this->SourceFileExtensions.push_back( "m" );
this->SourceFileExtensions.push_back( "M" );
this->SourceFileExtensions.push_back( "mm" );
this->HeaderFileExtensions.push_back( "h" );
this->HeaderFileExtensions.push_back( "hh" );
this->HeaderFileExtensions.push_back( "h++" );
this->HeaderFileExtensions.push_back( "hm" );
this->HeaderFileExtensions.push_back( "hpp" );
this->HeaderFileExtensions.push_back( "hxx" );
this->HeaderFileExtensions.push_back( "in" );
this->HeaderFileExtensions.push_back( "txx" );
this->DefineFlags = " ";
@ -756,15 +731,26 @@ void cmMakefile::ConfigureFinalPass()
"with CMake 2.4 or later. For compatibility with older versions please "
"use any CMake 2.8.x release or lower.");
}
for (cmTargets::iterator l = this->Targets.begin();
l != this->Targets.end(); l++)
#if defined(_WIN32) && !defined(__CYGWIN__)
// Do old-style link dependency analysis only for CM_USE_OLD_VS6.
if(this->GetGlobalGenerator()->IsForVS6())
{
if (l->second.GetType() == cmState::INTERFACE_LIBRARY)
for (cmTargets::iterator l = this->Targets.begin();
l != this->Targets.end(); l++)
{
continue;
if (l->second.GetType() == cmState::INTERFACE_LIBRARY)
{
continue;
}
// Erase any cached link information that might have been comptued
// on-demand during the configuration. This ensures that build
// system generation uses up-to-date information even if other cache
// invalidation code in this source file is buggy.
l->second.AnalyzeLibDependenciesForVS6(*this);
}
l->second.FinishConfigure();
}
#endif
}
//----------------------------------------------------------------------------
@ -1780,6 +1766,18 @@ const char* cmMakefile::GetCurrentBinaryDirectory() const
return this->StateSnapshot.GetDirectory().GetCurrentBinary();
}
std::vector<cmTarget*> cmMakefile::GetImportedTargets() const
{
std::vector<cmTarget*> tgts;
tgts.reserve(this->ImportedTargets.size());
for (TargetMap::const_iterator it = this->ImportedTargets.begin();
it != this->ImportedTargets.end(); ++it)
{
tgts.push_back(it->second);
}
return tgts;
}
//----------------------------------------------------------------------------
void cmMakefile::AddIncludeDirectories(const std::vector<std::string> &incs,
bool before)
@ -2050,10 +2048,11 @@ void cmMakefile::AddGlobalLinkInformation(const std::string& name,
}
void cmMakefile::AddAlias(const std::string& lname, cmTarget *tgt)
void cmMakefile::AddAlias(const std::string& lname,
std::string const& tgtName)
{
this->AliasTargets[lname] = tgt;
this->GetGlobalGenerator()->AddAlias(lname, tgt);
this->AliasTargets[lname] = tgtName;
this->GetGlobalGenerator()->AddAlias(lname, tgtName);
}
cmTarget* cmMakefile::AddLibrary(const std::string& lname,
@ -2110,7 +2109,6 @@ cmMakefile::AddNewTarget(cmState::TargetType type, const std::string& name)
cmTarget& target = it->second;
target.SetType(type, name);
target.SetMakefile(this);
this->GetGlobalGenerator()->AddTarget(&it->second);
return &it->second;
}
@ -4039,10 +4037,12 @@ cmTarget* cmMakefile::FindTarget(const std::string& name,
{
if (!excludeAliases)
{
TargetMap::const_iterator i = this->AliasTargets.find(name);
std::map<std::string, std::string>::const_iterator i =
this->AliasTargets.find(name);
if (i != this->AliasTargets.end())
{
return i->second;
cmTargets::iterator ai = this->Targets.find(i->second);
return &ai->second;
}
}
cmTargets::iterator i = this->Targets.find( name );
@ -4197,15 +4197,11 @@ cmMakefile::AddImportedTarget(const std::string& name,
// Create the target.
cmsys::auto_ptr<cmTarget> target(new cmTarget);
target->SetType(type, name);
target->MarkAsImported();
target->MarkAsImported(global);
target->SetMakefile(this);
// Add to the set of available imported targets.
this->ImportedTargets[name] = target.get();
if(global)
{
this->GetGlobalGenerator()->AddTarget(target.get());
}
// Transfer ownership to this cmMakefile object.
this->ImportedTargetsOwned.push_back(target.get());

View File

@ -283,7 +283,7 @@ public:
cmTarget* AddLibrary(const std::string& libname, cmState::TargetType type,
const std::vector<std::string> &srcs,
bool excludeFromAll = false);
void AddAlias(const std::string& libname, cmTarget *tgt);
void AddAlias(const std::string& libname, const std::string& tgt);
#if defined(CMAKE_BUILD_WITH_CMAKE)
/**
@ -390,6 +390,7 @@ public:
{
return this->ImportedTargetsOwned;
}
std::vector<cmTarget*> GetImportedTargets() const;
cmTarget* FindTarget(const std::string& name,
bool excludeAliases = false) const;
@ -400,6 +401,11 @@ public:
bool excludeAliases = false) const;
bool IsAlias(const std::string& name) const;
std::map<std::string, std::string> GetAliasTargets() const
{
return this->AliasTargets;
}
/**
* Mark include directories as system directories.
*/
@ -425,17 +431,6 @@ public:
cmSourceFile* GetOrCreateSource(const std::string& sourceName,
bool generated = false);
//@{
/**
* Return a list of extensions associated with source and header
* files
*/
const std::vector<std::string>& GetSourceExtensions() const
{return this->SourceFileExtensions;}
const std::vector<std::string>& GetHeaderExtensions() const
{return this->HeaderFileExtensions;}
//@}
/**
* Given a variable name, return its value (as a string).
* If the variable is not found in this makefile instance, the
@ -801,7 +796,7 @@ protected:
#else
typedef std::map<std::string, cmTarget*> TargetMap;
#endif
TargetMap AliasTargets;
std::map<std::string, std::string> AliasTargets;
std::vector<cmSourceFile*> SourceFiles;
// Tests
@ -823,8 +818,6 @@ protected:
std::vector<cmTestGenerator*> TestGenerators;
std::string ComplainFileRegularExpression;
std::vector<std::string> SourceFileExtensions;
std::vector<std::string> HeaderFileExtensions;
std::string DefineFlags;
// Track the value of the computed DEFINITIONS property.

View File

@ -279,11 +279,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
{
this->LocalGenerator
->AppendCustomCommands(commands,
this->GeneratorTarget->Target->GetPreBuildCommands(),
this->GeneratorTarget->GetPreBuildCommands(),
this->GeneratorTarget);
this->LocalGenerator
->AppendCustomCommands(commands,
this->GeneratorTarget->Target->GetPreLinkCommands(),
this->GeneratorTarget->GetPreLinkCommands(),
this->GeneratorTarget);
}
@ -450,7 +450,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
{
this->LocalGenerator->
AppendCustomCommands(commands,
this->GeneratorTarget->Target->GetPostBuildCommands(),
this->GeneratorTarget->GetPostBuildCommands(),
this->GeneratorTarget);
}

View File

@ -114,7 +114,7 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules()
// Add post-build rules.
this->LocalGenerator->
AppendCustomCommands(commands,
this->GeneratorTarget->Target->GetPostBuildCommands(),
this->GeneratorTarget->GetPostBuildCommands(),
this->GeneratorTarget);
// Depend on the object files.
@ -458,11 +458,11 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
{
this->LocalGenerator
->AppendCustomCommands(commands,
this->GeneratorTarget->Target->GetPreBuildCommands(),
this->GeneratorTarget->GetPreBuildCommands(),
this->GeneratorTarget);
this->LocalGenerator
->AppendCustomCommands(commands,
this->GeneratorTarget->Target->GetPreLinkCommands(),
this->GeneratorTarget->GetPreLinkCommands(),
this->GeneratorTarget);
}
@ -814,7 +814,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
{
this->LocalGenerator->
AppendCustomCommands(commands,
this->GeneratorTarget->Target->GetPostBuildCommands(),
this->GeneratorTarget->GetPostBuildCommands(),
this->GeneratorTarget);
}

View File

@ -67,20 +67,20 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
// Utility targets store their rules in pre- and post-build commands.
this->LocalGenerator->AppendCustomDepends
(depends, this->GeneratorTarget->Target->GetPreBuildCommands());
(depends, this->GeneratorTarget->GetPreBuildCommands());
this->LocalGenerator->AppendCustomDepends
(depends, this->GeneratorTarget->Target->GetPostBuildCommands());
(depends, this->GeneratorTarget->GetPostBuildCommands());
this->LocalGenerator->AppendCustomCommands
(commands, this->GeneratorTarget->Target->GetPreBuildCommands(),
(commands, this->GeneratorTarget->GetPreBuildCommands(),
this->GeneratorTarget);
// Depend on all custom command outputs for sources
this->DriveCustomCommands(depends);
this->LocalGenerator->AppendCustomCommands
(commands, this->GeneratorTarget->Target->GetPostBuildCommands(),
(commands, this->GeneratorTarget->GetPostBuildCommands(),
this->GeneratorTarget);
// Add dependencies on targets that must be built first.

View File

@ -598,9 +598,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
}
const std::vector<cmCustomCommand> *cmdLists[3] = {
&gt.Target->GetPreBuildCommands(),
&gt.Target->GetPreLinkCommands(),
&gt.Target->GetPostBuildCommands()
&gt.GetPreBuildCommands(),
&gt.GetPreLinkCommands(),
&gt.GetPostBuildCommands()
};
std::vector<std::string> preLinkCmdLines, postBuildCmdLines;

View File

@ -33,8 +33,8 @@ void cmNinjaUtilityTargetGenerator::Generate()
cmNinjaDeps deps, outputs, util_outputs(1, utilCommandName);
const std::vector<cmCustomCommand> *cmdLists[2] = {
&this->GetGeneratorTarget()->Target->GetPreBuildCommands(),
&this->GetGeneratorTarget()->Target->GetPostBuildCommands()
&this->GetGeneratorTarget()->GetPreBuildCommands(),
&this->GetGeneratorTarget()->GetPostBuildCommands()
};
bool uses_terminal = false;

View File

@ -83,7 +83,7 @@ void cmOSXBundleGenerator::CreateFramework(
std::string newoutpath = outpath + "/" +
this->GT->GetFrameworkDirectory(this->ConfigName, false);
std::string frameworkVersion = this->GT->Target->GetFrameworkVersion();
std::string frameworkVersion = this->GT->GetFrameworkVersion();
// Configure the Info.plist file into the Resources directory.
this->MacContentFolders->insert("Resources");

View File

@ -896,7 +896,6 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg);
lg->AddGeneratorTarget(gt);
lg->GetGlobalGenerator()->AddGeneratorTarget(autogenTarget, gt);
// Set target folder
const char* autogenFolder = makefile->GetState()

View File

@ -528,7 +528,7 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
cmSystemTools::ExpandListArgument(this->Sources, sourceFiles);
const std::vector<std::string>& headerExtensions =
makefile->GetHeaderExtensions();
makefile->GetCMakeInstance()->GetHeaderExtensions();
std::map<std::string, std::vector<std::string> > includedUis;
std::map<std::string, std::vector<std::string> > skippedUis;

View File

@ -167,8 +167,10 @@ bool cmSourceFile::FindFullPath(std::string* error)
{
tryDirs[0] = "";
}
const std::vector<std::string>& srcExts = mf->GetSourceExtensions();
const std::vector<std::string>& hdrExts = mf->GetHeaderExtensions();
const std::vector<std::string>& srcExts =
mf->GetCMakeInstance()->GetSourceExtensions();
std::vector<std::string> hdrExts =
mf->GetCMakeInstance()->GetHeaderExtensions();
for(const char* const* di = tryDirs; *di; ++di)
{
std::string tryPath = this->Location.GetDirectory();

View File

@ -121,8 +121,10 @@ void cmSourceFileLocation::UpdateExtension(const std::string& name)
// The global generator checks extensions of enabled languages.
cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
cmMakefile const* mf = this->Makefile;
const std::vector<std::string>& srcExts = mf->GetSourceExtensions();
const std::vector<std::string>& hdrExts = mf->GetHeaderExtensions();
const std::vector<std::string>& srcExts =
mf->GetCMakeInstance()->GetSourceExtensions();
const std::vector<std::string>& hdrExts =
mf->GetCMakeInstance()->GetHeaderExtensions();
if(!gg->GetLanguageFromExtension(ext.c_str()).empty() ||
std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end() ||
std::find(hdrExts.begin(), hdrExts.end(), ext) != hdrExts.end())
@ -193,12 +195,14 @@ cmSourceFileLocation
// disk. One of these must match if loc refers to this source file.
std::string const& ext = this->Name.substr(loc.Name.size()+1);
cmMakefile const* mf = this->Makefile;
const std::vector<std::string>& srcExts = mf->GetSourceExtensions();
const std::vector<std::string>& srcExts =
mf->GetCMakeInstance()->GetSourceExtensions();
if(std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end())
{
return true;
}
const std::vector<std::string>& hdrExts = mf->GetHeaderExtensions();
std::vector<std::string> hdrExts =
mf->GetCMakeInstance()->GetHeaderExtensions();
if(std::find(hdrExts.begin(), hdrExts.end(), ext) != hdrExts.end())
{
return true;

View File

@ -63,6 +63,7 @@ cmTarget::cmTarget()
this->IsAndroid = false;
this->IsApple = false;
this->IsImportedTarget = false;
this->ImportedGloballyVisible = false;
this->BuildInterfaceIncludesAppended = false;
}
@ -314,23 +315,6 @@ cmListFileBacktrace const* cmTarget::GetUtilityBacktrace(
return &i->second;
}
//----------------------------------------------------------------------------
void cmTarget::FinishConfigure()
{
// Erase any cached link information that might have been comptued
// on-demand during the configuration. This ensures that build
// system generation uses up-to-date information even if other cache
// invalidation code in this source file is buggy.
#if defined(_WIN32) && !defined(__CYGWIN__)
// Do old-style link dependency analysis only for CM_USE_OLD_VS6.
if(this->Makefile->GetGlobalGenerator()->IsForVS6())
{
this->AnalyzeLibDependenciesForVS6(*this->Makefile);
}
#endif
}
//----------------------------------------------------------------------------
cmListFileBacktrace const& cmTarget::GetBacktrace() const
{
@ -1522,9 +1506,10 @@ void cmTarget::CheckProperty(const std::string& prop,
}
//----------------------------------------------------------------------------
void cmTarget::MarkAsImported()
void cmTarget::MarkAsImported(bool global)
{
this->IsImportedTarget = true;
this->ImportedGloballyVisible = global;
}
//----------------------------------------------------------------------------
@ -1617,7 +1602,7 @@ const char *cmTarget::GetProperty(const std::string& prop,
// CMake time.
cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
gg->CreateGenerationObjects();
cmGeneratorTarget* gt = gg->GetGeneratorTarget(this);
cmGeneratorTarget* gt = gg->FindGeneratorTarget(this->GetName());
this->Properties.SetProperty(propLOCATION,
gt->GetLocationForBuild());
}
@ -1642,7 +1627,7 @@ const char *cmTarget::GetProperty(const std::string& prop,
{
cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
gg->CreateGenerationObjects();
cmGeneratorTarget* gt = gg->GetGeneratorTarget(this);
cmGeneratorTarget* gt = gg->FindGeneratorTarget(this->GetName());
this->Properties.SetProperty(
prop, gt->GetFullPath(configName, false).c_str());
}
@ -1666,7 +1651,7 @@ const char *cmTarget::GetProperty(const std::string& prop,
{
cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
gg->CreateGenerationObjects();
cmGeneratorTarget* gt = gg->GetGeneratorTarget(this);
cmGeneratorTarget* gt = gg->FindGeneratorTarget(this->GetName());
this->Properties.SetProperty(
prop, gt->GetFullPath(configName, false).c_str());
}
@ -2048,25 +2033,6 @@ void cmTarget::SetPropertyDefault(const std::string& property,
}
}
//----------------------------------------------------------------------------
std::string cmTarget::GetFrameworkVersion() const
{
assert(this->GetType() != cmState::INTERFACE_LIBRARY);
if(const char* fversion = this->GetProperty("FRAMEWORK_VERSION"))
{
return fversion;
}
else if(const char* tversion = this->GetProperty("VERSION"))
{
return tversion;
}
else
{
return "A";
}
}
bool cmTarget::GetMappedConfig(std::string const& desired_config,
const char** loc,
const char** imp,

View File

@ -75,7 +75,7 @@ public:
*/
void SetType(cmState::TargetType f, const std::string& name);
void MarkAsImported();
void MarkAsImported(bool global = false);
///! Set/Get the name of the target
const std::string& GetName() const {return this->Name;}
@ -176,9 +176,6 @@ public:
std::set<std::string>const& GetUtilities() const { return this->Utilities; }
cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const;
/** Finalize the target at the end of the Configure step. */
void FinishConfigure();
///! Set/Get a property of this target file
void SetProperty(const std::string& prop, const char *value);
void AppendProperty(const std::string& prop, const char* value,
@ -189,6 +186,8 @@ public:
void CheckProperty(const std::string& prop, cmMakefile* context) const;
bool IsImported() const {return this->IsImportedTarget;}
bool IsImportedGloballyVisible() const
{ return this->ImportedGloballyVisible; }
// Get the properties
cmPropertyMap &GetProperties() const { return this->Properties; }
@ -209,10 +208,6 @@ public:
/** Return whether this target is an executable Bundle on Apple. */
bool IsAppBundleOnApple() const;
/** Return the framework version string. Undefined if
IsFrameworkOnApple returns false. */
std::string GetFrameworkVersion() const;
/** Get a backtrace from the creation of the target. */
cmListFileBacktrace const& GetBacktrace() const;
@ -234,9 +229,6 @@ public:
std::set<std::string> const & GetSystemIncludeDirectories() const
{ return this->SystemIncludeDirectories; }
bool LinkLanguagePropagatesToDependents() const
{ return this->TargetTypeValue == cmState::STATIC_LIBRARY; }
cmStringRange GetIncludeDirectoriesEntries() const;
cmBacktraceRange GetIncludeDirectoriesBacktraces() const;
@ -254,10 +246,11 @@ public:
cmStringRange GetLinkImplementationEntries() const;
cmBacktraceRange GetLinkImplementationBacktraces() const;
#if defined(_WIN32) && !defined(__CYGWIN__)
const LinkLibraryVectorType &GetLinkLibrariesForVS6() const {
return this->LinkLibrariesForVS6;}
void AnalyzeLibDependenciesForVS6( const cmMakefile& mf );
#endif
struct StrictTargetComparison {
@ -316,8 +309,6 @@ private:
void GatherDependenciesForVS6( const cmMakefile& mf,
const LibraryID& lib,
DependencyMap& dep_map);
void AnalyzeLibDependenciesForVS6( const cmMakefile& mf );
#endif
const char* GetSuffixVariableInternal(bool implib) const;
@ -360,6 +351,7 @@ private:
bool IsAndroid;
bool IsApple;
bool IsImportedTarget;
bool ImportedGloballyVisible;
bool BuildInterfaceIncludesAppended;
#if defined(_WIN32) && !defined(__CYGWIN__)
bool LinkLibrariesForVS6Analyzed;

View File

@ -2814,7 +2814,7 @@ cmVisualStudio10TargetGenerator::WriteEvents(std::string const& configName)
{
addedPrelink = true;
std::vector<cmCustomCommand> commands =
this->GeneratorTarget->Target->GetPreLinkCommands();
this->GeneratorTarget->GetPreLinkCommands();
this->GlobalGenerator->AddSymbolExportCommand(
this->GeneratorTarget, commands, configName);
this->WriteEvent("PreLinkEvent", commands, configName);
@ -2823,12 +2823,12 @@ cmVisualStudio10TargetGenerator::WriteEvents(std::string const& configName)
if (!addedPrelink)
{
this->WriteEvent("PreLinkEvent",
this->GeneratorTarget->Target->GetPreLinkCommands(), configName);
this->GeneratorTarget->GetPreLinkCommands(), configName);
}
this->WriteEvent("PreBuildEvent",
this->GeneratorTarget->Target->GetPreBuildCommands(), configName);
this->GeneratorTarget->GetPreBuildCommands(), configName);
this->WriteEvent("PostBuildEvent",
this->GeneratorTarget->Target->GetPostBuildCommands(), configName);
this->GeneratorTarget->GetPostBuildCommands(), configName);
}
void cmVisualStudio10TargetGenerator::WriteEvent(

View File

@ -165,6 +165,30 @@ cmake::cmake()
// Make sure we can capture the build tool output.
cmSystemTools::EnableVSConsoleOutput();
// Set up a list of source and header extensions
// these are used to find files when the extension
// is not given
// The "c" extension MUST precede the "C" extension.
this->SourceFileExtensions.push_back( "c" );
this->SourceFileExtensions.push_back( "C" );
this->SourceFileExtensions.push_back( "c++" );
this->SourceFileExtensions.push_back( "cc" );
this->SourceFileExtensions.push_back( "cpp" );
this->SourceFileExtensions.push_back( "cxx" );
this->SourceFileExtensions.push_back( "m" );
this->SourceFileExtensions.push_back( "M" );
this->SourceFileExtensions.push_back( "mm" );
this->HeaderFileExtensions.push_back( "h" );
this->HeaderFileExtensions.push_back( "hh" );
this->HeaderFileExtensions.push_back( "h++" );
this->HeaderFileExtensions.push_back( "hm" );
this->HeaderFileExtensions.push_back( "hpp" );
this->HeaderFileExtensions.push_back( "hxx" );
this->HeaderFileExtensions.push_back( "in" );
this->HeaderFileExtensions.push_back( "txx" );
}
cmake::~cmake()
@ -423,8 +447,8 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
(cmSystemTools::GetCurrentWorkingDirectory());
// read in the list file to fill the cache
snapshot.SetDefaultDefinitions();
cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(gg, snapshot));
cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator(mf.get()));
cmMakefile* mf = new cmMakefile(gg, snapshot);
gg->AddMakefile(mf);
mf->SetArgcArgv(args);
@ -457,6 +481,8 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
std::vector<std::string> includeDirs;
cmSystemTools::ExpandListArgument(includes, includeDirs);
gg->CreateGenerationObjects();
cmLocalGenerator* lg = gg->LocalGenerators[0];
std::string includeFlags = lg->GetIncludeFlags(includeDirs, 0, language);
std::string definitions = mf->GetSafeDefinition("PACKAGE_DEFINITIONS");
@ -486,8 +512,9 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
std::string linkPath;
std::string flags;
std::string linkFlags;
gg->CreateGeneratorTargets(cmGlobalGenerator::AllTargets, lg.get());
cmGeneratorTarget *gtgt = gg->GetGeneratorTarget(tgt);
gg->CreateGenerationObjects();
cmGeneratorTarget *gtgt = gg->FindGeneratorTarget(tgt->GetName());
cmLocalGenerator* lg = gtgt->GetLocalGenerator();
lg->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags,
gtgt, false);
linkLibs = frameworkPath + linkPath + linkLibs;

View File

@ -182,6 +182,11 @@ class cmake
///! get the cmCachemManager used by this invocation of cmake
cmCacheManager *GetCacheManager() { return this->CacheManager; }
const std::vector<std::string>& GetSourceExtensions() const
{return this->SourceFileExtensions;}
const std::vector<std::string>& GetHeaderExtensions() const
{return this->HeaderFileExtensions;}
/**
* Given a variable name, return its value (as a string).
*/
@ -391,6 +396,8 @@ private:
std::string CheckStampFile;
std::string CheckStampList;
std::string VSSolutionFile;
std::vector<std::string> SourceFileExtensions;
std::vector<std::string> HeaderFileExtensions;
bool ClearBuildSystem;
bool DebugTryCompile;
cmFileTimeComparison* FileComparison;