diff options
author | Stephen Kelly <steveire@gmail.com> | 2012-10-06 15:16:11 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2013-10-10 14:36:26 (GMT) |
commit | 5fe5c32480a5acf26bd20e52a091cd63747ed77d (patch) | |
tree | 748ebca1ae42657e8ccea1910a8457200fb9969b /Source | |
parent | e383555838c2539eca11c43abfccba9fa41ca97d (diff) | |
download | CMake-5fe5c32480a5acf26bd20e52a091cd63747ed77d.zip CMake-5fe5c32480a5acf26bd20e52a091cd63747ed77d.tar.gz CMake-5fe5c32480a5acf26bd20e52a091cd63747ed77d.tar.bz2 |
export(): Set a Makefile on the cmExportBuildFileGenerator.
This is better than the cmCommand, because the lifetime of that is
not as useful, and it is only used to report an error anyway.
In the next commit, the cmExportBuildFileGenerator will outlive the
cmCommand.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmExportBuildFileGenerator.cxx | 21 | ||||
-rw-r--r-- | Source/cmExportBuildFileGenerator.h | 13 | ||||
-rw-r--r-- | Source/cmExportCommand.cxx | 2 |
3 files changed, 19 insertions, 17 deletions
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 243e5ce..e2ad74f 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -11,12 +11,11 @@ ============================================================================*/ #include "cmExportBuildFileGenerator.h" -#include "cmExportCommand.h" //---------------------------------------------------------------------------- cmExportBuildFileGenerator::cmExportBuildFileGenerator() { - this->ExportCommand = 0; + this->Makefile = 0; } //---------------------------------------------------------------------------- @@ -39,12 +38,10 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) } else { - if(this->ExportCommand && this->ExportCommand->ErrorMessage.empty()) - { - cmOStringStream e; - e << "given target \"" << te->GetName() << "\" more than once."; - this->ExportCommand->ErrorMessage = e.str(); - } + cmOStringStream e; + e << "given target \"" << te->GetName() << "\" more than once."; + this->Makefile->GetCMakeInstance() + ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(), this->Backtrace); return false; } if (te->GetType() == cmTarget::INTERFACE_LIBRARY) @@ -220,18 +217,20 @@ cmExportBuildFileGenerator ::ComplainAboutMissingTarget(cmTarget* depender, cmTarget* dependee) { - if(!this->ExportCommand || !this->ExportCommand->ErrorMessage.empty()) + if(cmSystemTools::GetErrorOccuredFlag()) { return; } cmOStringStream e; - e << "called with target \"" << depender->GetName() + e << "export called with target \"" << depender->GetName() << "\" which requires target \"" << dependee->GetName() << "\" that is not in the export list.\n" << "If the required target is not easy to reference in this call, " << "consider using the APPEND option with multiple separate calls."; - this->ExportCommand->ErrorMessage = e.str(); + + this->Makefile->GetCMakeInstance() + ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(), this->Backtrace); } std::string diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h index 3ffdf8b..4436896 100644 --- a/Source/cmExportBuildFileGenerator.h +++ b/Source/cmExportBuildFileGenerator.h @@ -13,8 +13,7 @@ #define cmExportBuildFileGenerator_h #include "cmExportFileGenerator.h" - -class cmExportCommand; +#include "cmListFileCache.h" /** \class cmExportBuildFileGenerator * \brief Generate a file exporting targets from a build tree. @@ -37,8 +36,11 @@ public: /** Set whether to append generated code to the output file. */ void SetAppendMode(bool append) { this->AppendMode = append; } - /** Set the command instance through which errors should be reported. */ - void SetCommand(cmExportCommand* cmd) { this->ExportCommand = cmd; } + void SetMakefile(cmMakefile *mf) { + this->Makefile = mf; + this->Makefile->GetBacktrace(this->Backtrace); + } + protected: // Implement virtual methods from the superclass. virtual bool GenerateMainFile(std::ostream& os); @@ -64,7 +66,8 @@ protected: std::string InstallNameDir(cmTarget* target, const std::string& config); std::vector<cmTarget*> const* Exports; - cmExportCommand* ExportCommand; + cmMakefile* Makefile; + cmListFileBacktrace Backtrace; }; #endif diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index f335b8b..9d0d478 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -169,7 +169,7 @@ bool cmExportCommand ebfg.SetNamespace(this->Namespace.GetCString()); ebfg.SetAppendMode(this->Append.IsEnabled()); ebfg.SetExports(&targets); - ebfg.SetCommand(this); + ebfg.SetMakefile(this->Makefile); ebfg.SetExportOld(this->ExportOld.IsEnabled()); cmGlobalGenerator *gg = this->Makefile->GetLocalGenerator() |