diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index db8874981..2a144c6b2 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -97,7 +97,7 @@ struct DoAccept template<> struct DoAccept { - static void Do(std::vector& files, cmSourceFile* f) + static void Do(std::vector& files, cmSourceFile* f) { files.push_back(f); } @@ -120,7 +120,7 @@ struct DoAccept }; //---------------------------------------------------------------------------- -template > +template > struct TagVisitor { DataType& Data; @@ -241,7 +241,7 @@ const char *cmGeneratorTarget::GetProperty(const std::string& prop) const //---------------------------------------------------------------------------- std::vector const* -cmGeneratorTarget::GetSourceDepends(cmSourceFile* sf) const +cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const { SourceEntriesType::const_iterator i = this->SourceEntries.find(sf); if(i != this->SourceEntries.end()) @@ -306,13 +306,10 @@ static void handleSystemIncludesDep(cmMakefile *mf, cmTarget* depTgt, //---------------------------------------------------------------------------- void -cmGeneratorTarget::GetObjectSources(std::vector &data) const +cmGeneratorTarget +::GetObjectSources(std::vector &data) const { IMPLEMENT_VISIT(ObjectSources); - if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY) - { - this->ObjectSources = data; - } } //---------------------------------------------------------------------------- @@ -321,13 +318,14 @@ const std::string& cmGeneratorTarget::GetObjectName(cmSourceFile const* file) return this->Objects[file]; } -void cmGeneratorTarget::AddObject(cmSourceFile *sf, std::string const&name) +void cmGeneratorTarget::AddObject(cmSourceFile const* sf, + std::string const&name) { this->Objects[sf] = name; } //---------------------------------------------------------------------------- -void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile* sf) +void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile const* sf) { this->ExplicitObjectName.insert(sf); } @@ -341,34 +339,39 @@ bool cmGeneratorTarget::HasExplicitObjectName(cmSourceFile const* file) const } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GetIDLSources(std::vector& data) const +void cmGeneratorTarget +::GetIDLSources(std::vector& data) const { IMPLEMENT_VISIT(IDLSources); } //---------------------------------------------------------------------------- void -cmGeneratorTarget::GetHeaderSources(std::vector& data) const +cmGeneratorTarget +::GetHeaderSources(std::vector& data) const { IMPLEMENT_VISIT(HeaderSources); } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GetExtraSources(std::vector& data) const +void cmGeneratorTarget +::GetExtraSources(std::vector& data) const { IMPLEMENT_VISIT(ExtraSources); } //---------------------------------------------------------------------------- void -cmGeneratorTarget::GetCustomCommands(std::vector& data) const +cmGeneratorTarget +::GetCustomCommands(std::vector& data) const { IMPLEMENT_VISIT(CustomCommands); } //---------------------------------------------------------------------------- void -cmGeneratorTarget::GetExternalObjects(std::vector& data) const +cmGeneratorTarget +::GetExternalObjects(std::vector& data) const { IMPLEMENT_VISIT(ExternalObjects); } @@ -383,7 +386,8 @@ cmGeneratorTarget::GetExpectedResxHeaders(std::set& srcs) const } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GetResxSources(std::vector& srcs) const +void cmGeneratorTarget +::GetResxSources(std::vector& srcs) const { ResxData data; IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData) @@ -569,9 +573,11 @@ cmGeneratorTarget::UseObjectLibraries(std::vector& objs) const cmTarget* objLib = *ti; cmGeneratorTarget* ogt = this->GlobalGenerator->GetGeneratorTarget(objLib); - for(std::vector::const_iterator - si = ogt->ObjectSources.begin(); - si != ogt->ObjectSources.end(); ++si) + std::vector objectSources; + ogt->GetObjectSources(objectSources); + for(std::vector::const_iterator + si = objectSources.begin(); + si != objectSources.end(); ++si) { std::string obj = ogt->ObjectDirectory; obj += ogt->Objects[*si]; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 81a447f46..53e27c510 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -32,19 +32,19 @@ public: bool GetPropertyAsBool(const std::string& prop) const; void GetSourceFiles(std::vector& files) const; - void GetObjectSources(std::vector &) const; + void GetObjectSources(std::vector &) const; const std::string& GetObjectName(cmSourceFile const* file); - void AddObject(cmSourceFile *sf, std::string const&name); + void AddObject(cmSourceFile const* sf, std::string const&name); bool HasExplicitObjectName(cmSourceFile const* file) const; - void AddExplicitObjectName(cmSourceFile* sf); + void AddExplicitObjectName(cmSourceFile const* sf); - void GetResxSources(std::vector&) const; - void GetIDLSources(std::vector&) const; - void GetExternalObjects(std::vector&) const; - void GetHeaderSources(std::vector&) const; - void GetExtraSources(std::vector&) const; - void GetCustomCommands(std::vector&) const; + void GetResxSources(std::vector&) const; + void GetIDLSources(std::vector&) const; + void GetExternalObjects(std::vector&) const; + void GetHeaderSources(std::vector&) const; + void GetExtraSources(std::vector&) const; + void GetCustomCommands(std::vector&) const; void GetExpectedResxHeaders(std::set&) const; cmTarget* Target; @@ -87,7 +87,8 @@ public: void LookupObjectLibraries(); /** Get sources that must be built before the given source. */ - std::vector const* GetSourceDepends(cmSourceFile* sf) const; + std::vector const* + GetSourceDepends(cmSourceFile const* sf) const; /** * Flags for a given source file as used in this target. Typically assigned @@ -116,17 +117,16 @@ public: struct ResxData { mutable std::set ExpectedResxHeaders; - mutable std::vector ResxSources; + mutable std::vector ResxSources; }; private: friend class cmTargetTraceDependencies; struct SourceEntry { std::vector Depends; }; - typedef std::map SourceEntriesType; + typedef std::map SourceEntriesType; SourceEntriesType SourceEntries; std::map Objects; std::set ExplicitObjectName; - mutable std::vector ObjectSources; std::vector ObjectLibraries; mutable std::map > SystemIncludesCache; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index b95ff81ae..5b6d729d5 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1449,6 +1449,7 @@ void cmGlobalGenerator::ComputeGeneratorTargetObjects() continue; } cmGeneratorTarget* gt = ti->second; + this->ComputeTargetObjectDirectory(gt); gt->LookupObjectLibraries(); this->ComputeTargetObjects(gt); } @@ -1515,9 +1516,31 @@ cmGlobalGenerator::GetGeneratorTarget(cmTarget const* t) const } //---------------------------------------------------------------------------- -void cmGlobalGenerator::ComputeTargetObjects(cmGeneratorTarget*) const +void cmGlobalGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const +{ + std::vector objectSources; + gt->GetObjectSources(objectSources); + + std::map mapping; + for(std::vector::const_iterator it + = objectSources.begin(); it != objectSources.end(); ++it) + { + mapping[*it]; + } + + gt->LocalGenerator->ComputeObjectFilenames(mapping, gt); + + for(std::map::const_iterator it + = mapping.begin(); it != mapping.end(); ++it) + { + assert(!it->second.empty()); + gt->AddObject(it->first, it->second); + } +} + +//---------------------------------------------------------------------------- +void cmGlobalGenerator::ComputeTargetObjectDirectory(cmGeneratorTarget*) const { - // Implemented in generator subclasses that need this. } void cmGlobalGenerator::CheckLocalGenerators() diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 91e71a82d..49a418d73 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -323,6 +323,8 @@ public: GetExportedTargetsFile(const std::string &filename) const; void AddCMP0042WarnTarget(const std::string& target); + virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; + protected: typedef std::vector GeneratorVector; // for a project collect all its targets by following depend @@ -441,7 +443,7 @@ private: void CreateGeneratorTargets(cmMakefile* mf); void CreateGeneratorTargets(); void ComputeGeneratorTargetObjects(); - virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const; + void ComputeTargetObjects(cmGeneratorTarget* gt) const; void ClearGeneratorMembers(); diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 0a05f5a3e..49ce1b52a 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -19,6 +19,7 @@ #include "cmVersion.h" #include +#include const char* cmGlobalNinjaGenerator::NINJA_BUILD_FILE = "build.ninja"; const char* cmGlobalNinjaGenerator::NINJA_RULES_FILE = "rules.ninja"; @@ -631,8 +632,9 @@ std::string cmGlobalNinjaGenerator::GetEditCacheCommand() const return cmSystemTools::GetCMakeGUICommand(); } -// TODO: Refactor to combine with cmGlobalUnixMakefileGenerator3 impl. -void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const +//---------------------------------------------------------------------------- +void cmGlobalNinjaGenerator +::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const { cmTarget* target = gt->Target; @@ -643,19 +645,6 @@ void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const dir_max += gt->LocalGenerator->GetTargetDirectory(*target); dir_max += "/"; gt->ObjectDirectory = dir_max; - - std::vector objectSources; - gt->GetObjectSources(objectSources); - // Compute the name of each object file. - for(std::vector::iterator - si = objectSources.begin(); - si != objectSources.end(); ++si) - { - cmSourceFile* sf = *si; - std::string objectName = gt->LocalGenerator - ->GetObjectFileNameWithoutTarget(*sf, dir_max); - gt->AddObject(sf, objectName); - } } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 7725cf352..f2643af2d 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -299,7 +299,7 @@ public: void AddTargetAlias(const std::string& alias, cmTarget* target); - + virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; protected: /// Overloaded methods. @@ -310,8 +310,6 @@ protected: private: virtual std::string GetEditCacheCommand() const; - /// @see cmGlobalGenerator::ComputeTargetObjects - virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const; void OpenBuildFileStream(); void CloseBuildFileStream(); diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index f5c56a987..4632071bf 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -106,11 +106,9 @@ std::string cmGlobalUnixMakefileGenerator3::GetEditCacheCommand() const //---------------------------------------------------------------------------- void cmGlobalUnixMakefileGenerator3 -::ComputeTargetObjects(cmGeneratorTarget* gt) const +::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const { cmTarget* target = gt->Target; - cmLocalUnixMakefileGenerator3* lg = - static_cast(gt->LocalGenerator); // Compute full path to object file directory for this target. std::string dir_max; @@ -119,22 +117,6 @@ cmGlobalUnixMakefileGenerator3 dir_max += gt->LocalGenerator->GetTargetDirectory(*target); dir_max += "/"; gt->ObjectDirectory = dir_max; - - std::vector objectSources; - gt->GetObjectSources(objectSources); - // Compute the name of each object file. - for(std::vector::iterator - si = objectSources.begin(); - si != objectSources.end(); ++si) - { - cmSourceFile* sf = *si; - bool hasSourceExtension = true; - std::string objectName = gt->LocalGenerator - ->GetObjectFileNameWithoutTarget(*sf, dir_max, - &hasSourceExtension); - gt->AddObject(sf, objectName); - lg->AddLocalObjectFile(target, sf, objectName, hasSourceExtension); - } } void cmGlobalUnixMakefileGenerator3::Configure() diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 811517627..d003789eb 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -128,6 +128,7 @@ public: /** Does the make tool tolerate .NOTPARALLEL? */ virtual bool AllowNotParallel() const { return true; } + virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; protected: void WriteMainMakefile2(); void WriteMainCMakefile(); @@ -198,7 +199,6 @@ protected: private: virtual const char* GetBuildIgnoreErrorsFlag() const { return "-i"; } virtual std::string GetEditCacheCommand() const; - virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const; }; #endif diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 840e8888e..37a416b3b 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -470,7 +470,7 @@ cmGlobalVisualStudio10Generator //---------------------------------------------------------------------------- void cmGlobalVisualStudio10Generator::PathTooLong( - cmTarget* target, cmSourceFile* sf, std::string const& sfRel) + cmTarget* target, cmSourceFile const* sf, std::string const& sfRel) { size_t len = (strlen(target->GetMakefile()->GetCurrentOutputDirectory()) + 1 + sfRel.length()); diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 999a9d54c..ede6b1b98 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -87,7 +87,7 @@ public: /** Generate an .rule file path for a given command output. */ virtual std::string GenerateRuleFile(std::string const& output) const; - void PathTooLong(cmTarget* target, cmSourceFile* sf, + void PathTooLong(cmTarget* target, cmSourceFile const* sf, std::string const& sfRel); virtual const char* GetToolsVersion() { return "4.0"; } @@ -112,7 +112,7 @@ private: LongestSourcePath(): Length(0), Target(0), SourceFile(0) {} size_t Length; cmTarget* Target; - cmSourceFile* SourceFile; + cmSourceFile const* SourceFile; std::string SourceRel; }; LongestSourcePath LongestSource; diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 2b2a4715c..38f709f42 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -119,51 +119,12 @@ void cmGlobalVisualStudioGenerator::Generate() } //---------------------------------------------------------------------------- -void -cmGlobalVisualStudioGenerator -::ComputeTargetObjects(cmGeneratorTarget* gt) const +void cmGlobalVisualStudioGenerator +::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const { - cmLocalVisualStudioGenerator* lg = - static_cast(gt->LocalGenerator); - std::string dir_max = lg->ComputeLongestObjectDirectory(*gt->Target); - - // Count the number of object files with each name. Note that - // windows file names are not case sensitive. - std::map counts; - std::vector objectSources; - gt->GetObjectSources(objectSources); - for(std::vector::const_iterator - si = objectSources.begin(); - si != objectSources.end(); ++si) - { - cmSourceFile* sf = *si; - std::string objectNameLower = cmSystemTools::LowerCase( - cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath())); - objectNameLower += ".obj"; - counts[objectNameLower] += 1; - } - - // For all source files producing duplicate names we need unique - // object name computation. - for(std::vector::const_iterator - si = objectSources.begin(); - si != objectSources.end(); ++si) - { - cmSourceFile* sf = *si; - std::string objectName = - cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); - objectName += ".obj"; - if(counts[cmSystemTools::LowerCase(objectName)] > 1) - { - gt->AddExplicitObjectName(sf); - objectName = lg->GetObjectFileNameWithoutTarget(*sf, dir_max); - } - gt->AddObject(sf, objectName); - } - std::string dir = gt->Makefile->GetCurrentOutputDirectory(); dir += "/"; - std::string tgtDir = lg->GetTargetDirectory(*gt->Target); + std::string tgtDir = gt->LocalGenerator->GetTargetDirectory(*gt->Target); if(!tgtDir.empty()) { dir += tgtDir; @@ -919,4 +880,4 @@ std::string cmGlobalVisualStudioGenerator::ExpandCFGIntDir( i += config.size(); } return tmp; -} \ No newline at end of file +} diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 7e8dcf8b7..1ab899097 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -88,6 +88,7 @@ public: virtual std::string ExpandCFGIntDir(const std::string& str, const std::string& config) const; + void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; protected: // Does this VS version link targets to each other if there are // dependencies in the SLN file? This was done for VS versions @@ -116,7 +117,6 @@ private: virtual std::string GetVSMakeProgram() = 0; void PrintCompilerAdvice(std::ostream&, std::string const&, const char*) const {} - void ComputeTargetObjects(cmGeneratorTarget* gt) const; void FollowLinkDepends(cmTarget const* target, std::set& linked); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 36196a23a..d4eb85bc6 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3934,37 +3934,10 @@ bool cmGlobalXCodeGenerator::IsMultiConfig() return true; } - //---------------------------------------------------------------------------- -void -cmGlobalXCodeGenerator -::ComputeTargetObjects(cmGeneratorTarget* gt) const +//---------------------------------------------------------------------------- +void cmGlobalXCodeGenerator +::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const { - // Count the number of object files with each name. Warn about duplicate - // names since Xcode names them uniquely automatically with a numeric suffix - // to avoid exact duplicate file names. Note that Mac file names are not - // typically case sensitive, hence the LowerCase. - std::map counts; - std::vector objectSources; - gt->GetObjectSources(objectSources); - for(std::vector::const_iterator - si = objectSources.begin(); - si != objectSources.end(); ++si) - { - cmSourceFile* sf = *si; - std::string objectName = - cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); - objectName += ".o"; - - std::string objectNameLower = cmSystemTools::LowerCase(objectName); - counts[objectNameLower] += 1; - if (2 == counts[objectNameLower]) - { - // TODO: emit warning about duplicate name? - } - - gt->AddObject(sf, objectName); - } - const char* configName = this->GetCMakeCFGIntDir(); std::string dir = this->GetObjectsNormalDirectory( "$(PROJECT_NAME)", configName, gt->Target); diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index be81cdc4c..23616b4f9 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -204,6 +204,7 @@ private: std::vector const& defines, bool dflag = false); + void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; protected: virtual const char* GetInstallTargetName() const { return "install"; } virtual const char* GetPackageTargetName() const { return "package"; } @@ -216,7 +217,6 @@ protected: private: void PrintCompilerAdvice(std::ostream&, std::string const&, const char*) const {} - void ComputeTargetObjects(cmGeneratorTarget* gt) const; std::string GetObjectsNormalDirectory( const std::string &projName, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index ebcfa08c5..c63de792b 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -3080,6 +3080,14 @@ cmLocalGenerator return it->second; } +//---------------------------------------------------------------------------- +void cmLocalGenerator::ComputeObjectFilenames( + std::map&, + cmGeneratorTarget const*) +{ + +} + //---------------------------------------------------------------------------- std::string cmLocalGenerator diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index afcaee9b5..61488fecd 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -372,6 +372,10 @@ public: std::string& linkPath, cmGeneratorTarget* target); + virtual void ComputeObjectFilenames( + std::map& mapping, + cmGeneratorTarget const* gt = 0); + protected: ///! put all the libraries for a target on into the given stream virtual void OutputLinkLibraries(std::string& linkLibraries, diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 7c4aab87c..2f763cecf 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -267,6 +267,20 @@ void cmLocalNinjaGenerator::SetConfigName() } } +//---------------------------------------------------------------------------- +void cmLocalNinjaGenerator::ComputeObjectFilenames( + std::map& mapping, + cmGeneratorTarget const* gt) +{ + for(std::map::iterator + si = mapping.begin(); si != mapping.end(); ++si) + { + cmSourceFile const* sf = si->first; + si->second = this->GetObjectFileNameWithoutTarget(*sf, + gt->ObjectDirectory); + } +} + void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os) { cmGlobalNinjaGenerator::WriteDivider(os); diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 9d0b7b5bc..e91e60b1b 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -101,6 +101,10 @@ public: virtual std::string ConvertToLinkReference(std::string const& lib, OutputFormat format = SHELL); + virtual void ComputeObjectFilenames( + std::map& mapping, + cmGeneratorTarget const* gt = 0); + protected: virtual std::string ConvertToIncludeReference(std::string const& path, diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 9f12ffef7..2d3608925 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -172,26 +172,71 @@ void cmLocalUnixMakefileGenerator3::Generate() } //---------------------------------------------------------------------------- -void cmLocalUnixMakefileGenerator3::AddLocalObjectFile( - cmTarget* target, cmSourceFile* sf, std::string objNoTargetDir, - bool hasSourceExtension) +void cmLocalUnixMakefileGenerator3::ComputeObjectFilenames( + std::map& mapping, + cmGeneratorTarget const* gt) { - if(cmSystemTools::FileIsFullPath(objNoTargetDir.c_str())) + for(std::map::iterator + si = mapping.begin(); si != mapping.end(); ++si) { - objNoTargetDir = cmSystemTools::GetFilenameName(objNoTargetDir); + cmSourceFile const* sf = si->first; + si->second = this->GetObjectFileNameWithoutTarget(*sf, + gt->ObjectDirectory); + } +} + +//---------------------------------------------------------------------------- +void cmLocalUnixMakefileGenerator3:: +GetLocalObjectFiles(std::map &localObjectFiles) +{ + std::set emitted; + cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator ti = targets.begin(); + ti != targets.end(); ++ti) + { + cmGeneratorTarget* gt = ti->second; + if (gt->GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } + std::vector objectSources; + gt->GetObjectSources(objectSources); + // Compute full path to object file directory for this target. + std::string dir_max; + dir_max += gt->Makefile->GetCurrentOutputDirectory(); + dir_max += "/"; + dir_max += this->GetTargetDirectory(*gt->Target); + dir_max += "/"; + // Compute the name of each object file. + for(std::vector::iterator + si = objectSources.begin(); + si != objectSources.end(); ++si) + { + cmSourceFile const* sf = *si; + bool hasSourceExtension = true; + std::string objectName = this->GetObjectFileNameWithoutTarget(*sf, + dir_max, + &hasSourceExtension); + if(cmSystemTools::FileIsFullPath(objectName.c_str())) + { + objectName = cmSystemTools::GetFilenameName(objectName); + } + LocalObjectInfo& info = localObjectFiles[objectName]; + info.HasSourceExtension = hasSourceExtension; + info.push_back(LocalObjectEntry(gt->Target, sf->GetLanguage())); + } } - LocalObjectInfo& info = this->LocalObjectFiles[objNoTargetDir]; - info.HasSourceExtension = hasSourceExtension; - info.push_back(LocalObjectEntry(target, sf->GetLanguage())); } //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3::GetIndividualFileTargets (std::vector& targets) { + std::map localObjectFiles; + this->GetLocalObjectFiles(localObjectFiles); for (std::map::iterator lo = - this->LocalObjectFiles.begin(); - lo != this->LocalObjectFiles.end(); ++lo) + localObjectFiles.begin(); + lo != localObjectFiles.end(); ++lo) { targets.push_back(lo->first); @@ -253,11 +298,14 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() bool do_assembly_rules = this->GetCreateAssemblySourceRules(); + std::map localObjectFiles; + this->GetLocalObjectFiles(localObjectFiles); + // now write out the object rules // for each object file name for (std::map::iterator lo = - this->LocalObjectFiles.begin(); - lo != this->LocalObjectFiles.end(); ++lo) + localObjectFiles.begin(); + lo != localObjectFiles.end(); ++lo) { // Add a convenience rule for building the object file. this->WriteObjectConvenienceRule(ruleFileStream, diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index d5042472d..14543fbaa 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -224,10 +224,6 @@ public: // write the target rules for the local Makefile into the stream void WriteLocalAllRules(std::ostream& ruleFileStream); - void AddLocalObjectFile(cmTarget* target, cmSourceFile* sf, - std::string objNoTargetDir, - bool hasSourceExtension); - std::vector const& GetLocalHelp() { return this->LocalHelp; } /** Get whether to create rules to generate preprocessed and @@ -317,6 +313,10 @@ private: std::string MakeLauncher(cmCustomCommandGenerator const& ccg, cmTarget* target, RelativeRoot relative); + virtual void ComputeObjectFilenames( + std::map& mapping, + cmGeneratorTarget const* gt = 0); + friend class cmMakefileTargetGenerator; friend class cmMakefileExecutableTargetGenerator; friend class cmMakefileLibraryTargetGenerator; @@ -366,7 +366,9 @@ private: LocalObjectInfo():HasSourceExtension(false), HasPreprocessRule(false), HasAssembleRule(false) {} }; - std::map LocalObjectFiles; + void GetLocalObjectFiles( + std::map &localObjectFiles); + void WriteObjectConvenienceRule(std::ostream& ruleFileStream, const char* comment, const char* output, LocalObjectInfo const& info); diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 613ee975c..9680d43b1 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -30,6 +30,46 @@ cmLocalVisualStudioGenerator::~cmLocalVisualStudioGenerator() { } +//---------------------------------------------------------------------------- +void cmLocalVisualStudioGenerator::ComputeObjectFilenames( + std::map& mapping, + cmGeneratorTarget const* gt) +{ + std::string dir_max = this->ComputeLongestObjectDirectory(*gt->Target); + + // Count the number of object files with each name. Note that + // windows file names are not case sensitive. + std::map counts; + + for(std::map::iterator + si = mapping.begin(); si != mapping.end(); ++si) + { + cmSourceFile const* sf = si->first; + std::string objectNameLower = cmSystemTools::LowerCase( + cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath())); + objectNameLower += ".obj"; + counts[objectNameLower] += 1; + } + + // For all source files producing duplicate names we need unique + // object name computation. + + for(std::map::iterator + si = mapping.begin(); si != mapping.end(); ++si) + { + cmSourceFile const* sf = si->first; + std::string objectName = + cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); + objectName += ".obj"; + if(counts[cmSystemTools::LowerCase(objectName)] > 1) + { + const_cast(gt)->AddExplicitObjectName(sf); + objectName = this->GetObjectFileNameWithoutTarget(*sf, dir_max); + } + si->second = objectName; + } +} + //---------------------------------------------------------------------------- cmsys::auto_ptr cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmTarget& target, diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h index a89e21930..3bf4f4339 100644 --- a/Source/cmLocalVisualStudioGenerator.h +++ b/Source/cmLocalVisualStudioGenerator.h @@ -61,6 +61,10 @@ public: virtual void AddCMakeListsRules() = 0; + virtual void ComputeObjectFilenames( + std::map& mapping, + cmGeneratorTarget const* = 0); + protected: virtual const char* ReportErrorLabel() const; virtual bool CustomCommandUseLocal() const { return false; } diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx index 5857aefa0..8ff6c87d6 100644 --- a/Source/cmLocalXCodeGenerator.cxx +++ b/Source/cmLocalXCodeGenerator.cxx @@ -71,3 +71,31 @@ void cmLocalXCodeGenerator::GenerateInstallRules() t->HasMacOSXRpathInstallNameDir(""); } } + +//---------------------------------------------------------------------------- +void cmLocalXCodeGenerator::ComputeObjectFilenames( + std::map& mapping, + cmGeneratorTarget const*) +{ + // Count the number of object files with each name. Warn about duplicate + // names since Xcode names them uniquely automatically with a numeric suffix + // to avoid exact duplicate file names. Note that Mac file names are not + // typically case sensitive, hence the LowerCase. + std::map counts; + for(std::map::iterator + si = mapping.begin(); si != mapping.end(); ++si) + { + cmSourceFile const* sf = si->first; + std::string objectName = + cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); + objectName += ".o"; + + std::string objectNameLower = cmSystemTools::LowerCase(objectName); + counts[objectNameLower] += 1; + if (2 == counts[objectNameLower]) + { + // TODO: emit warning about duplicate name? + } + si->second = objectName; + } +} diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h index 3bfe3a30a..f553a17ef 100644 --- a/Source/cmLocalXCodeGenerator.h +++ b/Source/cmLocalXCodeGenerator.h @@ -32,6 +32,9 @@ public: const std::string& rawFlag); virtual void Generate(); virtual void GenerateInstallRules(); + virtual void ComputeObjectFilenames( + std::map& mapping, + cmGeneratorTarget const* gt = 0); private: }; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 3161abaf5..6759d050e 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -153,9 +153,9 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() // First generate the object rule files. Save a list of all object // files for this target. - std::vector customCommands; + std::vector customCommands; this->GeneratorTarget->GetCustomCommands(customCommands); - for(std::vector::const_iterator + for(std::vector::const_iterator si = customCommands.begin(); si != customCommands.end(); ++si) { @@ -176,27 +176,27 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() } } } - std::vector headerSources; + std::vector headerSources; this->GeneratorTarget->GetHeaderSources(headerSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( headerSources, this->MacOSXContentGenerator); - std::vector extraSources; + std::vector extraSources; this->GeneratorTarget->GetExtraSources(extraSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( extraSources, this->MacOSXContentGenerator); - std::vector externalObjects; + std::vector externalObjects; this->GeneratorTarget->GetExternalObjects(externalObjects); - for(std::vector::const_iterator + for(std::vector::const_iterator si = externalObjects.begin(); si != externalObjects.end(); ++si) { this->ExternalObjects.push_back((*si)->GetFullPath()); } - std::vector objectSources; + std::vector objectSources; this->GeneratorTarget->GetObjectSources(objectSources); - for(std::vector::const_iterator + for(std::vector::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { // Generate this object file's rule file. @@ -373,7 +373,7 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() //---------------------------------------------------------------------------- void cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator() - (cmSourceFile& source, const char* pkgloc) + (cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. if(!this->Generator->GetTarget()->IsBundleOnApple()) @@ -423,7 +423,8 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator() } //---------------------------------------------------------------------------- -void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source) +void cmMakefileTargetGenerator +::WriteObjectRuleFiles(cmSourceFile const& source) { // Identify the language of the source file. const std::string& lang = @@ -498,7 +499,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source) //---------------------------------------------------------------------------- void cmMakefileTargetGenerator -::AppendFortranFormatFlags(std::string& flags, cmSourceFile& source) +::AppendFortranFormatFlags(std::string& flags, cmSourceFile const& source) { const char* srcfmt = source.GetProperty("Fortran_FORMAT"); cmLocalGenerator::FortranFormat format = @@ -529,7 +530,7 @@ void cmMakefileTargetGenerator ::WriteObjectBuildFile(std::string &obj, const std::string& lang, - cmSourceFile& source, + cmSourceFile const& source, std::vector& depends) { this->LocalGenerator->AppendRuleDepend(depends, @@ -1194,7 +1195,7 @@ cmMakefileTargetGenerator //---------------------------------------------------------------------------- void cmMakefileTargetGenerator -::WriteObjectDependRules(cmSourceFile& source, +::WriteObjectDependRules(cmSourceFile const& source, std::vector& depends) { // Create the list of dependencies known at cmake time. These are diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 97c58b982..7ff6da9c1 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -81,7 +81,7 @@ protected: MacOSXContentGeneratorType(cmMakefileTargetGenerator* gen) : Generator(gen) {} - void operator()(cmSourceFile& source, const char* pkgloc); + void operator()(cmSourceFile const& source, const char* pkgloc); private: cmMakefileTargetGenerator* Generator; @@ -89,16 +89,16 @@ protected: friend struct MacOSXContentGeneratorType; // write the rules for an object - void WriteObjectRuleFiles(cmSourceFile& source); + void WriteObjectRuleFiles(cmSourceFile const& source); // write the build rule for an object void WriteObjectBuildFile(std::string &obj, const std::string& lang, - cmSourceFile& source, + cmSourceFile const& source, std::vector& depends); // write the depend.make file for an object - void WriteObjectDependRules(cmSourceFile& source, + void WriteObjectDependRules(cmSourceFile const& source, std::vector& depends); // write the build rule for a custom command @@ -126,7 +126,8 @@ protected: // Return the a string with -F flags on apple std::string GetFrameworkFlags(std::string const& l); - void AppendFortranFormatFlags(std::string& flags, cmSourceFile& source); + void AppendFortranFormatFlags(std::string& flags, + cmSourceFile const& source); // append intertarget dependencies void AppendTargetDepends(std::vector& depends); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index ed3782c2a..4319f3cb3 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -126,7 +126,7 @@ void cmNinjaTargetGenerator::AddFeatureFlags(std::string& flags, // void cmMakefileTargetGenerator::WriteTargetLanguageFlags() // Refactor it. std::string -cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, +cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source, const std::string& language) { // TODO: Fortran support. @@ -211,7 +211,7 @@ bool cmNinjaTargetGenerator::needsDepFile(const std::string& lang) // void cmMakefileTargetGenerator::WriteTargetLanguageFlags(). std::string cmNinjaTargetGenerator:: -ComputeDefines(cmSourceFile *source, const std::string& language) +ComputeDefines(cmSourceFile const* source, const std::string& language) { std::set defines; @@ -269,14 +269,14 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const std::string cmNinjaTargetGenerator -::GetSourceFilePath(cmSourceFile* source) const +::GetSourceFilePath(cmSourceFile const* source) const { return ConvertToNinjaPath(source->GetFullPath().c_str()); } std::string cmNinjaTargetGenerator -::GetObjectFilePath(cmSourceFile* source) const +::GetObjectFilePath(cmSourceFile const* source) const { std::string path = this->LocalGenerator->GetHomeRelativeOutputPath(); if(!path.empty()) @@ -480,36 +480,36 @@ cmNinjaTargetGenerator << this->GetTargetName() << "\n\n"; - std::vector customCommands; + std::vector customCommands; this->GeneratorTarget->GetCustomCommands(customCommands); - for(std::vector::const_iterator + for(std::vector::const_iterator si = customCommands.begin(); si != customCommands.end(); ++si) { cmCustomCommand const* cc = (*si)->GetCustomCommand(); this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget()); } - std::vector headerSources; + std::vector headerSources; this->GeneratorTarget->GetHeaderSources(headerSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( headerSources, this->MacOSXContentGenerator); - std::vector extraSources; + std::vector extraSources; this->GeneratorTarget->GetExtraSources(extraSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( extraSources, this->MacOSXContentGenerator); - std::vector externalObjects; + std::vector externalObjects; this->GeneratorTarget->GetExternalObjects(externalObjects); - for(std::vector::const_iterator + for(std::vector::const_iterator si = externalObjects.begin(); si != externalObjects.end(); ++si) { this->Objects.push_back(this->GetSourceFilePath(*si)); } - std::vector objectSources; + std::vector objectSources; this->GeneratorTarget->GetObjectSources(objectSources); - for(std::vector::const_iterator + for(std::vector::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { this->WriteObjectBuildStatement(*si); @@ -536,7 +536,7 @@ cmNinjaTargetGenerator void cmNinjaTargetGenerator -::WriteObjectBuildStatement(cmSourceFile* source) +::WriteObjectBuildStatement(cmSourceFile const* source) { std::string comment; const std::string language = source->GetLanguage(); @@ -570,9 +570,9 @@ cmNinjaTargetGenerator } // Add order-only dependencies on custom command outputs. - std::vector customCommands; + std::vector customCommands; this->GeneratorTarget->GetCustomCommands(customCommands); - for(std::vector::const_iterator + for(std::vector::const_iterator si = customCommands.begin(); si != customCommands.end(); ++si) { @@ -733,7 +733,7 @@ cmNinjaTargetGenerator //---------------------------------------------------------------------------- void cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()( - cmSourceFile& source, const char* pkgloc) + cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. if(!this->Generator->GetTarget()->IsBundleOnApple()) diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index e66e55fef..8669e6e34 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -79,10 +79,10 @@ protected: * @note Generally it is the value of the variable whose name is computed * by LanguageFlagsVarName(). */ - std::string ComputeFlagsForObject(cmSourceFile *source, + std::string ComputeFlagsForObject(cmSourceFile const* source, const std::string& language); - std::string ComputeDefines(cmSourceFile *source, + std::string ComputeDefines(cmSourceFile const* source, const std::string& language); std::string ConvertToNinjaPath(const char *path) const { @@ -96,10 +96,10 @@ protected: cmNinjaDeps ComputeLinkDeps() const; /// @return the source file path for the given @a source. - std::string GetSourceFilePath(cmSourceFile* source) const; + std::string GetSourceFilePath(cmSourceFile const* source) const; /// @return the object file path for the given @a source. - std::string GetObjectFilePath(cmSourceFile* source) const; + std::string GetObjectFilePath(cmSourceFile const* source) const; /// @return the file path where the target named @a name is generated. std::string GetTargetFilePath(const std::string& name) const; @@ -110,7 +110,7 @@ protected: void WriteLanguageRules(const std::string& language); void WriteCompileRule(const std::string& language); void WriteObjectBuildStatements(); - void WriteObjectBuildStatement(cmSourceFile* source); + void WriteObjectBuildStatement(cmSourceFile const* source); void WriteCustomCommandBuildStatement(cmCustomCommand *cc); cmNinjaDeps GetObjects() const @@ -129,7 +129,7 @@ protected: MacOSXContentGeneratorType(cmNinjaTargetGenerator* g) : Generator(g) {} - void operator()(cmSourceFile& source, const char* pkgloc); + void operator()(cmSourceFile const& source, const char* pkgloc); private: cmNinjaTargetGenerator* Generator; diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 835f892ba..6f16913d6 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -190,13 +190,14 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, //---------------------------------------------------------------------------- void cmOSXBundleGenerator:: -GenerateMacOSXContentStatements(std::vector const& sources, - MacOSXContentGeneratorType* generator) +GenerateMacOSXContentStatements( + std::vector const& sources, + MacOSXContentGeneratorType* generator) { if (this->MustSkip()) return; - for(std::vector::const_iterator + for(std::vector::const_iterator si = sources.begin(); si != sources.end(); ++si) { cmGeneratorTarget::SourceFileFlags tsFlags = diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h index 95b4aef6c..f945c15a8 100644 --- a/Source/cmOSXBundleGenerator.h +++ b/Source/cmOSXBundleGenerator.h @@ -44,11 +44,12 @@ public: struct MacOSXContentGeneratorType { virtual ~MacOSXContentGeneratorType() {} - virtual void operator()(cmSourceFile& source, const char* pkgloc) = 0; + virtual void operator()(cmSourceFile const& source, + const char* pkgloc) = 0; }; void GenerateMacOSXContentStatements( - std::vector const& sources, + std::vector const& sources, MacOSXContentGeneratorType* generator); std::string InitMacOSXContentDirectory(const char* pkgloc); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 8e8968d9e..bb76b7f8a 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -378,12 +378,12 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences() void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() { - std::vector resxObjs; + std::vector resxObjs; this->GeneratorTarget->GetResxSources(resxObjs); if(!resxObjs.empty()) { this->WriteString("\n", 1); - for(std::vector::const_iterator oi = resxObjs.begin(); + for(std::vector::const_iterator oi = resxObjs.begin(); oi != resxObjs.end(); ++oi) { std::string obj = (*oi)->GetFullPath(); @@ -552,9 +552,9 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() void cmVisualStudio10TargetGenerator::WriteCustomCommands() { this->SourcesVisited.clear(); - std::vector customCommands; + std::vector customCommands; this->GeneratorTarget->GetCustomCommands(customCommands); - for(std::vector::const_iterator + for(std::vector::const_iterator si = customCommands.begin(); si != customCommands.end(); ++si) { @@ -563,7 +563,8 @@ void cmVisualStudio10TargetGenerator::WriteCustomCommands() } //---------------------------------------------------------------------------- -void cmVisualStudio10TargetGenerator::WriteCustomCommand(cmSourceFile* sf) +void cmVisualStudio10TargetGenerator +::WriteCustomCommand(cmSourceFile const* sf) { if(this->SourcesVisited.insert(sf).second) { @@ -586,7 +587,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomCommand(cmSourceFile* sf) } void -cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, +cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source, cmCustomCommand const & command) { @@ -747,12 +748,12 @@ void cmVisualStudio10TargetGenerator::WriteGroups() this->WriteGroupSources(ti->first.c_str(), ti->second, sourceGroups); } - std::vector resxObjs; + std::vector resxObjs; this->GeneratorTarget->GetResxSources(resxObjs); if(!resxObjs.empty()) { this->WriteString("\n", 1); - for(std::vector::const_iterator oi = resxObjs.begin(); + for(std::vector::const_iterator oi = resxObjs.begin(); oi != resxObjs.end(); ++oi) { std::string obj = (*oi)->GetFullPath(); @@ -903,7 +904,7 @@ WriteGroupSources(const char* name, for(ToolSources::const_iterator s = sources.begin(); s != sources.end(); ++s) { - cmSourceFile* sf = s->SourceFile; + cmSourceFile const* sf = s->SourceFile; std::string const& source = sf->GetFullPath(); cmSourceGroup* sourceGroup = this->Makefile->FindSourceGroup(source.c_str(), sourceGroups); @@ -930,7 +931,7 @@ WriteGroupSources(const char* name, } void cmVisualStudio10TargetGenerator::WriteSource( - const char* tool, cmSourceFile* sf, const char* end) + const char* tool, cmSourceFile const* sf, const char* end) { // Visual Studio tools append relative paths to the current dir, as in: // @@ -986,9 +987,9 @@ void cmVisualStudio10TargetGenerator::WriteSource( } void cmVisualStudio10TargetGenerator::WriteSources( - const char* tool, std::vector const& sources) + const char* tool, std::vector const& sources) { - for(std::vector::const_iterator + for(std::vector::const_iterator si = sources.begin(); si != sources.end(); ++si) { this->WriteSource(tool, *si); @@ -1003,16 +1004,16 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } this->WriteString("\n", 1); - std::vector headerSources; + std::vector headerSources; this->GeneratorTarget->GetHeaderSources(headerSources); this->WriteSources("ClInclude", headerSources); - std::vector idlSources; + std::vector idlSources; this->GeneratorTarget->GetIDLSources(idlSources); this->WriteSources("Midl", idlSources); - std::vector objectSources; + std::vector objectSources; this->GeneratorTarget->GetObjectSources(objectSources); - for(std::vector::const_iterator + for(std::vector::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { @@ -1051,7 +1052,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } } - std::vector externalObjects; + std::vector externalObjects; this->GeneratorTarget->GetExternalObjects(externalObjects); if(this->LocalGenerator->GetVersion() > cmLocalVisualStudioGenerator::VS10) { @@ -1063,7 +1064,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() { // If an object file is generated in this target, then vs10 will use // it in the build, and we have to list it as None instead of Object. - for(std::vector::const_iterator + for(std::vector::const_iterator si = externalObjects.begin(); si != externalObjects.end(); ++si) { @@ -1073,7 +1074,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } } - std::vector extraSources; + std::vector extraSources; this->GeneratorTarget->GetExtraSources(extraSources); this->WriteSources("None", extraSources); @@ -1093,9 +1094,9 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( - cmSourceFile* source) + cmSourceFile const* source) { - cmSourceFile& sf = *source; + cmSourceFile const& sf = *source; std::string objectName; if(this->GeneratorTarget->HasExplicitObjectName(&sf)) diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 02b951cc8..d72c6fd6a 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -45,7 +45,7 @@ public: private: struct ToolSource { - cmSourceFile* SourceFile; + cmSourceFile const* SourceFile; bool RelativePath; }; struct ToolSources: public std::vector {}; @@ -55,8 +55,10 @@ private: void WriteString(const char* line, int indentLevel); void WriteProjectConfigurations(); void WriteProjectConfigurationValues(); - void WriteSource(const char* tool, cmSourceFile* sf, const char* end = 0); - void WriteSources(const char* tool, std::vector const&); + void WriteSource(const char* tool, cmSourceFile const* sf, + const char* end = 0); + void WriteSources(const char* tool, + std::vector const&); void WriteAllSources(); void WriteDotNetReferences(); void WriteEmbeddedResourceGroup(); @@ -77,13 +79,13 @@ private: std::vector const & includes); void OutputIncludes(std::vector const & includes); void OutputLinkIncremental(std::string const& configName); - void WriteCustomRule(cmSourceFile* source, + void WriteCustomRule(cmSourceFile const* source, cmCustomCommand const & command); void WriteCustomCommands(); - void WriteCustomCommand(cmSourceFile* sf); + void WriteCustomCommand(cmSourceFile const* sf); void WriteGroups(); void WriteProjectReferences(); - bool OutputSourceSpecificFlags(cmSourceFile* source); + bool OutputSourceSpecificFlags(cmSourceFile const* source); void AddLibraries(cmComputeLinkInformation& cli, std::string& libstring); void WriteLibOptions(std::string const& config); void WriteEvents(std::string const& configName); @@ -111,7 +113,7 @@ private: cmGlobalVisualStudio10Generator* GlobalGenerator; cmGeneratedFileStream* BuildFileStream; cmLocalVisualStudio7Generator* LocalGenerator; - std::set SourcesVisited; + std::set SourcesVisited; typedef std::map ToolSourceMap; ToolSourceMap Tools;