diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index 47f65926a..a84bb9dee 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -192,7 +192,7 @@ bool cmAddExecutableCommand this->SetError(e.str()); return false; } - this->Makefile->AddAlias(exename, aliasedTarget); + this->Makefile->AddAlias(exename, aliasedName); return true; } diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index e0adee39f..5296cbb36 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -314,7 +314,7 @@ bool cmAddLibraryCommand this->SetError(e.str()); return false; } - this->Makefile->AddAlias(libName, aliasedTarget); + this->Makefile->AddAlias(libName, aliasedName); return true; } diff --git a/Source/cmAuxSourceDirectoryCommand.cxx b/Source/cmAuxSourceDirectoryCommand.cxx index 5f5017d99..92ac07dfd 100644 --- a/Source/cmAuxSourceDirectoryCommand.cxx +++ b/Source/cmAuxSourceDirectoryCommand.cxx @@ -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 srcExts = + this->Makefile->GetCMakeInstance()->GetSourceExtensions(); + if(!base.empty() && + std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end()) { std::string fullname = templateDirectory; fullname += "/"; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index a32bb48a0..50d832438 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -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 const& dirs = - this->Target->Target->GetLinkDirectories(); + this->Target->GetLinkDirectories(); this->OldLinkDirMask.insert(dirs.begin(), dirs.end()); } diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 113c9895a..586b5bfb1 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -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); diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 23c11d720..9e3653983 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -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")) diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index d52ce35b3..e8a2e6a52 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -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; diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index 1daa67e08..83127e7ed 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -105,16 +105,18 @@ cmExportTryCompileFileGenerator::PopulateProperties( ImportPropertyMap& properties, std::set &emitted) { - cmPropertyMap props = target->Target->GetProperties(); - for(cmPropertyMap::const_iterator i = props.begin(); i != props.end(); ++i) + std::vector props = target->GetPropertyKeys(); + for(std::vector::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 depends; diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 597c9d80f..9348ef2b3 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -383,6 +383,9 @@ void cmExtraCodeBlocksGenerator all_files_map_t allFiles; std::vector cFiles; + std::vector srcExts = + this->GlobalGenerator->GetCMakeInstance()->GetSourceExtensions(); + for (std::vector::const_iterator lg=lgs.begin(); lg!=lgs.end(); lg++) { @@ -420,9 +423,7 @@ void cmExtraCodeBlocksGenerator { std::string srcext = (*si)->GetExtension(); for(std::vector::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 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::const_iterator - ext = mf->GetHeaderExtensions().begin(); - ext != mf->GetHeaderExtensions().end(); + ext = headerExts.begin(); + ext != headerExts.end(); ++ext) { std::string hname=headerBasename; diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index f4a653730..67aa157a1 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -149,6 +149,11 @@ void cmExtraCodeLiteGenerator // which may have an acompanying header, one for all other files std::string projectType; + std::vector srcExts = + this->GlobalGenerator->GetCMakeInstance()->GetSourceExtensions(); + std::vector headerExts = + this->GlobalGenerator->GetCMakeInstance()->GetHeaderExtensions(); + std::map cFiles; std::set otherFiles; for (std::vector::const_iterator lg=lgs.begin(); @@ -207,9 +212,7 @@ void cmExtraCodeLiteGenerator { std::string srcext = (*si)->GetExtension(); for(std::vector::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::const_iterator - ext = mf->GetHeaderExtensions().begin(); - ext != mf->GetHeaderExtensions().end(); + ext = headerExts.begin(); + ext != headerExts.end(); ++ext) { std::string hname=headerBasename; diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 7a7e4ffb3..df6e3fbb8 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -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) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index fe6b44644..1f74eda9a 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -796,7 +796,7 @@ std::set const& cmGeneratorTarget::GetUtilityItems() const if(!this->UtilityItemsDone) { this->UtilityItemsDone = true; - std::set const& utilities = this->Target->GetUtilities(); + std::set const& utilities = this->GetUtilities(); for(std::set::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 const& +cmGeneratorTarget::GetPreBuildCommands() const +{ + return this->Target->GetPreBuildCommands(); +} + +std::vector const& +cmGeneratorTarget::GetPreLinkCommands() const +{ + return this->Target->GetPreLinkCommands(); +} + +std::vector 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&cmGeneratorTarget::GetLinkDirectories() const +{ + return this->Target->GetLinkDirectories(); +} + +const std::set& 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& 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& Languages; cmGeneratorTarget const* HeadTarget; - cmMakefile* Makefile; const cmGeneratorTarget* Target; std::set 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(tgt, p); - const bool explicitlySet = tgt->Target->GetProperties() - .find(p) - != tgt->Target->GetProperties().end(); + std::vector 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 propKeys = theTarget->GetPropertyKeys(); + + const bool ifaceIsSet = + std::find(propKeys.begin(), propKeys.end(), + interfaceProperty) != propKeys.end(); PropertyType ifacePropContent = getTypedProperty(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 cmGeneratorTarget::GetPropertyKeys() const +{ + cmPropertyMap propsObject = this->Target->GetProperties(); + std::vector 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; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 544cf0eaf..da59a98be 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -31,8 +31,13 @@ public: cmLocalGenerator* GetLocalGenerator() const; bool IsImported() const; + bool IsImportedGloballyVisible() const; const char *GetLocation(const std::string& config) const; + std::vector const &GetPreBuildCommands() const; + std::vector const &GetPreLinkCommands() const; + std::vector 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 GetPropertyKeys() const; const char *GetProperty(const std::string& prop) const; bool GetPropertyAsBool(const std::string& prop) const; void GetSourceFiles(std::vector& 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& GetLinkDirectories() const; + + std::setconst& 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 {}; + public std::map {}; typedef std::map LinkImplMapType; mutable LinkImplMapType LinkImplMap; diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 12115be34..18e140e40 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -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); } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index d26cc3467..3d2db422f 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -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 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 itgts = mf->GetImportedTargets(); + for(std::vector::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 importedMap; + for(unsigned int i=0; i < this->Makefiles.size(); ++i) + { + cmMakefile* mf = this->Makefiles[i]; + for(std::vector::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 tgts = + this->LocalGenerators[i]->GetGeneratorTargets(); + for (std::vector::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 tgts = + this->Makefiles[i]->GetOwnedImportedTargets(); + for (std::vector::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 tgts = + this->LocalGenerators[i]->GetImportedGeneratorTargets(); + for (std::vector::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::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 tgts = + this->LocalGenerators[i]->GetGeneratorTargets(); + for (std::vector::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"; } } diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 18f532930..bc6e17d7f 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -42,10 +42,6 @@ class cmInstallTargetGenerator; class cmInstallFilesGenerator; class cmExportBuildFileGenerator; -typedef std::map 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 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 >& GetProjectMap() const {return this->ProjectMap;} @@ -429,19 +417,14 @@ protected: std::map BuildExportSets; std::map BuildExportExportSets; - // All targets in the entire project. -#if defined(CMAKE_BUILD_WITH_CMAKE) -#ifdef CMake_HAVE_CXX11_UNORDERED_MAP - typedef std::unordered_map TargetMap; -#else - typedef cmsys::hash_map TargetMap; -#endif -#else - typedef std::map TargetMap; -#endif - TargetMap TotalTargets; - TargetMap AliasTargets; - TargetMap ImportedTargets; + std::map 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 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 const& importedMap); void CreateGeneratorTargets(TargetTypes targetTypes); void ClearGeneratorMembers(); diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index 7c6c48c14..018ab24f0 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -105,6 +105,9 @@ bool cmGlobalKdevelopGenerator std::set files; std::string tmp; + std::vector hdrExts = + this->GlobalGenerator->GetCMakeInstance()->GetHeaderExtensions(); + for (std::vector::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::const_iterator - ext = makefile->GetHeaderExtensions().begin(); - ext != makefile->GetHeaderExtensions().end(); ++ext) + ext = hdrExts.begin(); ext != hdrExts.end(); ++ext) { std::string hname=headerBasename; hname += "."; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 2671f4d9e..8498e39e5 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -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 const& utils = target->Target->GetUtilities(); + std::set const& utils = target->GetUtilities(); std::copy(utils.begin(), utils.end(), std::back_inserter(outputs)); } else { cmTargetDependSet const& targetDeps = this->GetTargetDirectDepends(target); diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index b4a915c7f..7dd24fb71 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -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(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 targets = lg2->GetGeneratorTargets(); diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index bb494f1ab..5866c0e7f 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -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 { diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 547324750..f5848ab81 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -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 cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( std::vector const& configs, - OrderedTargetDependSet const& projectTargets, cmTarget const* target) + OrderedTargetDependSet const& projectTargets, + cmGeneratorTarget const* target) { std::set activeConfigs; // if it is a utilitiy target then only make it part of the @@ -1011,13 +1012,13 @@ cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( for(std::vector::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 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[_] properties for(std::vector::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) { diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 6a0e5e9b9..fe6db2e98 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -163,9 +163,9 @@ protected: std::set IsPartOfDefaultBuild(std::vector const& configs, OrderedTargetDependSet const& projectTargets, - cmTarget const* target); + cmGeneratorTarget const* target); bool IsDependedOn(OrderedTargetDependSet const& projectTargets, - cmTarget const* target); + cmGeneratorTarget const* target); std::map GUIDMap; virtual void WriteFolders(std::ostream& fout); diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index bdb1b2589..5e239b8cd 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -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 tgts = + this->LocalGenerators[i]->GetGeneratorTargets(); + // All targets depend on the build-system check target. + for(std::vector::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::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())) diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index b819daddd..bb0c974af 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -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 diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index eecc82bb4..da8c81414 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -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 tgts = + this->LocalGenerators[i]->GetGeneratorTargets(); + // All targets depend on the build-system check target. + for(std::vector::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& 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 const & prebuild - = gtgt->Target->GetPreBuildCommands(); + = gtgt->GetPreBuildCommands(); std::vector const & prelink - = gtgt->Target->GetPreLinkCommands(); + = gtgt->GetPreLinkCommands(); std::vector 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 const& props = gtgt->GetPropertyKeys(); + for(std::vector::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=] 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)); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index c37417ddf..d92cbeaa4 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -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::const_iterator i = + this->AliasTargets.find(name); + if (i != this->AliasTargets.end()) + { + std::vector::const_iterator ai = + std::find_if(this->GeneratorTargets.begin(), + this->GeneratorTargets.end(), + NamedGeneratorTargetFinder(i->second)); + return *ai; + } + std::vector::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::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 { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 552020baf..e2f551976 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -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 &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 WarnCMP0063; std::vector GeneratorTargets; + std::vector ImportedGeneratorTargets; + std::vector OwnedImportedGeneratorTargets; + std::map AliasTargets; bool EmitUniversalBinaryFlags; diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 891c44ecb..7de48a44b 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -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; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 34a50a3f6..82e3b01a1 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -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 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 no_depends; std::vector 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(); diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index d5abf68f7..cdacb9ec6 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -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 depends; for (std::vector::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::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::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::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 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::const_iterator i; const std::vector& 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"; } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index ca8d697c0..ae6a24e26 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -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 commands = - target->Target->GetPreLinkCommands(); + target->GetPreLinkCommands(); cmGlobalVisualStudioGenerator* gg = static_cast(this->GlobalGenerator); gg->AddSymbolExportCommand( @@ -2045,7 +2045,7 @@ void cmLocalVisualStudio7Generator } if (!addedPrelink) { - event.Write(target->Target->GetPreLinkCommands()); + event.Write(target->GetPreLinkCommands()); } cmsys::auto_ptr 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\n"; - cmPropertyMap const& props = target->Target->GetProperties(); - for(cmPropertyMap::const_iterator i = props.begin(); i != props.end(); ++i) + std::vector const& props = target->GetPropertyKeys(); + for(std::vector::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\tsecond.GetValue() << "\"\n" + << "\t\t\tValue=\"" << target->GetProperty(*i) << "\"\n" << "\t\t/>\n"; } } diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx index 3b430d26a..aec260366 100644 --- a/Source/cmLocalXCodeGenerator.cxx +++ b/Source/cmLocalXCodeGenerator.cxx @@ -51,13 +51,11 @@ void cmLocalXCodeGenerator::Generate() { cmLocalGenerator::Generate(); - cmTargets& targets = this->Makefile->GetTargets(); - for(cmTargets::iterator iter = targets.begin(); + std::vector targets = this->GetGeneratorTargets(); + for(std::vector::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 targets = this->GetGeneratorTargets(); + for(std::vector::iterator iter = targets.begin(); iter != targets.end(); ++iter) { - cmTarget* t = &iter->second; - cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(t); - gt->HasMacOSXRpathInstallNameDir(""); + (*iter)->HasMacOSXRpathInstallNameDir(""); } } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 40e2892fc..ffe92af20 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -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 cmMakefile::GetImportedTargets() const +{ + std::vector 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 &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::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 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()); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 725448b9e..f1dd374fb 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -283,7 +283,7 @@ public: cmTarget* AddLibrary(const std::string& libname, cmState::TargetType type, const std::vector &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 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 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& GetSourceExtensions() const - {return this->SourceFileExtensions;} - const std::vector& 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 TargetMap; #endif - TargetMap AliasTargets; + std::map AliasTargets; std::vector SourceFiles; // Tests @@ -823,8 +818,6 @@ protected: std::vector TestGenerators; std::string ComplainFileRegularExpression; - std::vector SourceFileExtensions; - std::vector HeaderFileExtensions; std::string DefineFlags; // Track the value of the computed DEFINITIONS property. diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index f56037fdb..9e35e4c2b 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -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); } diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 0a65641de..1923ea4fb 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -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); } diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx index d35c3ae03..5b62cbf3b 100644 --- a/Source/cmMakefileUtilityTargetGenerator.cxx +++ b/Source/cmMakefileUtilityTargetGenerator.cxx @@ -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. diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index b533d377d..17561b5ab 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -598,9 +598,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } const std::vector *cmdLists[3] = { - >.Target->GetPreBuildCommands(), - >.Target->GetPreLinkCommands(), - >.Target->GetPostBuildCommands() + >.GetPreBuildCommands(), + >.GetPreLinkCommands(), + >.GetPostBuildCommands() }; std::vector preLinkCmdLines, postBuildCmdLines; diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index b2a5334fc..edc65f030 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -33,8 +33,8 @@ void cmNinjaUtilityTargetGenerator::Generate() cmNinjaDeps deps, outputs, util_outputs(1, utilCommandName); const std::vector *cmdLists[2] = { - &this->GetGeneratorTarget()->Target->GetPreBuildCommands(), - &this->GetGeneratorTarget()->Target->GetPostBuildCommands() + &this->GetGeneratorTarget()->GetPreBuildCommands(), + &this->GetGeneratorTarget()->GetPostBuildCommands() }; bool uses_terminal = false; diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index e9dc43320..3c4aa00a9 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -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"); diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index 225c03ee7..b813c1463 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -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() diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index fc690f83b..b16eccda3 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -528,7 +528,7 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) cmSystemTools::ExpandListArgument(this->Sources, sourceFiles); const std::vector& headerExtensions = - makefile->GetHeaderExtensions(); + makefile->GetCMakeInstance()->GetHeaderExtensions(); std::map > includedUis; std::map > skippedUis; diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 37383be7f..a9ac5497b 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -167,8 +167,10 @@ bool cmSourceFile::FindFullPath(std::string* error) { tryDirs[0] = ""; } - const std::vector& srcExts = mf->GetSourceExtensions(); - const std::vector& hdrExts = mf->GetHeaderExtensions(); + const std::vector& srcExts = + mf->GetCMakeInstance()->GetSourceExtensions(); + std::vector hdrExts = + mf->GetCMakeInstance()->GetHeaderExtensions(); for(const char* const* di = tryDirs; *di; ++di) { std::string tryPath = this->Location.GetDirectory(); diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx index b8d5c020b..00d5d6afe 100644 --- a/Source/cmSourceFileLocation.cxx +++ b/Source/cmSourceFileLocation.cxx @@ -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& srcExts = mf->GetSourceExtensions(); - const std::vector& hdrExts = mf->GetHeaderExtensions(); + const std::vector& srcExts = + mf->GetCMakeInstance()->GetSourceExtensions(); + const std::vector& 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& srcExts = mf->GetSourceExtensions(); + const std::vector& srcExts = + mf->GetCMakeInstance()->GetSourceExtensions(); if(std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end()) { return true; } - const std::vector& hdrExts = mf->GetHeaderExtensions(); + std::vector hdrExts = + mf->GetCMakeInstance()->GetHeaderExtensions(); if(std::find(hdrExts.begin(), hdrExts.end(), ext) != hdrExts.end()) { return true; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e05646929..1eebd12df 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -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, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1cae94f27..62e10f408 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -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::setconst& 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 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; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 9c9f5abea..541e5f6f1 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2814,7 +2814,7 @@ cmVisualStudio10TargetGenerator::WriteEvents(std::string const& configName) { addedPrelink = true; std::vector 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( diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 726824109..d5bc3d250 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -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& args) (cmSystemTools::GetCurrentWorkingDirectory()); // read in the list file to fill the cache snapshot.SetDefaultDefinitions(); - cmsys::auto_ptr mf(new cmMakefile(gg, snapshot)); - cmsys::auto_ptr 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& args) std::vector 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& 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; diff --git a/Source/cmake.h b/Source/cmake.h index 9d28cbafc..6b0e83f94 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -182,6 +182,11 @@ class cmake ///! get the cmCachemManager used by this invocation of cmake cmCacheManager *GetCacheManager() { return this->CacheManager; } + const std::vector& GetSourceExtensions() const + {return this->SourceFileExtensions;} + const std::vector& 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 SourceFileExtensions; + std::vector HeaderFileExtensions; bool ClearBuildSystem; bool DebugTryCompile; cmFileTimeComparison* FileComparison;