summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorDaniel Pfeifer <daniel@pfeifer-mail.de>2016-12-28 22:43:11 (GMT)
committerRegina Pfeifer <regina@mailbox.org>2019-07-18 09:53:46 (GMT)
commit20169f0b8de5d0e5efea2d67a735332786173c23 (patch)
treeecb5c367721d6c6104a3e3b5c54a86f2fd49ebc0 /Source
parenta74dad3bd3e5e4bbf09764a0b6bdedfe842442a7 (diff)
downloadCMake-20169f0b8de5d0e5efea2d67a735332786173c23.zip
CMake-20169f0b8de5d0e5efea2d67a735332786173c23.tar.gz
CMake-20169f0b8de5d0e5efea2d67a735332786173c23.tar.bz2
cmExportLibraryDependenciesCommand: Port away from FinalPass
Diffstat (limited to 'Source')
-rw-r--r--Source/cmExportLibraryDependenciesCommand.cxx57
-rw-r--r--Source/cmExportLibraryDependenciesCommand.h8
2 files changed, 24 insertions, 41 deletions
diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx
index 87ef2a9..8f2fff5 100644
--- a/Source/cmExportLibraryDependenciesCommand.cxx
+++ b/Source/cmExportLibraryDependenciesCommand.cxx
@@ -19,57 +19,31 @@
class cmExecutionStatus;
-bool cmExportLibraryDependenciesCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
-{
- if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
- return false;
- }
-
- // store the arguments for the final pass
- this->Filename = args[0];
- this->Append = false;
- if (args.size() > 1) {
- if (args[1] == "APPEND") {
- this->Append = true;
- }
- }
- return true;
-}
-
-void cmExportLibraryDependenciesCommand::FinalPass()
-{
- // export_library_dependencies() shouldn't modify anything
- // ensure this by calling a const method
- this->ConstFinalPass();
-}
-
-void cmExportLibraryDependenciesCommand::ConstFinalPass() const
+static void FinalAction(cmMakefile& makefile, std::string const& filename,
+ bool append)
{
// Use copy-if-different if not appending.
std::unique_ptr<cmsys::ofstream> foutPtr;
- if (this->Append) {
+ if (append) {
const auto openmodeApp = std::ios::app;
- foutPtr =
- cm::make_unique<cmsys::ofstream>(this->Filename.c_str(), openmodeApp);
+ foutPtr = cm::make_unique<cmsys::ofstream>(filename.c_str(), openmodeApp);
} else {
std::unique_ptr<cmGeneratedFileStream> ap(
- new cmGeneratedFileStream(this->Filename, true));
+ new cmGeneratedFileStream(filename, true));
ap->SetCopyIfDifferent(true);
foutPtr = std::move(ap);
}
std::ostream& fout = *foutPtr;
if (!fout) {
- cmSystemTools::Error("Error Writing " + this->Filename);
+ cmSystemTools::Error("Error Writing " + filename);
cmSystemTools::ReportLastSystemError("");
return;
}
// Collect dependency information about all library targets built in
// the project.
- cmake* cm = this->Makefile->GetCMakeInstance();
+ cmake* cm = makefile.GetCMakeInstance();
cmGlobalGenerator* global = cm->GetGlobalGenerator();
const std::vector<cmMakefile*>& locals = global->GetMakefiles();
std::map<std::string, std::string> libDepsOld;
@@ -166,3 +140,20 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
}
fout << "endif()\n";
}
+
+bool cmExportLibraryDependenciesCommand::InitialPass(
+ std::vector<std::string> const& args, cmExecutionStatus&)
+{
+ if (args.empty()) {
+ this->SetError("called with incorrect number of arguments");
+ return false;
+ }
+
+ std::string const& filename = args[0];
+ bool const append = args.size() > 1 && args[1] == "APPEND";
+ this->Makefile->AddFinalAction([filename, append](cmMakefile& makefile) {
+ FinalAction(makefile, filename, append);
+ });
+
+ return true;
+}
diff --git a/Source/cmExportLibraryDependenciesCommand.h b/Source/cmExportLibraryDependenciesCommand.h
index 5255d63..4817162 100644
--- a/Source/cmExportLibraryDependenciesCommand.h
+++ b/Source/cmExportLibraryDependenciesCommand.h
@@ -23,14 +23,6 @@ public:
}
bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status) override;
-
- void FinalPass() override;
- bool HasFinalPass() const override { return true; }
-
-private:
- std::string Filename;
- bool Append = false;
- void ConstFinalPass() const;
};
#endif