diff options
author | Brad King <brad.king@kitware.com> | 2020-09-03 19:28:36 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-09-04 13:44:30 (GMT) |
commit | aea465793e9744fcda0c26dad14c0620b7448f14 (patch) | |
tree | 49755bcc289a1d1864acaee9a474e3171d4eb8db /Source | |
parent | 152724274534def1126f97a28f0ce9f0e126a2b2 (diff) | |
download | CMake-aea465793e9744fcda0c26dad14c0620b7448f14.zip CMake-aea465793e9744fcda0c26dad14c0620b7448f14.tar.gz CMake-aea465793e9744fcda0c26dad14c0620b7448f14.tar.bz2 |
cmLocalVisualStudio7Generator: Consolidate target iteration
Combine iteration with `cmLocalVisualStudio10Generator` and dispatch
generation of each target with a virtual `GenerateTarget` method.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmLocalVisualStudio10Generator.cxx | 14 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio10Generator.h | 6 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 44 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.h | 3 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 4 |
5 files changed, 14 insertions, 57 deletions
diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index 9706f2e..98e9db9 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -68,9 +68,6 @@ cmLocalVisualStudio10Generator::~cmLocalVisualStudio10Generator() void cmLocalVisualStudio10Generator::GenerateTarget(cmGeneratorTarget* target) { - if (!target->IsInBuildSystem()) { - return; - } auto& targetVisited = this->GetSourcesVisited(target); auto& deps = this->GlobalGenerator->GetTargetDirectDepends(target); for (auto& d : deps) { @@ -80,7 +77,7 @@ void cmLocalVisualStudio10Generator::GenerateTarget(cmGeneratorTarget* target) } if (static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator) ->TargetIsFortranOnly(target)) { - this->CreateSingleVCProj(target->GetName(), target); + this->cmLocalVisualStudio7Generator::GenerateTarget(target); } else { cmVisualStudio10TargetGenerator tg( target, @@ -90,15 +87,6 @@ void cmLocalVisualStudio10Generator::GenerateTarget(cmGeneratorTarget* target) } } -void cmLocalVisualStudio10Generator::Generate() -{ - for (cmGeneratorTarget* gt : - this->GlobalGenerator->GetLocalGeneratorTargetsInOrder(this)) { - this->GenerateTarget(gt); - } - this->WriteStampFiles(); -} - void cmLocalVisualStudio10Generator::ReadAndStoreExternalGUID( const std::string& name, const char* path) { diff --git a/Source/cmLocalVisualStudio10Generator.h b/Source/cmLocalVisualStudio10Generator.h index a12247c..631132e 100644 --- a/Source/cmLocalVisualStudio10Generator.h +++ b/Source/cmLocalVisualStudio10Generator.h @@ -25,10 +25,6 @@ public: virtual ~cmLocalVisualStudio10Generator(); - /** - * Generate the makefile for this directory. - */ - void Generate() override; void ReadAndStoreExternalGUID(const std::string& name, const char* path) override; @@ -43,7 +39,7 @@ protected: bool CustomCommandUseLocal() const override { return true; } private: - void GenerateTarget(cmGeneratorTarget* target); + void GenerateTarget(cmGeneratorTarget* target) override; std::map<cmGeneratorTarget const*, std::set<cmSourceFile const*>> SourcesVisited; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 1eaf450..1ebd5da 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -80,7 +80,15 @@ void cmLocalVisualStudio7Generator::AddHelperCommands() void cmLocalVisualStudio7Generator::Generate() { - this->WriteProjectFiles(); + // Create the project file for each target. + for (cmGeneratorTarget* gt : + this->GlobalGenerator->GetLocalGeneratorTargetsInOrder(this)) { + if (!gt->IsInBuildSystem() || gt->GetProperty("EXTERNAL_MSPROJECT")) { + continue; + } + this->GenerateTarget(gt); + } + this->WriteStampFiles(); } @@ -111,36 +119,6 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() } } -// TODO -// for CommandLine= need to repleace quotes with " -// write out configurations -void cmLocalVisualStudio7Generator::WriteProjectFiles() -{ - // If not an in source build, then create the output directory - if (this->GetCurrentBinaryDirectory() != this->GetSourceDirectory()) { - if (!cmSystemTools::MakeDirectory(this->GetCurrentBinaryDirectory())) { - cmSystemTools::Error("Error creating directory " + - this->GetCurrentBinaryDirectory()); - } - } - - // Get the set of targets in this directory. - const auto& tgts = - this->GlobalGenerator->GetLocalGeneratorTargetsInOrder(this); - - // Create the project file for each target. - for (const auto& l : tgts) { - if (!l->IsInBuildSystem()) { - continue; - } - // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace - // so don't build a projectfile for it - if (!l->GetProperty("EXTERNAL_MSPROJECT")) { - this->CreateSingleVCProj(l->GetName(), l); - } - } -} - void cmLocalVisualStudio7Generator::WriteStampFiles() { // Touch a timestamp file used to determine when the project file is @@ -179,9 +157,9 @@ void cmLocalVisualStudio7Generator::WriteStampFiles() } } -void cmLocalVisualStudio7Generator::CreateSingleVCProj( - const std::string& lname, cmGeneratorTarget* target) +void cmLocalVisualStudio7Generator::GenerateTarget(cmGeneratorTarget* target) { + std::string const& lname = target->GetName(); cmGlobalVisualStudioGenerator* gg = static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator); this->FortranProject = gg->TargetIsFortranOnly(target); diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index d76fc82..9ccd1a1 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -84,7 +84,7 @@ public: const char* path); protected: - void CreateSingleVCProj(const std::string& lname, cmGeneratorTarget* tgt); + virtual void GenerateTarget(cmGeneratorTarget* target); private: using Options = cmVS7GeneratorOptions; @@ -92,7 +92,6 @@ private: std::string GetBuildTypeLinkerFlags(std::string rootLinkerFlags, const std::string& configName); void FixGlobalTargets(); - void WriteProjectFiles(); void WriteVCProjHeader(std::ostream& fout, const std::string& libName, cmGeneratorTarget* tgt, std::vector<cmSourceGroup>& sgs); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index dc61def..b5368cf 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -314,10 +314,6 @@ std::ostream& cmVisualStudio10TargetGenerator::Elem::WriteString( void cmVisualStudio10TargetGenerator::Generate() { - // do not generate external ms projects - if (this->GeneratorTarget->GetProperty("EXTERNAL_MSPROJECT")) { - return; - } const std::string ProjectFileExtension = computeProjectFileExtension(this->GeneratorTarget); if (ProjectFileExtension == ".vcxproj") { |