summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-01-29 15:20:47 (GMT)
committerBrad King <brad.king@kitware.com>2018-01-29 15:51:22 (GMT)
commit79f22e84089e3f7a29cfea3275af6fafc5d3c091 (patch)
tree5f83790921f2ea838e6ffdf169392a0b56faccb2
parent92cd3d06772ada13935790d66927ab4663c7d628 (diff)
downloadCMake-79f22e84089e3f7a29cfea3275af6fafc5d3c091.zip
CMake-79f22e84089e3f7a29cfea3275af6fafc5d3c091.tar.gz
CMake-79f22e84089e3f7a29cfea3275af6fafc5d3c091.tar.bz2
Makefile,Ninja: De-duplicate ComputeObjectFilenames method
Move the method implementation up to `cmLocalCommonGenerator` to avoid duplicating it in each generator.
-rw-r--r--Source/cmLocalCommonGenerator.cxx15
-rw-r--r--Source/cmLocalCommonGenerator.h6
-rw-r--r--Source/cmLocalNinjaGenerator.cxx14
-rw-r--r--Source/cmLocalNinjaGenerator.h5
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx14
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.h5
6 files changed, 21 insertions, 38 deletions
diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx
index 50ebfa1..5a43f2e 100644
--- a/Source/cmLocalCommonGenerator.cxx
+++ b/Source/cmLocalCommonGenerator.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmLocalCommonGenerator.h"
+#include <utility>
#include <vector>
#include "cmGeneratorTarget.h"
@@ -76,3 +77,17 @@ std::string cmLocalCommonGenerator::GetTargetFortranFlags(
return flags;
}
+
+void cmLocalCommonGenerator::ComputeObjectFilenames(
+ std::map<cmSourceFile const*, std::string>& mapping,
+ cmGeneratorTarget const* gt)
+{
+ // Determine if these object files should use a custom extension
+ char const* custom_ext = gt->GetCustomObjectExtension();
+ for (auto& si : mapping) {
+ cmSourceFile const* sf = si.first;
+ bool keptSourceExtension;
+ si.second = this->GetObjectFileNameWithoutTarget(
+ *sf, gt->ObjectDirectory, &keptSourceExtension, custom_ext);
+ }
+}
diff --git a/Source/cmLocalCommonGenerator.h b/Source/cmLocalCommonGenerator.h
index a60573c..7b8e6fe 100644
--- a/Source/cmLocalCommonGenerator.h
+++ b/Source/cmLocalCommonGenerator.h
@@ -5,6 +5,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <map>
#include <string>
#include "cmLocalGenerator.h"
@@ -12,6 +13,7 @@
class cmGeneratorTarget;
class cmGlobalGenerator;
class cmMakefile;
+class cmSourceFile;
/** \class cmLocalCommonGenerator
* \brief Common infrastructure for Makefile and Ninja local generators.
@@ -30,6 +32,10 @@ public:
std::string GetTargetFortranFlags(cmGeneratorTarget const* target,
std::string const& config) override;
+ void ComputeObjectFilenames(
+ std::map<cmSourceFile const*, std::string>& mapping,
+ cmGeneratorTarget const* gt = nullptr) override;
+
protected:
std::string WorkingDirectory;
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index 2d969d2..8c889fc 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -246,20 +246,6 @@ void cmLocalNinjaGenerator::WriteNinjaFilesInclusion(std::ostream& os)
os << "\n";
}
-void cmLocalNinjaGenerator::ComputeObjectFilenames(
- std::map<cmSourceFile const*, std::string>& mapping,
- cmGeneratorTarget const* gt)
-{
- // Determine if these object files should use a custom extension
- char const* custom_ext = gt->GetCustomObjectExtension();
- for (auto& si : mapping) {
- cmSourceFile const* sf = si.first;
- bool keptSourceExtension;
- si.second = this->GetObjectFileNameWithoutTarget(
- *sf, gt->ObjectDirectory, &keptSourceExtension, custom_ext);
- }
-}
-
void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os)
{
cmGlobalNinjaGenerator::WriteDivider(os);
diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h
index bb16899..95d8a61 100644
--- a/Source/cmLocalNinjaGenerator.h
+++ b/Source/cmLocalNinjaGenerator.h
@@ -23,7 +23,6 @@ class cmGlobalGenerator;
class cmGlobalNinjaGenerator;
class cmMakefile;
class cmRulePlaceholderExpander;
-class cmSourceFile;
class cmake;
/**
@@ -74,10 +73,6 @@ public:
void AppendCustomCommandDeps(cmCustomCommandGenerator const& ccg,
cmNinjaDeps& ninjaDeps);
- void ComputeObjectFilenames(
- std::map<cmSourceFile const*, std::string>& mapping,
- cmGeneratorTarget const* gt = nullptr) override;
-
protected:
std::string ConvertToIncludeReference(
std::string const& path,
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index ff3fcfd..12682a7 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -150,20 +150,6 @@ void cmLocalUnixMakefileGenerator3::ComputeHomeRelativeOutputPath()
}
}
-void cmLocalUnixMakefileGenerator3::ComputeObjectFilenames(
- std::map<cmSourceFile const*, std::string>& mapping,
- cmGeneratorTarget const* gt)
-{
- // Determine if these object files should use a custom extension
- char const* custom_ext = gt->GetCustomObjectExtension();
- for (auto& si : mapping) {
- cmSourceFile const* sf = si.first;
- bool keptSourceExtension;
- si.second = this->GetObjectFileNameWithoutTarget(
- *sf, gt->ObjectDirectory, &keptSourceExtension, custom_ext);
- }
-}
-
void cmLocalUnixMakefileGenerator3::GetLocalObjectFiles(
std::map<std::string, LocalObjectInfo>& localObjectFiles)
{
diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h
index 86c5aab..2d580d5 100644
--- a/Source/cmLocalUnixMakefileGenerator3.h
+++ b/Source/cmLocalUnixMakefileGenerator3.h
@@ -19,7 +19,6 @@ class cmCustomCommandGenerator;
class cmGeneratorTarget;
class cmGlobalGenerator;
class cmMakefile;
-class cmSourceFile;
/** \class cmLocalUnixMakefileGenerator3
* \brief Write a LocalUnix makefiles.
@@ -252,10 +251,6 @@ protected:
private:
std::string MaybeConvertWatcomShellCommand(std::string const& cmd);
- void ComputeObjectFilenames(
- std::map<cmSourceFile const*, std::string>& mapping,
- cmGeneratorTarget const* gt = nullptr) override;
-
friend class cmMakefileTargetGenerator;
friend class cmMakefileExecutableTargetGenerator;
friend class cmMakefileLibraryTargetGenerator;