From 9d653f9c1cc129be4fdce7f0e93c282760c7603e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 29 Aug 2015 18:05:46 +0200 Subject: cmFLTKWrapUI: Remove CMake 2.2 compat code. CMake 3.0 dropped CMake <= 2.4 compatibility. --- Source/cmFLTKWrapUICommand.cxx | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx index 12adfd9..d17d664 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -129,45 +129,6 @@ void cmFLTKWrapUICommand::FinalPass() cmSystemTools::Message(msg.c_str(),"Warning"); return; } - std::vector srcs; - target->GetSourceFiles(srcs, ""); - bool found = false; - for (unsigned int i = 0; i < srcs.size(); ++i) - { - if (srcs[i]->GetFullPath() == - this->GeneratedSourcesClasses[0]->GetFullPath()) - { - found = true; - break; - } - } - if (!found) - { - std::string msg = - "In CMake 2.2 the FLTK_WRAP_UI command sets a variable to the list of " - "source files that should be added to your executable or library. It " - "appears that you have not added these source files to your target. " - "You should change your CMakeLists.txt file to " - "directly add the generated files to the target. " - "For example FTLK_WRAP_UI(foo src1 src2 src3) " - "will create a variable named foo_FLTK_UI_SRCS that contains the list " - "of sources to add to your target when you call ADD_LIBRARY or " - "ADD_EXECUTABLE. For now CMake will add the sources to your target " - "for you as was done in CMake 2.0 and earlier. In the future this may " - "become an error."; - msg +="The problem was found while processing the source directory: "; - msg += this->Makefile->GetCurrentSourceDirectory(); - cmSystemTools::Message(msg.c_str(),"Warning"); - // first we add the rules for all the .fl to .h and .cxx files - size_t lastHeadersClass = this->GeneratedSourcesClasses.size(); - - // Generate code for all the .fl files - for(size_t classNum = 0; classNum < lastHeadersClass; classNum++) - { - this->Makefile->GetTargets()[this->Target] - .AddSource(this->GeneratedSourcesClasses[classNum]->GetFullPath()); - } - } } -- cgit v0.12 From bf28b7874b999224782fac72c5a74020bd6c47d3 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 29 Aug 2015 18:47:14 +0200 Subject: cmGeneratorTarget: Rename internal member. Leave the old name available for another use. --- Source/cmGeneratorTarget.cxx | 6 +++--- Source/cmGeneratorTarget.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 62598f4..4ed2939 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -406,8 +406,8 @@ std::string cmGeneratorTarget::GetOutputName(const std::string& config, std::vector const* cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const { - SourceEntriesType::const_iterator i = this->SourceEntries.find(sf); - if(i != this->SourceEntries.end()) + SourceEntriesType::const_iterator i = this->SourceDepends.find(sf); + if(i != this->SourceDepends.end()) { return &i->second.Depends; } @@ -1723,7 +1723,7 @@ void cmTargetTraceDependencies::Trace() // Get the next source from the queue. cmSourceFile* sf = this->SourceQueue.front(); this->SourceQueue.pop(); - this->CurrentEntry = &this->GeneratorTarget->SourceEntries[sf]; + this->CurrentEntry = &this->GeneratorTarget->SourceDepends[sf]; // Queue dependencies added explicitly by the user. if(const char* additionalDeps = sf->GetProperty("OBJECT_DEPENDS")) diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 916f281..6d5641b 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -370,7 +370,7 @@ private: friend class cmTargetTraceDependencies; struct SourceEntry { std::vector Depends; }; typedef std::map SourceEntriesType; - SourceEntriesType SourceEntries; + SourceEntriesType SourceDepends; mutable std::map Objects; std::set ExplicitObjectName; mutable std::map > SystemIncludesCache; -- cgit v0.12 From 01e666c70e9c83ebd8c200d121b706868f69e617 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 29 Aug 2015 18:32:24 +0200 Subject: cmTarget: Join strings conditionally. --- Source/cmTarget.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index bb44956..7fd8d86 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -768,9 +768,9 @@ void cmTarget::GetSourceFiles(std::vector &files, //---------------------------------------------------------------------------- void cmTarget::AddTracedSources(std::vector const& srcs) { - std::string srcFiles = cmJoin(srcs, ";"); - if (!srcFiles.empty()) + if (!srcs.empty()) { + std::string srcFiles = cmJoin(srcs, ";"); this->Internal->SourceFilesMap.clear(); this->LinkImplementationLanguageIsContextDependent = true; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); -- cgit v0.12 From 156bd2c983b439478dff5fe84629b5a93e780a92 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 24 Sep 2015 22:03:12 +0200 Subject: Xcode: Port away from unnecessary CMP0049 compatibility. The input does not need the conversion. --- Source/cmGlobalXCodeGenerator.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 746e1a7..64fa12a 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -463,7 +463,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, std::string listfile = mf->GetCurrentSourceDirectory(); listfile += "/"; listfile += "CMakeLists.txt"; - allbuild->AddSourceCMP0049(listfile.c_str()); + allbuild->AddSource(listfile.c_str()); // Add XCODE depend helper std::string dir = mf->GetCurrentBinaryDirectory(); @@ -557,7 +557,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, listfile = lg->GetMakefile()->GetCurrentSourceDirectory(); listfile += "/"; listfile += "CMakeLists.txt"; - target.AddSourceCMP0049(listfile.c_str()); + target.AddSource(listfile.c_str()); } } } -- cgit v0.12 From 7ce0991a7a29e244aee3f61e9e8b1879e59d156c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 6 Oct 2015 22:35:28 +0200 Subject: GHS: Port API to cmGeneratorTarget. --- Source/cmGhsMultiTargetGenerator.cxx | 14 ++++++++------ Source/cmGhsMultiTargetGenerator.h | 4 ++-- Source/cmGlobalGhsMultiGenerator.cxx | 3 ++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index cae5c2f..46ea2f3 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -27,7 +27,7 @@ cmGhsMultiTargetGenerator::cmGhsMultiTargetGenerator(cmGeneratorTarget *target) , LocalGenerator(static_cast( target->GetLocalGenerator())) , Makefile(target->Target->GetMakefile()) - , TargetGroup(DetermineIfTargetGroup(target->Target)) + , TargetGroup(DetermineIfTargetGroup(target)) , DynamicDownload(false) { this->RelBuildFilePath = this->GetRelBuildFilePath(target->Target); @@ -178,10 +178,11 @@ std::vector cmGhsMultiTargetGenerator::GetSources() const GhsMultiGpj::Types cmGhsMultiTargetGenerator::GetGpjTag() const { - return cmGhsMultiTargetGenerator::GetGpjTag(this->Target); + return cmGhsMultiTargetGenerator::GetGpjTag(this->GeneratorTarget); } -GhsMultiGpj::Types cmGhsMultiTargetGenerator::GetGpjTag(const cmTarget *target) +GhsMultiGpj::Types cmGhsMultiTargetGenerator::GetGpjTag( + const cmGeneratorTarget *target) { GhsMultiGpj::Types output; if (cmGhsMultiTargetGenerator::DetermineIfTargetGroup(target)) @@ -566,13 +567,14 @@ bool cmGhsMultiTargetGenerator::IsNotKernel(std::string const &config, return output; } -bool cmGhsMultiTargetGenerator::DetermineIfTargetGroup(const cmTarget *target) +bool cmGhsMultiTargetGenerator::DetermineIfTargetGroup( + const cmGeneratorTarget *target) { bool output = false; std::vector sources; std::string config = - target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"); - target->GetSourceFiles(sources, config); + target->Target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"); + target->Target->GetSourceFiles(sources, config); for (std::vector::const_iterator sources_i = sources.begin(); sources.end() != sources_i; ++sources_i) { diff --git a/Source/cmGhsMultiTargetGenerator.h b/Source/cmGhsMultiTargetGenerator.h index c29a31e..d1c17f4 100644 --- a/Source/cmGhsMultiTargetGenerator.h +++ b/Source/cmGhsMultiTargetGenerator.h @@ -36,7 +36,7 @@ public: bool IncludeThisTarget(); std::vector GetSources() const; GhsMultiGpj::Types GetGpjTag() const; - static GhsMultiGpj::Types GetGpjTag(const cmTarget *target); + static GhsMultiGpj::Types GetGpjTag(const cmGeneratorTarget* target); const char *GetAbsBuildFilePath() const { return this->AbsBuildFilePath.c_str(); @@ -95,7 +95,7 @@ private: std::string GetOutputFilename(const std::string &config) const; bool IsNotKernel(std::string const &config, const std::string &language); - static bool DetermineIfTargetGroup(const cmTarget *target); + static bool DetermineIfTargetGroup(const cmGeneratorTarget* target); bool DetermineIfDynamicDownload(std::string const &config, const std::string &language); diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 6dde1e3..1ad727a 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -509,7 +509,8 @@ void cmGlobalGhsMultiGenerator::UpdateBuildFiles( splitPath.back()); *this->TargetFolderBuildStreams[folderName] << foldNameRelBuildFile << " "; - GhsMultiGpj::WriteGpjTag(cmGhsMultiTargetGenerator::GetGpjTag(tgt), + GhsMultiGpj::WriteGpjTag(cmGhsMultiTargetGenerator::GetGpjTag( + tgtsI->second), this->TargetFolderBuildStreams[folderName]); } } -- cgit v0.12 From 5d3776a7ebb718ae6ed4724e0a8961cda68b6316 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 29 Aug 2015 17:51:15 +0200 Subject: Access sources through cmGeneratorTarget. --- Source/cmExtraCodeBlocksGenerator.cxx | 4 +++- Source/cmExtraCodeLiteGenerator.cxx | 4 +++- Source/cmExtraEclipseCDT4Generator.cxx | 4 +++- Source/cmExtraSublimeTextGenerator.cxx | 2 +- Source/cmGeneratorTarget.cxx | 8 ++++---- Source/cmGhsMultiTargetGenerator.cxx | 4 ++-- Source/cmGlobalGenerator.cxx | 4 +++- Source/cmGlobalGhsMultiGenerator.cxx | 3 ++- Source/cmGlobalKdevelopGenerator.cxx | 4 +++- Source/cmMakefileTargetGenerator.cxx | 2 +- Source/cmNinjaNormalTargetGenerator.cxx | 2 +- Source/cmNinjaUtilityTargetGenerator.cxx | 2 +- 12 files changed, 27 insertions(+), 16 deletions(-) diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index dfd51c7..7915a6e 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -401,7 +401,9 @@ void cmExtraCodeBlocksGenerator case cmTarget::UTILITY: // can have sources since 2.6.3 { std::vector sources; - ti->second.GetSourceFiles(sources, + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&ti->second); + gt->GetSourceFiles(sources, makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); for (std::vector::const_iterator si=sources.begin(); si!=sources.end(); si++) diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index c2cff14..496c1a8 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -196,7 +196,9 @@ void cmExtraCodeLiteGenerator case cmTarget::MODULE_LIBRARY: { std::vector sources; - ti->second.GetSourceFiles(sources, + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&ti->second); + gt->GetSourceFiles(sources, makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); for (std::vector::const_iterator si=sources.begin(); si!=sources.end(); si++) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 44bf586..6dc18c2 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -562,7 +562,9 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets( // get the files from the source lists then add them to the groups cmTarget* tgt = const_cast(&ti->second); std::vector files; - tgt->GetSourceFiles(files, + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(tgt); + gt->GetSourceFiles(files, makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); for(std::vector::const_iterator sfIt = files.begin(); sfIt != files.end(); diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 163a75b..11410a7 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -237,7 +237,7 @@ void cmExtraSublimeTextGenerator:: cmGeneratorTarget *gtgt = this->GlobalGenerator ->GetGeneratorTarget(target); std::vector sourceFiles; - target->GetSourceFiles(sourceFiles, + gtgt->GetSourceFiles(sourceFiles, makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); std::vector::const_iterator sourceFilesEnd = sourceFiles.end(); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4ed2939..3a865fc 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -449,7 +449,7 @@ static void handleSystemIncludesDep(cmMakefile *mf, cmTarget const* depTgt, #define IMPLEMENT_VISIT_IMPL(DATA, DATATYPE) \ { \ std::vector sourceFiles; \ - this->Target->GetSourceFiles(sourceFiles, config); \ + this->GetSourceFiles(sourceFiles, config); \ TagVisitor visitor(this, data); \ for(std::vector::const_iterator si = sourceFiles.begin(); \ si != sourceFiles.end(); ++si) \ @@ -1683,7 +1683,7 @@ cmTargetTraceDependencies ci != configs.end(); ++ci) { std::vector sources; - this->Target->GetSourceFiles(sources, *ci); + this->GeneratorTarget->GetSourceFiles(sources, *ci); for(std::vector::const_iterator si = sources.begin(); si != sources.end(); ++si) { @@ -4444,12 +4444,12 @@ bool cmGeneratorTarget::GetConfigCommonSourceFiles( std::vector::const_iterator it = configs.begin(); const std::string& firstConfig = *it; - this->Target->GetSourceFiles(files, firstConfig); + this->GetSourceFiles(files, firstConfig); for ( ; it != configs.end(); ++it) { std::vector configFiles; - this->Target->GetSourceFiles(configFiles, *it); + this->GetSourceFiles(configFiles, *it); if (configFiles != files) { std::string firstConfigFiles; diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 46ea2f3..bfcef43 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -172,7 +172,7 @@ std::vector cmGhsMultiTargetGenerator::GetSources() const { std::vector output; std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - this->Target->GetSourceFiles(output, config); + this->GeneratorTarget->GetSourceFiles(output, config); return output; } @@ -574,7 +574,7 @@ bool cmGhsMultiTargetGenerator::DetermineIfTargetGroup( std::vector sources; std::string config = target->Target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"); - target->Target->GetSourceFiles(sources, config); + target->GetSourceFiles(sources, config); for (std::vector::const_iterator sources_i = sources.begin(); sources.end() != sources_i; ++sources_i) { diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 05f1029..db842b0 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2949,10 +2949,12 @@ void cmGlobalGenerator::WriteSummary(cmTarget* target) { configs.push_back(""); } + cmGeneratorTarget* gt = + this->GetGeneratorTarget(target); for(std::vector::const_iterator ci = configs.begin(); ci != configs.end(); ++ci) { - target->GetSourceFiles(sources, *ci); + gt->GetSourceFiles(sources, *ci); } std::vector::const_iterator sourcesEnd = cmRemoveDuplicates(sources); diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 1ad727a..87cf58f 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -521,7 +521,8 @@ bool cmGlobalGhsMultiGenerator::IsTgtForBuild(const cmTarget *tgt) const std::string config = tgt->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"); std::vector tgtSources; - tgt->GetSourceFiles(tgtSources, config); + cmGeneratorTarget* gt = this->GetGeneratorTarget(tgt); + gt->GetSourceFiles(tgtSources, config); bool tgtInBuild = true; char const *excludeFromAll = tgt->GetProperty("EXCLUDE_FROM_ALL"); if (NULL != excludeFromAll && '1' == excludeFromAll[0] && diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index 138ddbb..c40f846 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -139,7 +139,9 @@ bool cmGlobalKdevelopGenerator ti != targets.end(); ti++) { std::vector sources; - ti->second.GetSourceFiles(sources, ti->second.GetMakefile() + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&ti->second); + gt->GetSourceFiles(sources, ti->second.GetMakefile() ->GetSafeDefinition("CMAKE_BUILD_TYPE")); for (std::vector::const_iterator si=sources.begin(); si!=sources.end(); si++) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index b278087..cd499f6 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1149,7 +1149,7 @@ cmMakefileTargetGenerator { // Depend on all custom command outputs. std::vector sources; - this->Target->GetSourceFiles(sources, + this->GeneratorTarget->GetSourceFiles(sources, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); for(std::vector::const_iterator source = sources.begin(); source != sources.end(); ++source) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 84c19a3..24fcaf4 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -112,7 +112,7 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules() // Write rules for languages compiled in this target. std::set languages; std::vector sourceFiles; - this->GetTarget()->GetSourceFiles(sourceFiles, + this->GetGeneratorTarget()->GetSourceFiles(sourceFiles, this->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE")); for(std::vector::const_iterator i = sourceFiles.begin(); i != sourceFiles.end(); ++i) diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index 58b901a..df43c61 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -58,7 +58,7 @@ void cmNinjaUtilityTargetGenerator::Generate() std::vector sources; std::string config = this->GetMakefile() ->GetSafeDefinition("CMAKE_BUILD_TYPE"); - this->GetTarget()->GetSourceFiles(sources, config); + this->GetGeneratorTarget()->GetSourceFiles(sources, config); for(std::vector::const_iterator source = sources.begin(); source != sources.end(); ++source) { -- cgit v0.12 From c38e30f68c7beffdc65af0f3799ae82ce60aaf67 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 29 Aug 2015 18:10:19 +0200 Subject: cmGeneratorTarget: Add methods for generate-time source addition. --- Source/cmGeneratorTarget.cxx | 12 +++++++++++- Source/cmGeneratorTarget.h | 3 +++ Source/cmGlobalVisualStudio8Generator.cxx | 2 +- Source/cmGlobalXCodeGenerator.cxx | 13 ++++++++----- Source/cmLocalVisualStudio6Generator.cxx | 6 ++++-- Source/cmLocalVisualStudio7Generator.cxx | 8 ++++++-- Source/cmQtAutoGeneratorInitializer.cxx | 4 ++-- 7 files changed, 35 insertions(+), 13 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 3a865fc..dc399d8 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -402,6 +402,16 @@ std::string cmGeneratorTarget::GetOutputName(const std::string& config, return i->second; } +void cmGeneratorTarget::AddSource(const std::string& src) +{ + this->Target->AddSource(src); +} + +void cmGeneratorTarget::AddTracedSources(std::vector const& srcs) +{ + this->Target->AddTracedSources(srcs); +} + //---------------------------------------------------------------------------- std::vector const* cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const @@ -1755,7 +1765,7 @@ void cmTargetTraceDependencies::Trace() } this->CurrentEntry = 0; - this->Target->AddTracedSources(this->NewSources); + this->GeneratorTarget->AddTracedSources(this->NewSources); } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 6d5641b..0c6ad82 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -296,6 +296,9 @@ public: // Get the target base name. std::string GetOutputName(const std::string& config, bool implib) const; + void AddSource(const std::string& src); + void AddTracedSources(std::vector const& srcs); + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 86a8f87..ab9d7e7 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -336,7 +336,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() no_main_dependency, commandLines, "Checking Build System", no_working_directory, true)) { - tgt->AddSource(file->GetFullPath()); + gt->AddSource(file->GetFullPath()); } else { diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 64fa12a..3d52e3a 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -463,7 +463,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, std::string listfile = mf->GetCurrentSourceDirectory(); listfile += "/"; listfile += "CMakeLists.txt"; - allbuild->AddSource(listfile.c_str()); + allBuildGt->AddSource(listfile.c_str()); // Add XCODE depend helper std::string dir = mf->GetCurrentBinaryDirectory(); @@ -553,11 +553,13 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, allbuild->AddUtility(target.GetName()); } + cmGeneratorTarget* targetGT = this->GetGeneratorTarget(&target); + // Refer to the build configuration file for easy editing. listfile = lg->GetMakefile()->GetCurrentSourceDirectory(); listfile += "/"; listfile += "CMakeLists.txt"; - target.AddSource(listfile.c_str()); + targetGT->AddSource(listfile.c_str()); } } } @@ -1401,7 +1403,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) if(cmSourceFile* sf = mf->GetOrCreateSource(fname.c_str())) { sf->SetProperty("LANGUAGE", llang.c_str()); - cmtarget.AddSource(fname); + gtgt->AddSource(fname); } } @@ -3069,17 +3071,18 @@ bool cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, continue; } + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); + // add the soon to be generated Info.plist file as a source for a // MACOSX_BUNDLE file if(cmtarget.GetPropertyAsBool("MACOSX_BUNDLE")) { std::string plist = this->ComputeInfoPListLocation(cmtarget); mf->GetOrCreateSource(plist, true); - cmtarget.AddSource(plist); + gtgt->AddSource(plist); } std::vector classes; - cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); if (!gtgt->GetConfigCommonSourceFiles(classes)) { return false; diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index cc94cd4..ab215d1 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -243,7 +243,8 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmTarget& tgt) no_working_directory, true); if(this->Makefile->GetSource(makefileIn.c_str())) { - tgt.AddSource(makefileIn); + cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(&tgt); + gt->AddSource(makefileIn); } else { @@ -595,7 +596,8 @@ cmLocalVisualStudio6Generator origCommand.GetCommandLines(), comment, origCommand.GetWorkingDirectory().c_str())) { - target.AddSource(outsf->GetFullPath()); + cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(&target); + gt->AddSource(outsf->GetFullPath()); } // Replace the dependencies with the output of this rule so that the diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index a4bce8a..8924564 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -112,7 +112,9 @@ void cmLocalVisualStudio7Generator::AddCMakeListsRules() } if(l->first != CMAKE_CHECK_BUILD_SYSTEM_TARGET) { - l->second.AddSource(sf->GetFullPath()); + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&l->second); + gt->AddSource(sf->GetFullPath()); } } } @@ -148,7 +150,9 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() force.c_str(), no_depends, no_main_dependency, force_commands, " ", 0, true)) { - tgt.AddSource(file->GetFullPath()); + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&tgt); + gt->AddSource(file->GetFullPath()); } } } diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index 2703f4c..378f132 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -101,7 +101,7 @@ static void SetupSourceFiles(cmGeneratorTarget const* target, fileIt != newRccFiles.end(); ++fileIt) { - const_cast(target->Target)->AddSource(*fileIt); + const_cast(target)->AddSource(*fileIt); } } @@ -709,7 +709,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenSources( makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", mocCppFile.c_str(), false); - target->Target->AddSource(mocCppFile); + target->AddSource(mocCppFile); } } -- cgit v0.12 From 64f73150b8e5e5cad216444c0468e8e59434d973 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 12 Sep 2015 21:29:33 +0200 Subject: cmTarget: Add API for generate-time source addition. This method is a refactoring artifact. It will be removed in a follow-up. --- Source/cmGeneratorTarget.cxx | 2 +- Source/cmTarget.cxx | 5 +++++ Source/cmTarget.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index dc399d8..83f9cd2 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -404,7 +404,7 @@ std::string cmGeneratorTarget::GetOutputName(const std::string& config, void cmGeneratorTarget::AddSource(const std::string& src) { - this->Target->AddSource(src); + this->Target->AddGenerateTimeSource(src); } void cmGeneratorTarget::AddTracedSources(std::vector const& srcs) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 7fd8d86..16378cc 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -960,6 +960,11 @@ cmSourceFile* cmTarget::AddSource(const std::string& src) return this->Makefile->GetOrCreateSource(src); } +void cmTarget::AddGenerateTimeSource(const std::string& src) +{ + this->AddSource(src); +} + //---------------------------------------------------------------------------- void cmTarget::MergeLinkLibraries( cmMakefile& mf, const std::string& selfname, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 3e71dbd..cbf2ca9 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -145,6 +145,7 @@ public: void AddTracedSources(std::vector const& srcs); cmSourceFile* AddSourceCMP0049(const std::string& src); cmSourceFile* AddSource(const std::string& src); + void AddGenerateTimeSource(const std::string& src); enum LinkLibraryType {GENERAL, DEBUG, OPTIMIZED}; -- cgit v0.12 From 776ff8eb0b8d790c63f8ad6bb6689620e6e04cb4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 12 Sep 2015 21:44:52 +0200 Subject: cmTarget: Add Compute API for sources. This method is a refactoring artifact. It will be removed in a follow-up. --- Source/cmGlobalGenerator.cxx | 1 + Source/cmGlobalVisualStudio8Generator.cxx | 1 + Source/cmGlobalVisualStudioGenerator.cxx | 1 + Source/cmGlobalXCodeGenerator.cxx | 2 ++ Source/cmQtAutoGeneratorInitializer.cxx | 2 ++ Source/cmTarget.cxx | 4 ++++ Source/cmTarget.h | 2 ++ 7 files changed, 13 insertions(+) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index db842b0..a62d534 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1538,6 +1538,7 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes, ti != targets.end(); ++ti) { cmTarget* t = &ti->second; + t->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg); this->GeneratorTargets[t] = gt; generatorTargets[t] = gt; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index ab9d7e7..5bace47 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -254,6 +254,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false, no_working_directory, no_depends, noCommandLines); + tgt->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg); mf->AddGeneratorTarget(tgt, gt); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index d45aa27..fd2d33a 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -86,6 +86,7 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets() no_depends, no_commands, false, "Build all projects"); + allBuild->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]); allBuild->GetMakefile()->AddGeneratorTarget(allBuild, gt); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 3d52e3a..14bc340 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -456,6 +456,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, no_working_directory, "echo", "Build all projects"); + allbuild->Compute(); cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root); mf->AddGeneratorTarget(allbuild, allBuildGt); @@ -491,6 +492,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, no_working_directory, "make", "-f", file.c_str()); + check->Compute(); cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root); mf->AddGeneratorTarget(check, checkGt); } diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index 378f132..1b1b98e 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -885,6 +885,8 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( /*byproducts=*/rcc_output, depends, commandLines, false, autogenComment.c_str()); + autogenTarget->Compute(); + cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); makefile->AddGeneratorTarget(autogenTarget, gt); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 16378cc..515b261 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -397,6 +397,10 @@ void CreatePropertyGeneratorExpressions( } } +void cmTarget::Compute() +{ +} + //---------------------------------------------------------------------------- void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile) { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index cbf2ca9..2f1671d 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -133,6 +133,8 @@ public: void AddPostBuildCommand(cmCustomCommand const &cmd) {this->PostBuildCommands.push_back(cmd);} + void Compute(); + /** * Get the list of the source files used by this target */ -- cgit v0.12 From fe113f0fd40696e50ac9aac48297466e3b649ad5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 21:46:15 +0200 Subject: cmTarget: Split storage of sources from genexes. --- Source/cmTarget.cxx | 89 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 39 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 515b261..6e1c488 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -126,7 +126,9 @@ public: std::vector CompileFeaturesBacktraces; std::vector CompileDefinitionsEntries; std::vector CompileDefinitionsBacktraces; - std::vector SourceEntries; + std::vector SourceEntries; + std::vector SourceBacktraces; + std::vector SourceItems; std::vector LinkImplementationPropertyEntries; void AddInterfaceEntries( @@ -385,7 +387,8 @@ void cmTarget::SetMakefile(cmMakefile* mf) void CreatePropertyGeneratorExpressions( std::vector const& entries, std::vector const& backtraces, - std::vector& items) + std::vector& items, + bool evaluateForBuildsystem = false) { std::vector::const_iterator btIt = backtraces.begin(); for (std::vector::const_iterator it = entries.begin(); @@ -393,12 +396,17 @@ void CreatePropertyGeneratorExpressions( { cmGeneratorExpression ge(*btIt); cmsys::auto_ptr cge = ge.Parse(*it); + cge->SetEvaluateForBuildsystem(evaluateForBuildsystem); items.push_back(new cmTargetInternals::TargetPropertyEntry(cge)); } } void cmTarget::Compute() { + CreatePropertyGeneratorExpressions( + this->Internal->SourceEntries, + this->Internal->SourceBacktraces, + this->Internal->SourceItems, true); } //---------------------------------------------------------------------------- @@ -649,13 +657,11 @@ void cmTarget::GetSourceFiles(std::vector &files, // for TARGET_OBJECTS instead for backwards compatibility with OLD // behavior of CMP0024 and CMP0026 only. - typedef cmTargetInternals::TargetPropertyEntry - TargetPropertyEntry; - for(std::vector::const_iterator + for(std::vector::const_iterator i = this->Internal->SourceEntries.begin(); i != this->Internal->SourceEntries.end(); ++i) { - std::string entry = (*i)->ge->GetInput(); + std::string const& entry = *i; std::vector items; cmSystemTools::ExpandListArgument(entry, items); @@ -697,7 +703,7 @@ void cmTarget::GetSourceFiles(std::vector &files, UNORDERED_SET uniqueSrcs; bool contextDependentDirectSources = processSources(this, - this->Internal->SourceEntries, + this->Internal->SourceItems, files, uniqueSrcs, &dagChecker, @@ -778,10 +784,12 @@ void cmTarget::AddTracedSources(std::vector const& srcs) this->Internal->SourceFilesMap.clear(); this->LinkImplementationLanguageIsContextDependent = true; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + this->Internal->SourceEntries.push_back(srcFiles); + this->Internal->SourceBacktraces.push_back(lfbt); cmGeneratorExpression ge(lfbt); cmsys::auto_ptr cge = ge.Parse(srcFiles); cge->SetEvaluateForBuildsystem(true); - this->Internal->SourceEntries.push_back( + this->Internal->SourceItems.push_back( new cmTargetInternals::TargetPropertyEntry(cge)); } } @@ -818,11 +826,8 @@ void cmTarget::AddSources(std::vector const& srcs) this->Internal->SourceFilesMap.clear(); this->LinkImplementationLanguageIsContextDependent = true; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - cmsys::auto_ptr cge = ge.Parse(srcFiles); - cge->SetEvaluateForBuildsystem(true); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceEntries.push_back(srcFiles); + this->Internal->SourceBacktraces.push_back(lfbt); } } @@ -926,10 +931,10 @@ public: } - bool operator()(cmTargetInternals::TargetPropertyEntry* entry) + bool operator()(std::string const& entry) { std::vector files; - cmSystemTools::ExpandListArgument(entry->ge->GetInput(), files); + cmSystemTools::ExpandListArgument(entry, files); std::vector locations(files.size()); std::transform(files.begin(), files.end(), locations.begin(), CreateLocation(this->Needle.GetMakefile())); @@ -951,11 +956,8 @@ cmSourceFile* cmTarget::AddSource(const std::string& src) this->Internal->SourceFilesMap.clear(); this->LinkImplementationLanguageIsContextDependent = true; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - cmsys::auto_ptr cge = ge.Parse(src); - cge->SetEvaluateForBuildsystem(true); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceEntries.push_back(src); + this->Internal->SourceBacktraces.push_back(lfbt); } if (cmGeneratorExpression::Find(src) != std::string::npos) { @@ -966,6 +968,19 @@ cmSourceFile* cmTarget::AddSource(const std::string& src) void cmTarget::AddGenerateTimeSource(const std::string& src) { + cmSourceFileLocation sfl(this->Makefile, src); + if (std::find_if(this->Internal->SourceEntries.begin(), + this->Internal->SourceEntries.end(), + TargetPropertyEntryFinder(sfl)) + == this->Internal->SourceEntries.end()) + { + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr cge = ge.Parse(src); + cge->SetEvaluateForBuildsystem(true); + this->Internal->SourceItems.push_back( + new cmTargetInternals::TargetPropertyEntry(cge)); + } this->AddSource(src); } @@ -1679,13 +1694,15 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) return; } this->Internal->SourceFilesMap.clear(); - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - cmDeleteAll(this->Internal->SourceEntries); + this->Internal->SourceEntries.clear(); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceBacktraces.clear(); + if (value) + { + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + this->Internal->SourceEntries.push_back(value); + this->Internal->SourceBacktraces.push_back(lfbt); + } } else { @@ -1778,10 +1795,8 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } this->Internal->SourceFilesMap.clear(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->SourceEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->SourceEntries.push_back(value); + this->Internal->SourceBacktraces.push_back(lfbt); } else { @@ -2418,13 +2433,11 @@ const char *cmTarget::GetProperty(const std::string& prop, std::ostringstream ss; const char* sep = ""; - typedef cmTargetInternals::TargetPropertyEntry - TargetPropertyEntry; - for(std::vector::const_iterator + for(std::vector::const_iterator i = this->Internal->SourceEntries.begin(); i != this->Internal->SourceEntries.end(); ++i) { - std::string entry = (*i)->ge->GetInput(); + std::string const& entry = *i; std::vector files; cmSystemTools::ExpandListArgument(entry, files); @@ -3076,13 +3089,11 @@ cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const // there is no cmGeneratorTarget at configure-time, so search the SOURCES // for TARGET_OBJECTS instead for backwards compatibility with OLD // behavior of CMP0024 and CMP0026 only. - typedef cmTargetInternals::TargetPropertyEntry - TargetPropertyEntry; - for(std::vector::const_iterator + for(std::vector::const_iterator i = this->Internal->SourceEntries.begin(); i != this->Internal->SourceEntries.end(); ++i) { - std::string entry = (*i)->ge->GetInput(); + std::string const& entry = *i; std::vector files; cmSystemTools::ExpandListArgument(entry, files); @@ -3745,7 +3756,7 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->SourceEntries); + cmDeleteAll(this->Pointer->SourceItems); delete this->Pointer; } -- cgit v0.12 From da1b0449d96d4044bc4633a40ac87b6d4a19912d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 12 Sep 2015 21:51:10 +0200 Subject: cmTarget: Remove a conditional for generate-time source addition. It is not really necessary. --- Source/cmTarget.cxx | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 6e1c488..fc9e963 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -968,19 +968,12 @@ cmSourceFile* cmTarget::AddSource(const std::string& src) void cmTarget::AddGenerateTimeSource(const std::string& src) { - cmSourceFileLocation sfl(this->Makefile, src); - if (std::find_if(this->Internal->SourceEntries.begin(), - this->Internal->SourceEntries.end(), - TargetPropertyEntryFinder(sfl)) - == this->Internal->SourceEntries.end()) - { - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - cmsys::auto_ptr cge = ge.Parse(src); - cge->SetEvaluateForBuildsystem(true); - this->Internal->SourceItems.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); - } + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr cge = ge.Parse(src); + cge->SetEvaluateForBuildsystem(true); + this->Internal->SourceItems.push_back( + new cmTargetInternals::TargetPropertyEntry(cge)); this->AddSource(src); } -- cgit v0.12 From 33f87bb1f503c09a6b8018edf97b615f0e7f713d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 13 Sep 2015 09:45:41 +0200 Subject: cmGeneratorTarget: Move AddInterfaceEntries method. It will be needed here in a follow-up commit. --- Source/cmGeneratorTarget.cxx | 55 ++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 83f9cd2..357b972 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -812,6 +812,33 @@ bool cmGeneratorTarget::GetPropertyAsBool(const std::string& prop) const } //---------------------------------------------------------------------------- +static void AddInterfaceEntries( + cmGeneratorTarget const* thisTarget, std::string const& config, + std::string const& prop, + std::vector& entries) +{ + if(cmLinkImplementationLibraries const* impl = + thisTarget->Target->GetLinkImplementationLibraries(config)) + { + for (std::vector::const_iterator + it = impl->Libraries.begin(), end = impl->Libraries.end(); + it != end; ++it) + { + if(it->Target) + { + std::string genex = + "$"; + cmGeneratorExpression ge(it->Backtrace); + cmsys::auto_ptr cge = ge.Parse(genex); + cge->SetEvaluateForBuildsystem(true); + entries.push_back( + new cmGeneratorTarget::TargetPropertyEntry(cge, *it)); + } + } + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetSourceFiles(std::vector &files, const std::string& config) const { @@ -2177,34 +2204,6 @@ static void processIncludeDirectories(cmGeneratorTarget const* tgt, } } - -//---------------------------------------------------------------------------- -static void AddInterfaceEntries( - cmGeneratorTarget const* thisTarget, std::string const& config, - std::string const& prop, - std::vector& entries) -{ - if(cmLinkImplementationLibraries const* impl = - thisTarget->Target->GetLinkImplementationLibraries(config)) - { - for (std::vector::const_iterator - it = impl->Libraries.begin(), end = impl->Libraries.end(); - it != end; ++it) - { - if(it->Target) - { - std::string genex = - "$"; - cmGeneratorExpression ge(it->Backtrace); - cmsys::auto_ptr cge = ge.Parse(genex); - cge->SetEvaluateForBuildsystem(true); - entries.push_back( - new cmGeneratorTarget::TargetPropertyEntry(cge, *it)); - } - } - } -} - //---------------------------------------------------------------------------- std::vector cmGeneratorTarget::GetIncludeDirectories(const std::string& config, -- cgit v0.12 From 7b6dc0fe45c7064ad741461bfaf19028e8539c78 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 13 Sep 2015 09:57:43 +0200 Subject: cmGeneratorTarget: Inline GetSourceFiles from cmTarget. --- Source/cmGeneratorTarget.cxx | 35 ++++++++++++++++++++++++++++++- Source/cmTarget.cxx | 49 ++++++-------------------------------------- Source/cmTarget.h | 14 ++++++++----- 3 files changed, 49 insertions(+), 49 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 357b972..43ce882 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -842,7 +842,40 @@ static void AddInterfaceEntries( void cmGeneratorTarget::GetSourceFiles(std::vector &files, const std::string& config) const { - this->Target->GetSourceFiles(files, config); + // Lookup any existing link implementation for this configuration. + std::string key = cmSystemTools::UpperCase(config); + + cmTarget::SourceFilesMapType& sfm = this->Target->GetSourceFilesMap(); + if(!this->Target->GetLinkImplementationLanguageIsContextDependent()) + { + files = sfm.begin()->second; + return; + } + + cmTarget::SourceFilesMapType::iterator + it = sfm.find(key); + if(it != sfm.end()) + { + files = it->second; + } + else + { + std::vector srcs; + this->Target->GetSourceFiles(srcs, config); + + std::set emitted; + + for(std::vector::const_iterator i = srcs.begin(); + i != srcs.end(); ++i) + { + cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i); + if (emitted.insert(sf).second) + { + files.push_back(sf); + } + } + sfm[key] = files; + } } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index fc9e963..8ff729f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -101,9 +101,7 @@ public: HeadToLinkImplementationMap> LinkImplMapType; LinkImplMapType LinkImplMap; - typedef std::map > - SourceFilesMapType; - SourceFilesMapType SourceFilesMap; + cmTarget::SourceFilesMapType SourceFilesMap; std::set UtilityItems; bool UtilityItemsDone; @@ -409,6 +407,11 @@ void cmTarget::Compute() this->Internal->SourceItems, true); } +cmTarget::SourceFilesMapType& cmTarget::GetSourceFilesMap() const +{ + return this->Internal->SourceFilesMap; +} + //---------------------------------------------------------------------------- void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile) { @@ -736,46 +739,6 @@ void cmTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- -void cmTarget::GetSourceFiles(std::vector &files, - const std::string& config) const -{ - - // Lookup any existing link implementation for this configuration. - std::string key = cmSystemTools::UpperCase(config); - - if(!this->LinkImplementationLanguageIsContextDependent) - { - files = this->Internal->SourceFilesMap.begin()->second; - return; - } - - cmTargetInternals::SourceFilesMapType::iterator - it = this->Internal->SourceFilesMap.find(key); - if(it != this->Internal->SourceFilesMap.end()) - { - files = it->second; - } - else - { - std::vector srcs; - this->GetSourceFiles(srcs, config); - - std::set emitted; - - for(std::vector::const_iterator i = srcs.begin(); - i != srcs.end(); ++i) - { - cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i); - if (emitted.insert(sf).second) - { - files.push_back(sf); - } - } - this->Internal->SourceFilesMap[key] = files; - } -} - -//---------------------------------------------------------------------------- void cmTarget::AddTracedSources(std::vector const& srcs) { if (!srcs.empty()) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 2f1671d..6024c38 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -135,11 +135,15 @@ public: void Compute(); - /** - * Get the list of the source files used by this target - */ - void GetSourceFiles(std::vector &files, - const std::string& config) const; + typedef std::map > + SourceFilesMapType; + + SourceFilesMapType& GetSourceFilesMap() const; + + bool GetLinkImplementationLanguageIsContextDependent() const { + return this->LinkImplementationLanguageIsContextDependent; + } + /** * Add sources to the target. */ -- cgit v0.12 From dce6581b7b58c346796c8d3045f4ce70d9672755 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 13 Sep 2015 10:18:15 +0200 Subject: cmGeneratorTarget: Move computed sources from cmTarget. --- Source/cmGeneratorTarget.cxx | 235 ++++++++++++++++++++++++++++++++-- Source/cmGeneratorTarget.h | 10 ++ Source/cmTarget.cxx | 299 ++----------------------------------------- Source/cmTarget.h | 18 +-- 4 files changed, 249 insertions(+), 313 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 43ce882..3fb0dc7 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -269,7 +269,9 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) DebugIncludesDone(false), DebugCompileOptionsDone(false), DebugCompileFeaturesDone(false), - DebugCompileDefinitionsDone(false) + DebugCompileDefinitionsDone(false), + DebugSourcesDone(false), + LinkImplementationLanguageIsContextDependent(true) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; @@ -296,6 +298,11 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) t->GetCompileDefinitionsEntries(), t->GetCompileDefinitionsBacktraces(), this->CompileDefinitionsEntries); + + CreatePropertyGeneratorExpressions( + t->GetSourceEntries(), + t->GetSourceBacktraces(), + this->SourceEntries, true); } cmGeneratorTarget::~cmGeneratorTarget() @@ -304,6 +311,7 @@ cmGeneratorTarget::~cmGeneratorTarget() cmDeleteAll(this->CompileOptionsEntries); cmDeleteAll(this->CompileFeaturesEntries); cmDeleteAll(this->CompileDefinitionsEntries); + cmDeleteAll(this->SourceEntries); cmDeleteAll(this->LinkInformation); this->LinkInformation.clear(); } @@ -404,12 +412,32 @@ std::string cmGeneratorTarget::GetOutputName(const std::string& config, void cmGeneratorTarget::AddSource(const std::string& src) { - this->Target->AddGenerateTimeSource(src); + this->Target->AddSource(src); + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr cge = ge.Parse(src); + cge->SetEvaluateForBuildsystem(true); + this->SourceEntries.push_back( + new TargetPropertyEntry(cge)); + this->SourceFilesMap.clear(); + this->LinkImplementationLanguageIsContextDependent = true; } void cmGeneratorTarget::AddTracedSources(std::vector const& srcs) { this->Target->AddTracedSources(srcs); + if (!srcs.empty()) + { + std::string srcFiles = cmJoin(srcs, ";"); + this->SourceFilesMap.clear(); + this->LinkImplementationLanguageIsContextDependent = true; + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr cge = ge.Parse(srcFiles); + cge->SetEvaluateForBuildsystem(true); + this->SourceEntries.push_back( + new cmGeneratorTarget::TargetPropertyEntry(cge)); + } } //---------------------------------------------------------------------------- @@ -839,29 +867,216 @@ static void AddInterfaceEntries( } //---------------------------------------------------------------------------- +static bool processSources(cmGeneratorTarget const* tgt, + const std::vector &entries, + std::vector &srcs, + UNORDERED_SET &uniqueSrcs, + cmGeneratorExpressionDAGChecker *dagChecker, + std::string const& config, bool debugSources) +{ + cmMakefile *mf = tgt->Target->GetMakefile(); + + bool contextDependent = false; + + for (std::vector::const_iterator + it = entries.begin(), end = entries.end(); it != end; ++it) + { + cmLinkImplItem const& item = (*it)->LinkImplItem; + std::string const& targetName = item; + std::vector entrySources; + cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, + config, + false, + tgt->Target, + tgt->Target, + dagChecker), + entrySources); + + if ((*it)->ge->GetHadContextSensitiveCondition()) + { + contextDependent = true; + } + + for(std::vector::iterator i = entrySources.begin(); + i != entrySources.end(); ++i) + { + std::string& src = *i; + cmSourceFile* sf = mf->GetOrCreateSource(src); + std::string e; + std::string fullPath = sf->GetFullPath(&e); + if(fullPath.empty()) + { + if(!e.empty()) + { + cmake* cm = mf->GetCMakeInstance(); + cm->IssueMessage(cmake::FATAL_ERROR, e, + tgt->Target->GetBacktrace()); + } + return contextDependent; + } + + if (!targetName.empty() && !cmSystemTools::FileIsFullPath(src.c_str())) + { + std::ostringstream err; + if (!targetName.empty()) + { + err << "Target \"" << targetName << "\" contains relative " + "path in its INTERFACE_SOURCES:\n" + " \"" << src << "\""; + } + else + { + err << "Found relative path while evaluating sources of " + "\"" << tgt->GetName() << "\":\n \"" << src << "\"\n"; + } + tgt->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, err.str()); + return contextDependent; + } + src = fullPath; + } + std::string usedSources; + for(std::vector::iterator + li = entrySources.begin(); li != entrySources.end(); ++li) + { + std::string src = *li; + + if(uniqueSrcs.insert(src).second) + { + srcs.push_back(src); + if (debugSources) + { + usedSources += " * " + src + "\n"; + } + } + } + if (!usedSources.empty()) + { + mf->GetCMakeInstance()->IssueMessage(cmake::LOG, + std::string("Used sources for target ") + + tgt->GetName() + ":\n" + + usedSources, (*it)->ge->GetBacktrace()); + } + } + return contextDependent; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetSourceFiles(std::vector &files, + const std::string& config) const +{ + assert(this->GetType() != cmTarget::INTERFACE_LIBRARY); + + if (!this->Makefile->GetGlobalGenerator()->GetConfigureDoneCMP0026()) + { + // At configure-time, this method can be called as part of getting the + // LOCATION property or to export() a file to be include()d. However + // there is no cmGeneratorTarget at configure-time, so search the SOURCES + // for TARGET_OBJECTS instead for backwards compatibility with OLD + // behavior of CMP0024 and CMP0026 only. + + cmStringRange sourceEntries = this->Target->GetSourceEntries(); + for(cmStringRange::const_iterator + i = sourceEntries.begin(); + i != sourceEntries.end(); ++i) + { + std::string const& entry = *i; + + std::vector items; + cmSystemTools::ExpandListArgument(entry, items); + for (std::vector::const_iterator + li = items.begin(); li != items.end(); ++li) + { + if(cmHasLiteralPrefix(*li, "$size() - 1] == '>') + { + continue; + } + files.push_back(*li); + } + } + return; + } + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugSources = !this->DebugSourcesDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "SOURCES") + != debugProperties.end(); + + if (this->Makefile->GetGlobalGenerator()->GetConfigureDoneCMP0026()) + { + this->DebugSourcesDone = true; + } + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "SOURCES", 0, 0); + + UNORDERED_SET uniqueSrcs; + bool contextDependentDirectSources = processSources(this, + this->SourceEntries, + files, + uniqueSrcs, + &dagChecker, + config, + debugSources); + + std::vector + linkInterfaceSourcesEntries; + + AddInterfaceEntries( + this, config, "INTERFACE_SOURCES", + linkInterfaceSourcesEntries); + + std::vector::size_type numFilesBefore = files.size(); + bool contextDependentInterfaceSources = processSources(this, + linkInterfaceSourcesEntries, + files, + uniqueSrcs, + &dagChecker, + config, + debugSources); + + if (!contextDependentDirectSources + && !(contextDependentInterfaceSources && numFilesBefore < files.size())) + { + this->LinkImplementationLanguageIsContextDependent = false; + } + + cmDeleteAll(linkInterfaceSourcesEntries); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetSourceFiles(std::vector &files, const std::string& config) const { + // Lookup any existing link implementation for this configuration. std::string key = cmSystemTools::UpperCase(config); - cmTarget::SourceFilesMapType& sfm = this->Target->GetSourceFilesMap(); - if(!this->Target->GetLinkImplementationLanguageIsContextDependent()) + if(!this->LinkImplementationLanguageIsContextDependent) { - files = sfm.begin()->second; + files = this->SourceFilesMap.begin()->second; return; } - cmTarget::SourceFilesMapType::iterator - it = sfm.find(key); - if(it != sfm.end()) + SourceFilesMapType::iterator + it = this->SourceFilesMap.find(key); + if(it != this->SourceFilesMap.end()) { files = it->second; } else { std::vector srcs; - this->Target->GetSourceFiles(srcs, config); + this->GetSourceFiles(srcs, config); std::set emitted; @@ -874,7 +1089,7 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, files.push_back(sf); } } - sfm[key] = files; + this->SourceFilesMap[key] = files; } } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 0c6ad82..e8c5e04 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -441,10 +441,15 @@ private: GetImportLinkInterface(const std::string& config, cmTarget const* head, bool usage_requirements_only) const; + typedef std::map > + SourceFilesMapType; + mutable SourceFilesMapType SourceFilesMap; + std::vector IncludeDirectoriesEntries; std::vector CompileOptionsEntries; std::vector CompileFeaturesEntries; std::vector CompileDefinitionsEntries; + std::vector SourceEntries; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, @@ -454,6 +459,9 @@ private: void LookupLinkItems(std::vector const& names, std::vector& items) const; + void GetSourceFiles(std::vector& files, + const std::string& config) const; + typedef std::pair OutputNameKey; typedef std::map OutputNameMapType; mutable OutputNameMapType OutputNameMap; @@ -462,6 +470,8 @@ private: mutable bool DebugCompileOptionsDone; mutable bool DebugCompileFeaturesDone; mutable bool DebugCompileDefinitionsDone; + mutable bool DebugSourcesDone; + mutable bool LinkImplementationLanguageIsContextDependent; public: std::vector const& diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8ff729f..e87aa16 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -101,21 +101,9 @@ public: HeadToLinkImplementationMap> LinkImplMapType; LinkImplMapType LinkImplMap; - cmTarget::SourceFilesMapType SourceFilesMap; - std::set UtilityItems; bool UtilityItemsDone; - class TargetPropertyEntry { - static cmLinkImplItem NoLinkImplItem; - public: - TargetPropertyEntry(cmsys::auto_ptr cge, - cmLinkImplItem const& item = NoLinkImplItem) - : ge(cge), LinkImplItem(item) - {} - const cmsys::auto_ptr ge; - cmLinkImplItem const& LinkImplItem; - }; std::vector IncludeDirectoriesEntries; std::vector IncludeDirectoriesBacktraces; std::vector CompileOptionsEntries; @@ -126,16 +114,9 @@ public: std::vector CompileDefinitionsBacktraces; std::vector SourceEntries; std::vector SourceBacktraces; - std::vector SourceItems; std::vector LinkImplementationPropertyEntries; - - void AddInterfaceEntries( - cmTarget const* thisTarget, std::string const& config, - std::string const& prop, std::vector& entries); }; -cmLinkImplItem cmTargetInternals::TargetPropertyEntry::NoLinkImplItem; - //---------------------------------------------------------------------------- cmTargetInternals::~cmTargetInternals() { @@ -154,8 +135,6 @@ cmTarget::cmTarget() this->IsApple = false; this->IsImportedTarget = false; this->BuildInterfaceIncludesAppended = false; - this->DebugSourcesDone = false; - this->LinkImplementationLanguageIsContextDependent = true; } void cmTarget::SetType(TargetType type, const std::string& name) @@ -382,34 +361,8 @@ void cmTarget::SetMakefile(cmMakefile* mf) } } -void CreatePropertyGeneratorExpressions( - std::vector const& entries, - std::vector const& backtraces, - std::vector& items, - bool evaluateForBuildsystem = false) -{ - std::vector::const_iterator btIt = backtraces.begin(); - for (std::vector::const_iterator it = entries.begin(); - it != entries.end(); ++it, ++btIt) - { - cmGeneratorExpression ge(*btIt); - cmsys::auto_ptr cge = ge.Parse(*it); - cge->SetEvaluateForBuildsystem(evaluateForBuildsystem); - items.push_back(new cmTargetInternals::TargetPropertyEntry(cge)); - } -} - void cmTarget::Compute() { - CreatePropertyGeneratorExpressions( - this->Internal->SourceEntries, - this->Internal->SourceBacktraces, - this->Internal->SourceItems, true); -} - -cmTarget::SourceFilesMapType& cmTarget::GetSourceFilesMap() const -{ - return this->Internal->SourceFilesMap; } //---------------------------------------------------------------------------- @@ -469,9 +422,7 @@ void cmTarget::FinishConfigure() //---------------------------------------------------------------------------- void cmTarget::ClearLinkMaps() { - this->LinkImplementationLanguageIsContextDependent = true; this->Internal->LinkImplMap.clear(); - this->Internal->SourceFilesMap.clear(); } //---------------------------------------------------------------------------- @@ -553,207 +504,13 @@ bool cmTarget::IsXCTestOnApple() const } //---------------------------------------------------------------------------- -static bool processSources(cmTarget const* tgt, - const std::vector &entries, - std::vector &srcs, - UNORDERED_SET &uniqueSrcs, - cmGeneratorExpressionDAGChecker *dagChecker, - std::string const& config, bool debugSources) -{ - cmMakefile *mf = tgt->GetMakefile(); - - bool contextDependent = false; - - for (std::vector::const_iterator - it = entries.begin(), end = entries.end(); it != end; ++it) - { - cmLinkImplItem const& item = (*it)->LinkImplItem; - std::string const& targetName = item; - std::vector entrySources; - cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, - config, - false, - tgt, - tgt, - dagChecker), - entrySources); - - if ((*it)->ge->GetHadContextSensitiveCondition()) - { - contextDependent = true; - } - - for(std::vector::iterator i = entrySources.begin(); - i != entrySources.end(); ++i) - { - std::string& src = *i; - cmSourceFile* sf = mf->GetOrCreateSource(src); - std::string e; - std::string fullPath = sf->GetFullPath(&e); - if(fullPath.empty()) - { - if(!e.empty()) - { - cmake* cm = mf->GetCMakeInstance(); - cm->IssueMessage(cmake::FATAL_ERROR, e, - tgt->GetBacktrace()); - } - return contextDependent; - } - - if (!targetName.empty() && !cmSystemTools::FileIsFullPath(src.c_str())) - { - std::ostringstream err; - if (!targetName.empty()) - { - err << "Target \"" << targetName << "\" contains relative " - "path in its INTERFACE_SOURCES:\n" - " \"" << src << "\""; - } - else - { - err << "Found relative path while evaluating sources of " - "\"" << tgt->GetName() << "\":\n \"" << src << "\"\n"; - } - tgt->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, err.str()); - return contextDependent; - } - src = fullPath; - } - std::string usedSources; - for(std::vector::iterator - li = entrySources.begin(); li != entrySources.end(); ++li) - { - std::string src = *li; - - if(uniqueSrcs.insert(src).second) - { - srcs.push_back(src); - if (debugSources) - { - usedSources += " * " + src + "\n"; - } - } - } - if (!usedSources.empty()) - { - mf->GetCMakeInstance()->IssueMessage(cmake::LOG, - std::string("Used sources for target ") - + tgt->GetName() + ":\n" - + usedSources, (*it)->ge->GetBacktrace()); - } - } - return contextDependent; -} - -//---------------------------------------------------------------------------- -void cmTarget::GetSourceFiles(std::vector &files, - const std::string& config) const -{ - assert(this->GetType() != INTERFACE_LIBRARY); - - if (!this->GetMakefile()->GetGlobalGenerator()->GetConfigureDoneCMP0026()) - { - // At configure-time, this method can be called as part of getting the - // LOCATION property or to export() a file to be include()d. However - // there is no cmGeneratorTarget at configure-time, so search the SOURCES - // for TARGET_OBJECTS instead for backwards compatibility with OLD - // behavior of CMP0024 and CMP0026 only. - - for(std::vector::const_iterator - i = this->Internal->SourceEntries.begin(); - i != this->Internal->SourceEntries.end(); ++i) - { - std::string const& entry = *i; - - std::vector items; - cmSystemTools::ExpandListArgument(entry, items); - for (std::vector::const_iterator - li = items.begin(); li != items.end(); ++li) - { - if(cmHasLiteralPrefix(*li, "$size() - 1] == '>') - { - continue; - } - files.push_back(*li); - } - } - return; - } - - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugSources = !this->DebugSourcesDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "SOURCES") - != debugProperties.end(); - - if (this->GetMakefile()->GetGlobalGenerator()->GetConfigureDoneCMP0026()) - { - this->DebugSourcesDone = true; - } - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "SOURCES", 0, 0); - - UNORDERED_SET uniqueSrcs; - bool contextDependentDirectSources = processSources(this, - this->Internal->SourceItems, - files, - uniqueSrcs, - &dagChecker, - config, - debugSources); - - std::vector - linkInterfaceSourcesEntries; - - this->Internal->AddInterfaceEntries( - this, config, "INTERFACE_SOURCES", - linkInterfaceSourcesEntries); - - std::vector::size_type numFilesBefore = files.size(); - bool contextDependentInterfaceSources = processSources(this, - linkInterfaceSourcesEntries, - files, - uniqueSrcs, - &dagChecker, - config, - debugSources); - - if (!contextDependentDirectSources - && !(contextDependentInterfaceSources && numFilesBefore < files.size())) - { - this->LinkImplementationLanguageIsContextDependent = false; - } - - cmDeleteAll(linkInterfaceSourcesEntries); -} - -//---------------------------------------------------------------------------- void cmTarget::AddTracedSources(std::vector const& srcs) { if (!srcs.empty()) { - std::string srcFiles = cmJoin(srcs, ";"); - this->Internal->SourceFilesMap.clear(); - this->LinkImplementationLanguageIsContextDependent = true; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->SourceEntries.push_back(srcFiles); + this->Internal->SourceEntries.push_back(cmJoin(srcs, ";")); this->Internal->SourceBacktraces.push_back(lfbt); - cmGeneratorExpression ge(lfbt); - cmsys::auto_ptr cge = ge.Parse(srcFiles); - cge->SetEvaluateForBuildsystem(true); - this->Internal->SourceItems.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); } } @@ -786,8 +543,6 @@ void cmTarget::AddSources(std::vector const& srcs) } if (!srcFiles.empty()) { - this->Internal->SourceFilesMap.clear(); - this->LinkImplementationLanguageIsContextDependent = true; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); this->Internal->SourceEntries.push_back(srcFiles); this->Internal->SourceBacktraces.push_back(lfbt); @@ -916,8 +671,6 @@ cmSourceFile* cmTarget::AddSource(const std::string& src) TargetPropertyEntryFinder(sfl)) == this->Internal->SourceEntries.end()) { - this->Internal->SourceFilesMap.clear(); - this->LinkImplementationLanguageIsContextDependent = true; cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); this->Internal->SourceEntries.push_back(src); this->Internal->SourceBacktraces.push_back(lfbt); @@ -929,17 +682,6 @@ cmSourceFile* cmTarget::AddSource(const std::string& src) return this->Makefile->GetOrCreateSource(src); } -void cmTarget::AddGenerateTimeSource(const std::string& src) -{ - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - cmsys::auto_ptr cge = ge.Parse(src); - cge->SetEvaluateForBuildsystem(true); - this->Internal->SourceItems.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); - this->AddSource(src); -} - //---------------------------------------------------------------------------- void cmTarget::MergeLinkLibraries( cmMakefile& mf, const std::string& selfname, @@ -1234,6 +976,16 @@ cmBacktraceRange cmTarget::GetCompileDefinitionsBacktraces() const return cmMakeRange(this->Internal->CompileDefinitionsBacktraces); } +cmStringRange cmTarget::GetSourceEntries() const +{ + return cmMakeRange(this->Internal->SourceEntries); +} + +cmBacktraceRange cmTarget::GetSourceBacktraces() const +{ + return cmMakeRange(this->Internal->SourceBacktraces); +} + #if defined(_WIN32) && !defined(__CYGWIN__) //---------------------------------------------------------------------------- void @@ -1649,7 +1401,6 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } - this->Internal->SourceFilesMap.clear(); this->Internal->SourceEntries.clear(); this->Internal->SourceBacktraces.clear(); @@ -1749,7 +1500,6 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } - this->Internal->SourceFilesMap.clear(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); this->Internal->SourceEntries.push_back(value); this->Internal->SourceBacktraces.push_back(lfbt); @@ -3424,32 +3174,6 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, } } -//---------------------------------------------------------------------------- -void cmTargetInternals::AddInterfaceEntries( - cmTarget const* thisTarget, std::string const& config, - std::string const& prop, std::vector& entries) -{ - if(cmLinkImplementationLibraries const* impl = - thisTarget->GetLinkImplementationLibraries(config)) - { - for (std::vector::const_iterator - it = impl->Libraries.begin(), end = impl->Libraries.end(); - it != end; ++it) - { - if(it->Target) - { - std::string genex = - "$"; - cmGeneratorExpression ge(it->Backtrace); - cmsys::auto_ptr cge = ge.Parse(genex); - cge->SetEvaluateForBuildsystem(true); - entries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge, *it)); - } - } - } -} - cmOptionalLinkImplementation& cmTarget::GetLinkImplMap(std::string const& config) const { @@ -3712,7 +3436,6 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->SourceItems); delete this->Pointer; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 6024c38..71f0d1f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -135,15 +135,6 @@ public: void Compute(); - typedef std::map > - SourceFilesMapType; - - SourceFilesMapType& GetSourceFilesMap() const; - - bool GetLinkImplementationLanguageIsContextDependent() const { - return this->LinkImplementationLanguageIsContextDependent; - } - /** * Add sources to the target. */ @@ -151,7 +142,6 @@ public: void AddTracedSources(std::vector const& srcs); cmSourceFile* AddSourceCMP0049(const std::string& src); cmSourceFile* AddSource(const std::string& src); - void AddGenerateTimeSource(const std::string& src); enum LinkLibraryType {GENERAL, DEBUG, OPTIMIZED}; @@ -395,6 +385,9 @@ public: cmStringRange GetCompileDefinitionsEntries() const; cmBacktraceRange GetCompileDefinitionsBacktraces() const; + cmStringRange GetSourceEntries() const; + cmBacktraceRange GetSourceBacktraces() const; + #if defined(_WIN32) && !defined(__CYGWIN__) const LinkLibraryVectorType &GetLinkLibrariesForVS6() const { return this->LinkLibrariesForVS6;} @@ -473,9 +466,6 @@ private: std::string ImportedGetFullPath(const std::string& config, bool implib) const; - - void GetSourceFiles(std::vector &files, - const std::string& config) const; private: mutable cmPropertyMap Properties; std::set SystemIncludeDirectories; @@ -509,8 +499,6 @@ private: bool IsApple; bool IsImportedTarget; bool BuildInterfaceIncludesAppended; - mutable bool DebugSourcesDone; - mutable bool LinkImplementationLanguageIsContextDependent; #if defined(_WIN32) && !defined(__CYGWIN__) bool LinkLibrariesForVS6Analyzed; #endif -- cgit v0.12 From af71c7b47947860d06c659647c6ff33ab3676284 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 12 Sep 2015 21:54:02 +0200 Subject: cmTarget: Remove Compute method. --- Source/cmGlobalGenerator.cxx | 1 - Source/cmGlobalVisualStudio8Generator.cxx | 1 - Source/cmGlobalVisualStudioGenerator.cxx | 1 - Source/cmGlobalXCodeGenerator.cxx | 2 -- Source/cmQtAutoGeneratorInitializer.cxx | 2 -- Source/cmTarget.cxx | 4 ---- Source/cmTarget.h | 2 -- 7 files changed, 13 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index a62d534..db842b0 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1538,7 +1538,6 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes, ti != targets.end(); ++ti) { cmTarget* t = &ti->second; - t->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg); this->GeneratorTargets[t] = gt; generatorTargets[t] = gt; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 5bace47..ab9d7e7 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -254,7 +254,6 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false, no_working_directory, no_depends, noCommandLines); - tgt->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg); mf->AddGeneratorTarget(tgt, gt); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index fd2d33a..d45aa27 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -86,7 +86,6 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets() no_depends, no_commands, false, "Build all projects"); - allBuild->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]); allBuild->GetMakefile()->AddGeneratorTarget(allBuild, gt); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 14bc340..3d52e3a 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -456,7 +456,6 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, no_working_directory, "echo", "Build all projects"); - allbuild->Compute(); cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root); mf->AddGeneratorTarget(allbuild, allBuildGt); @@ -492,7 +491,6 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, no_working_directory, "make", "-f", file.c_str()); - check->Compute(); cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root); mf->AddGeneratorTarget(check, checkGt); } diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index 1b1b98e..378f132 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -885,8 +885,6 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( /*byproducts=*/rcc_output, depends, commandLines, false, autogenComment.c_str()); - autogenTarget->Compute(); - cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); makefile->AddGeneratorTarget(autogenTarget, gt); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e87aa16..abfc40b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -361,10 +361,6 @@ void cmTarget::SetMakefile(cmMakefile* mf) } } -void cmTarget::Compute() -{ -} - //---------------------------------------------------------------------------- void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile) { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 71f0d1f..354eda2 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -133,8 +133,6 @@ public: void AddPostBuildCommand(cmCustomCommand const &cmd) {this->PostBuildCommands.push_back(cmd);} - void Compute(); - /** * Add sources to the target. */ -- cgit v0.12