[Cmake-commits] CMake branch, next, updated. v2.8.12-3783-gd322fe7

Stephen Kelly steveire at gmail.com
Thu Oct 10 18:19:22 EDT 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  d322fe7d28d925ee16c29858d6d37667a69f8795 (commit)
       via  52f2093a0b68fed92a9335bca735ee1bfd10c8d7 (commit)
       via  38536de09069dfdd5f578bb6536761a4a1d163e7 (commit)
       via  5fe5c32480a5acf26bd20e52a091cd63747ed77d (commit)
       via  e383555838c2539eca11c43abfccba9fa41ca97d (commit)
      from  c24205117647f00c9b7c0f6edc43a88c075b28ae (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d322fe7d28d925ee16c29858d6d37667a69f8795
commit d322fe7d28d925ee16c29858d6d37667a69f8795
Merge: c242051 52f2093
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Thu Oct 10 18:19:20 2013 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Oct 10 18:19:20 2013 -0400

    Merge topic 'export-at-generate-time' into next
    
    52f2093 export(): Handle multiple dependent export sets.
    38536de export(): Process the export() command at generate time.
    5fe5c32 export(): Set a Makefile on the cmExportBuildFileGenerator.
    e383555 cmExportInstallFileGenerator: Fix comment to match reality.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=52f2093a0b68fed92a9335bca735ee1bfd10c8d7
commit 52f2093a0b68fed92a9335bca735ee1bfd10c8d7
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Thu Oct 10 11:18:10 2013 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Fri Oct 11 00:18:50 2013 +0200

    export(): Handle multiple dependent export sets.
    
    The export-sets topic, merged in commit 49c7b649 (Merge topic
    'export-sets', 2012-10-01) changed install(EXPORT) to allow
    exporting targets whose dependents are exported separately
    to different locations. Doing the same for export() was not
    possible because the export() command was executed at
    configure-time.
    
    Now that export() is also executed at generate-time, make it
    possible to export to multiple dependent export sets.

diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index e593e0c..50835e2 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -11,6 +11,8 @@
 ============================================================================*/
 #include "cmExportBuildFileGenerator.h"
 
+#include "cmLocalGenerator.h"
+#include "cmGlobalGenerator.h"
 
 //----------------------------------------------------------------------------
 cmExportBuildFileGenerator::cmExportBuildFileGenerator()
@@ -194,27 +196,72 @@ cmExportBuildFileGenerator
 //----------------------------------------------------------------------------
 void
 cmExportBuildFileGenerator::HandleMissingTarget(
-  std::string& link_libs, std::vector<std::string>&,
-  cmMakefile*, cmTarget* depender, cmTarget* dependee)
+  std::string& link_libs, std::vector<std::string>& missingTargets,
+  cmMakefile* mf, cmTarget* depender, cmTarget* dependee)
 {
   // The target is not in the export.
   if(!this->AppendMode)
     {
-    // We are not appending, so all exported targets should be
-    // known here.  This is probably user-error.
-    this->ComplainAboutMissingTarget(depender, dependee);
+    const std::string name = dependee->GetName();
+    std::vector<std::string> namespaces = this->FindNamespaces(mf, name);
+
+    int targetOccurrences = (int)namespaces.size();
+    if (targetOccurrences == 1)
+      {
+      std::string missingTarget = namespaces[0];
+
+      missingTarget += dependee->GetExportName();
+      link_libs += missingTarget;
+      missingTargets.push_back(missingTarget);
+      return;
+      }
+    else
+      {
+      // We are not appending, so all exported targets should be
+      // known here.  This is probably user-error.
+      this->ComplainAboutMissingTarget(depender, dependee, targetOccurrences);
+      }
     }
   // Assume the target will be exported by another command.
   // Append it with the export namespace.
   link_libs += this->Namespace;
   link_libs += dependee->GetExportName();
+//   if generate time {}
+}
+
+
+//----------------------------------------------------------------------------
+std::vector<std::string>
+cmExportBuildFileGenerator
+::FindNamespaces(cmMakefile* mf, const std::string& name)
+{
+  std::vector<std::string> namespaces;
+  cmGlobalGenerator* gg = mf->GetLocalGenerator()->GetGlobalGenerator();
+
+  std::map<std::string, cmExportBuildFileGenerator*>& exportSets
+                                                  = gg->GetBuildExportSets();
+
+  for(std::map<std::string, cmExportBuildFileGenerator*>::const_iterator
+      expIt = exportSets.begin(); expIt != exportSets.end(); ++expIt)
+    {
+    const cmExportBuildFileGenerator* exportSet = expIt->second;
+    std::vector<std::string> const& targets = exportSet->GetTargets();
+
+    if (std::find(targets.begin(), targets.end(), name) != targets.end())
+      {
+      namespaces.push_back(exportSet->GetNamespace());
+      }
+    }
+
+  return namespaces;
 }
 
 //----------------------------------------------------------------------------
 void
 cmExportBuildFileGenerator
 ::ComplainAboutMissingTarget(cmTarget* depender,
-                             cmTarget* dependee)
+                             cmTarget* dependee,
+                             int occurrences)
 {
   if(cmSystemTools::GetErrorOccuredFlag())
     {
@@ -223,9 +270,17 @@ cmExportBuildFileGenerator
 
   cmOStringStream e;
   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, "
+    << "\" which requires target \"" << dependee->GetName() << "\" ";
+  if (occurrences == 0)
+    {
+    e << "that is not in the export set.\n";
+    }
+  else
+    {
+    e << "that is not in this export set, but " << occurrences
+    << " times in others.\n";
+    }
+  e << "If the required target is not easy to reference in this call, "
     << "consider using the APPEND option with multiple separate calls.";
 
   this->Makefile->GetCMakeInstance()
diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h
index 0392d80..2fbd98f 100644
--- a/Source/cmExportBuildFileGenerator.h
+++ b/Source/cmExportBuildFileGenerator.h
@@ -60,7 +60,8 @@ protected:
                                    cmTarget* dependee);
 
   void ComplainAboutMissingTarget(cmTarget* depender,
-                                  cmTarget* dependee);
+                                  cmTarget* dependee,
+                                  int occurrences);
 
   /** Fill in properties indicating built file locations.  */
   void SetImportLocationProperty(const char* config,
@@ -70,6 +71,9 @@ protected:
 
   std::string InstallNameDir(cmTarget* target, const std::string& config);
 
+  std::vector<std::string>
+  FindNamespaces(cmMakefile* mf, const std::string& name);
+
   std::vector<std::string> Targets;
   std::vector<cmTarget*> Exports;
   cmMakefile* Makefile;

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=38536de09069dfdd5f578bb6536761a4a1d163e7
commit 38536de09069dfdd5f578bb6536761a4a1d163e7
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Oct 6 17:27:40 2012 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Fri Oct 11 00:18:43 2013 +0200

    export(): Process the export() command at generate time.
    
    Make the API for adding targets string based so that it can easily
    use cmGeneratorTarget.
    
    Teach the cmIncludeCommand to generate the exported file at
    configure-time instead if it is to be include()d.

diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index e2ad74f..e593e0c 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -21,20 +21,19 @@ cmExportBuildFileGenerator::cmExportBuildFileGenerator()
 //----------------------------------------------------------------------------
 bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
 {
-  std::vector<cmTarget*> allTargets;
   {
   std::string expectedTargets;
   std::string sep;
-  for(std::vector<cmTarget*>::const_iterator
-        tei = this->Exports->begin();
-      tei != this->Exports->end(); ++tei)
+  for(std::vector<std::string>::const_iterator
+        tei = this->Targets.begin();
+      tei != this->Targets.end(); ++tei)
     {
-    expectedTargets += sep + this->Namespace + (*tei)->GetExportName();
+    cmTarget *te = this->Makefile->FindTargetToUse(tei->c_str());
+    expectedTargets += sep + this->Namespace + te->GetExportName();
     sep = " ";
-    cmTarget* te = *tei;
     if(this->ExportedTargets.insert(te).second)
       {
-      allTargets.push_back(te);
+      this->Exports.push_back(te);
       }
     else
       {
@@ -57,8 +56,8 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
 
   // Create all the imported targets.
   for(std::vector<cmTarget*>::const_iterator
-        tei = allTargets.begin();
-      tei != allTargets.end(); ++tei)
+        tei = this->Exports.begin();
+      tei != this->Exports.end(); ++tei)
     {
     cmTarget* te = *tei;
     this->GenerateImportTargetCode(os, te);
@@ -113,8 +112,8 @@ cmExportBuildFileGenerator
                             std::vector<std::string> &missingTargets)
 {
   for(std::vector<cmTarget*>::const_iterator
-        tei = this->Exports->begin();
-      tei != this->Exports->end(); ++tei)
+        tei = this->Exports.begin();
+      tei != this->Exports.end(); ++tei)
     {
     // Collect import properties for this target.
     cmTarget* target = *tei;
diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h
index 4436896..0392d80 100644
--- a/Source/cmExportBuildFileGenerator.h
+++ b/Source/cmExportBuildFileGenerator.h
@@ -30,8 +30,13 @@ public:
   cmExportBuildFileGenerator();
 
   /** Set the list of targets to export.  */
-  void SetExports(std::vector<cmTarget*> const* exports)
-    { this->Exports = exports; }
+  void SetTargets(std::vector<std::string> const& targets)
+    { this->Targets = targets; }
+  std::vector<std::string> const& GetTargets() const
+    { return this->Targets; }
+  void AppendTargets(std::vector<std::string> const& targets)
+    { this->Targets.insert(this->Targets.end(),
+      targets.begin(), targets.end()); }
 
   /** Set whether to append generated code to the output file.  */
   void SetAppendMode(bool append) { this->AppendMode = append; }
@@ -65,7 +70,8 @@ protected:
 
   std::string InstallNameDir(cmTarget* target, const std::string& config);
 
-  std::vector<cmTarget*> const* Exports;
+  std::vector<std::string> Targets;
+  std::vector<cmTarget*> Exports;
   cmMakefile* Makefile;
   cmListFileBacktrace Backtrace;
 };
diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx
index 9d0d478..86ddc3f 100644
--- a/Source/cmExportCommand.cxx
+++ b/Source/cmExportCommand.cxx
@@ -108,8 +108,6 @@ bool cmExportCommand
     fname += this->Filename.GetString();
     }
 
-  // Collect the targets to be exported.
-  std::vector<cmTarget*> targets;
   for(std::vector<std::string>::const_iterator
       currentTarget = this->Targets.GetVector().begin();
       currentTarget != this->Targets.GetVector().end();
@@ -128,15 +126,7 @@ bool cmExportCommand
        this->Makefile->GetLocalGenerator()->
        GetGlobalGenerator()->FindTarget(0, currentTarget->c_str()))
       {
-      if((target->GetType() == cmTarget::EXECUTABLE) ||
-         (target->GetType() == cmTarget::STATIC_LIBRARY) ||
-         (target->GetType() == cmTarget::SHARED_LIBRARY) ||
-         (target->GetType() == cmTarget::MODULE_LIBRARY) ||
-         (target->GetType() == cmTarget::INTERFACE_LIBRARY))
-        {
-        targets.push_back(target);
-        }
-      else if(target->GetType() == cmTarget::OBJECT_LIBRARY)
+      if(target->GetType() == cmTarget::OBJECT_LIBRARY)
         {
         cmOStringStream e;
         e << "given OBJECT library \"" << *currentTarget
@@ -144,37 +134,28 @@ bool cmExportCommand
         this->SetError(e.str().c_str());
         return false;
         }
-      else
-        {
-        cmOStringStream e;
-        e << "given target \"" << *currentTarget
-          << "\" which is not an executable or library.";
-        this->SetError(e.str().c_str());
-        return false;
-        }
       }
-    else
+    }
+
+  cmGlobalGenerator *gg = this->Makefile->GetLocalGenerator()
+                                        ->GetGlobalGenerator();
+  if (this->Append.IsEnabled())
+    {
+    if (cmExportBuildFileGenerator *ebfg = gg->GetExportedTargetsFile(fname))
       {
-      cmOStringStream e;
-      e << "given target \"" << *currentTarget
-        << "\" which is not built by this project.";
-      this->SetError(e.str().c_str());
-      return false;
+      ebfg->AppendTargets(this->Targets.GetVector());
+      return true;
       }
     }
 
   // Setup export file generation.
-  cmExportBuildFileGenerator ebfg;
-  ebfg.SetExportFile(fname.c_str());
-  ebfg.SetNamespace(this->Namespace.GetCString());
-  ebfg.SetAppendMode(this->Append.IsEnabled());
-  ebfg.SetExports(&targets);
-  ebfg.SetMakefile(this->Makefile);
-  ebfg.SetExportOld(this->ExportOld.IsEnabled());
-
-  cmGlobalGenerator *gg = this->Makefile->GetLocalGenerator()
-                                        ->GetGlobalGenerator();
-  gg->AddExportedTargetsFile(fname);
+  cmExportBuildFileGenerator *ebfg = new cmExportBuildFileGenerator;
+  ebfg->SetExportFile(fname.c_str());
+  ebfg->SetNamespace(this->Namespace.GetCString());
+  ebfg->SetAppendMode(this->Append.IsEnabled());
+  ebfg->SetTargets(this->Targets.GetVector());
+  ebfg->SetMakefile(this->Makefile);
+  ebfg->SetExportOld(this->ExportOld.IsEnabled());
 
   // Compute the set of configurations exported.
   std::vector<std::string> configurationTypes;
@@ -185,27 +166,15 @@ bool cmExportCommand
           ci = configurationTypes.begin();
         ci != configurationTypes.end(); ++ci)
       {
-      ebfg.AddConfiguration(ci->c_str());
+      ebfg->AddConfiguration(ci->c_str());
       }
     }
   else
     {
-    ebfg.AddConfiguration("");
+    ebfg->AddConfiguration("");
     }
 
-  // Generate the import file.
-  if(!ebfg.GenerateImportFile() && this->ErrorMessage.empty())
-    {
-    this->SetError("could not write export file.");
-    return false;
-    }
-
-  // Report generated error message if any.
-  if(!this->ErrorMessage.empty())
-    {
-    this->SetError(this->ErrorMessage.c_str());
-    return false;
-    }
+  gg->AddBuildExportSet(ebfg);
 
   return true;
 }
diff --git a/Source/cmExportCommand.h b/Source/cmExportCommand.h
index 87c3452..38e8d9a 100644
--- a/Source/cmExportCommand.h
+++ b/Source/cmExportCommand.h
@@ -85,7 +85,9 @@ public:
       "should never be installed.  "
       "See the install(EXPORT) command to export targets from an "
       "installation tree."
-      CM_LOCATION_UNDEFINED_BEHAVIOR("passing it to this command")
+      "\n"
+      "The properties set on the generated IMPORTED targets will have the "
+      "same values as the final values of the input TARGETS."
       "\n"
       "  export(PACKAGE <name>)\n"
       "Store the current build directory in the CMake user package registry "
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 25c5710..b01e499 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -52,6 +52,12 @@ void cmExportFileGenerator::SetExportFile(const char* mainFile)
 }
 
 //----------------------------------------------------------------------------
+const char* cmExportFileGenerator::GetMainExportFileName() const
+{
+  return this->MainImportFile.c_str();
+}
+
+//----------------------------------------------------------------------------
 bool cmExportFileGenerator::GenerateImportFile()
 {
   // Open the output file to generate it.
diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h
index 9628b96..f3d0807 100644
--- a/Source/cmExportFileGenerator.h
+++ b/Source/cmExportFileGenerator.h
@@ -33,9 +33,11 @@ public:
 
   /** Set the full path to the export file to generate.  */
   void SetExportFile(const char* mainFile);
+  const char *GetMainExportFileName() const;
 
   /** Set the namespace in which to place exported target names.  */
   void SetNamespace(const char* ns) { this->Namespace = ns; }
+  std::string GetNamespace() const { return this->Namespace; }
 
   void SetExportOld(bool exportOld) { this->ExportOld = exportOld; }
 
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index eacf85b..fa87e91 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -27,6 +27,7 @@
 #include "cmGeneratorTarget.h"
 #include "cmGeneratorExpression.h"
 #include "cmGeneratorExpressionEvaluationFile.h"
+#include "cmExportBuildFileGenerator.h"
 
 #include <cmsys/Directory.hxx>
 
@@ -77,6 +78,12 @@ cmGlobalGenerator::~cmGlobalGenerator()
     {
     delete *li;
     }
+  for(std::map<std::string, cmExportBuildFileGenerator*>::iterator
+        i = this->BuildExportSets.begin();
+      i != this->BuildExportSets.end(); ++i)
+    {
+    delete i->second;
+    }
   this->LocalGenerators.clear();
 
   if (this->ExtraGenerator)
@@ -183,6 +190,33 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang,
                          doc.c_str(), cmCacheManager::FILEPATH);
 }
 
+void cmGlobalGenerator::AddBuildExportSet(cmExportBuildFileGenerator* gen)
+{
+  this->BuildExportSets[gen->GetMainExportFileName()] = gen;
+}
+
+bool cmGlobalGenerator::GenerateImportFile(const std::string &file)
+{
+  std::map<std::string, cmExportBuildFileGenerator*>::iterator it
+                                          = this->BuildExportSets.find(file);
+  if (it != this->BuildExportSets.end())
+    {
+    bool result = it->second->GenerateImportFile();
+    delete it->second;
+    it->second = 0;
+    this->BuildExportSets.erase(it);
+    return result;
+    }
+  return false;
+}
+
+bool cmGlobalGenerator::IsExportedTargetsFile(const std::string &filename) const
+{
+  const std::map<std::string, cmExportBuildFileGenerator*>::const_iterator it
+                                      = this->BuildExportSets.find(filename);
+  return it != this->BuildExportSets.end();
+}
+
 // Find the make program for the generator, required for try compiles
 void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
 {
@@ -966,6 +1000,14 @@ void cmGlobalGenerator::Configure()
     }
 }
 
+cmExportBuildFileGenerator*
+cmGlobalGenerator::GetExportedTargetsFile(const std::string &filename) const
+{
+  std::map<std::string, cmExportBuildFileGenerator*>::const_iterator it
+    = this->BuildExportSets.find(filename);
+  return it == this->BuildExportSets.end() ? 0 : it->second;
+}
+
 bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS()
 {
   // If the property is not enabled then okay.
@@ -1091,6 +1133,19 @@ void cmGlobalGenerator::Generate()
     }
   this->SetCurrentLocalGenerator(0);
 
+  for (std::map<std::string, cmExportBuildFileGenerator*>::iterator
+      it = this->BuildExportSets.begin(); it != this->BuildExportSets.end();
+      ++it)
+    {
+    if (!it->second->GenerateImportFile()
+        && !cmSystemTools::GetErrorOccuredFlag())
+      {
+      this->GetCMakeInstance()
+          ->IssueMessage(cmake::FATAL_ERROR, "Could not write export file.",
+                        cmListFileBacktrace());
+      return;
+      }
+    }
   // Update rule hashes.
   this->CheckRuleHashes();
 
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index b8860f1..c930b2b 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -31,6 +31,7 @@ class cmExternalMakefileProjectGenerator;
 class cmTarget;
 class cmInstallTargetGenerator;
 class cmInstallFilesGenerator;
+class cmExportBuildFileGenerator;
 
 /** \class cmGlobalGenerator
  * \brief Responable for overseeing the generation process for the entire tree
@@ -293,18 +294,13 @@ public:
 
   void ProcessEvaluationFiles();
 
-  void AddExportedTargetsFile(const std::string &filename)
-  {
-    this->ExportedTargetsFiles.insert(filename);
-  }
-
-  bool IsExportedTargetsFile(const std::string &filename) const
-  {
-    const std::set<std::string>::const_iterator it
-                                  = this->ExportedTargetsFiles.find(filename);
-    return it != this->ExportedTargetsFiles.end();
-  }
-
+  std::map<std::string, cmExportBuildFileGenerator*>& GetBuildExportSets()
+    {return this->BuildExportSets;}
+  void AddBuildExportSet(cmExportBuildFileGenerator*);
+  bool IsExportedTargetsFile(const std::string &filename) const;
+  bool GenerateImportFile(const std::string &file);
+  cmExportBuildFileGenerator*
+  GetExportedTargetsFile(const std::string &filename) const;
 protected:
   typedef std::vector<cmLocalGenerator*> GeneratorVector;
   // for a project collect all its targets by following depend
@@ -356,6 +352,7 @@ protected:
   bool InstallTargetEnabled;
   // Sets of named target exports
   cmExportSetMap ExportSets;
+  std::map<std::string, cmExportBuildFileGenerator*> BuildExportSets;
 
   // Manifest of all targets that will be built for each configuration.
   // This is computed just before local generators generate.
@@ -384,7 +381,6 @@ private:
   std::map<cmStdString, cmStdString> ExtensionToLanguage;
   std::map<cmStdString, int> LanguageToLinkerPreference;
   std::map<cmStdString, cmStdString> LanguageToOriginalSharedLibFlags;
-  std::set<std::string> ExportedTargetsFiles;
 
   // Record hashes for rules and outputs.
   struct RuleHash { char Data[32]; };
diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx
index 39d4993..5b93171 100644
--- a/Source/cmIncludeCommand.cxx
+++ b/Source/cmIncludeCommand.cxx
@@ -127,6 +127,7 @@ bool cmIncludeCommand
         return false;
         }
       }
+    gg->GenerateImportFile(fname_abs);
     }
 
   std::string fullFilePath;
diff --git a/Tests/RunCMake/CMP0022/CMP0022-export-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-export-stderr.txt
index ae7627e..405dd8d 100644
--- a/Tests/RunCMake/CMP0022/CMP0022-export-stderr.txt
+++ b/Tests/RunCMake/CMP0022/CMP0022-export-stderr.txt
@@ -1,4 +1,4 @@
-CMake Error at CMP0022-export.cmake:11 \(export\):
+CMake Error in CMakeLists.txt:
   Target "cmp0022NEW" has policy CMP0022 enabled, but also has old-style
   LINK_INTERFACE_LIBRARIES properties populated, but it was exported without
   the EXPORT_LINK_INTERFACE_LIBRARIES to export the old-style properties
diff --git a/Tests/RunCMake/ExportWithoutLanguage/NoLanguage-stderr.txt b/Tests/RunCMake/ExportWithoutLanguage/NoLanguage-stderr.txt
index 67a0ae3..5658d85 100644
--- a/Tests/RunCMake/ExportWithoutLanguage/NoLanguage-stderr.txt
+++ b/Tests/RunCMake/ExportWithoutLanguage/NoLanguage-stderr.txt
@@ -1,6 +1,4 @@
 CMake Error: CMake can not determine linker language for target: NoLanguage
-CMake Error at NoLanguage.cmake:2 \(export\):
+CMake Error in CMakeLists.txt:
   Exporting the target "NoLanguage" is not allowed since its linker language
   cannot be determined
-Call Stack \(most recent call first\):
-  CMakeLists.txt:3 \(include\)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5fe5c32480a5acf26bd20e52a091cd63747ed77d
commit 5fe5c32480a5acf26bd20e52a091cd63747ed77d
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Oct 6 17:16:11 2012 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Oct 10 16:36:26 2013 +0200

    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.

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()

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e383555838c2539eca11c43abfccba9fa41ca97d
commit e383555838c2539eca11c43abfccba9fa41ca97d
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Thu Oct 10 11:14:11 2013 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu Oct 10 12:02:32 2013 +0200

    cmExportInstallFileGenerator: Fix comment to match reality.
    
    It was copied from cmExportBuildFileGenerator.

diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index c71008e..133944e 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -432,8 +432,8 @@ cmExportInstallFileGenerator::HandleMissingTarget(
     }
   else
     {
-    // We are not appending, so all exported targets should be
-    // known here.  This is probably user-error.
+    // All exported targets should be known here and should be unique.
+    // This is probably user-error.
     this->ComplainAboutMissingTarget(depender, dependee, targetOccurrences);
     }
 }

-----------------------------------------------------------------------

Summary of changes:
 Source/cmExportBuildFileGenerator.cxx              |  115 ++++++++++++++------
 Source/cmExportBuildFileGenerator.h                |   31 ++++--
 Source/cmExportCommand.cxx                         |   71 ++++---------
 Source/cmExportCommand.h                           |    4 +-
 Source/cmExportFileGenerator.cxx                   |    6 +
 Source/cmExportFileGenerator.h                     |    2 +
 Source/cmExportInstallFileGenerator.cxx            |    4 +-
 Source/cmGlobalGenerator.cxx                       |   55 ++++++++++
 Source/cmGlobalGenerator.h                         |   22 ++---
 Source/cmIncludeCommand.cxx                        |    1 +
 Tests/RunCMake/CMP0022/CMP0022-export-stderr.txt   |    2 +-
 .../ExportWithoutLanguage/NoLanguage-stderr.txt    |    4 +-
 12 files changed, 206 insertions(+), 111 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list