summaryrefslogtreecommitdiffstats
path: root/Source/cmExportLibraryDependenciesCommand.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmExportLibraryDependenciesCommand.cxx')
-rw-r--r--Source/cmExportLibraryDependenciesCommand.cxx57
1 files changed, 24 insertions, 33 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;
+}