[Cmake-commits] CMake branch, next, updated. v2.8.9-895-gc6c781f

Brad King brad.king at kitware.com
Sun Sep 30 10:28:35 EDT 2012


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  c6c781f2c2cc4768928fb7ffc830374b85afdf6e (commit)
       via  80112da54e1aa8e64f73a2a5a6a4f73431ac6764 (commit)
       via  955b96629e05bf2ddb6c94fa7a130e2b5b744782 (commit)
       via  6f50a04cc1c4584472f850e06daad7ae20af45c4 (commit)
       via  0cfd055acda3543d66690b5e92d8ee7c20e0654f (commit)
      from  a7e80609f2ff4e24e0a328928d1ff4046a88718a (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=c6c781f2c2cc4768928fb7ffc830374b85afdf6e
commit c6c781f2c2cc4768928fb7ffc830374b85afdf6e
Merge: a7e8060 80112da
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Sun Sep 30 10:28:32 2012 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Sun Sep 30 10:28:32 2012 -0400

    Merge topic 'export-sets' into next
    
    80112da Merge topic 'AutomocUseTargetProperties' into export-sets
    955b966 exports: add a test for exporting dependent targets
    6f50a04 exports: define a CMAKE_FIND_PACKAGE_NAME var set by find_package()
    0cfd055 exports: move the handling of missing targets into subclasses


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=80112da54e1aa8e64f73a2a5a6a4f73431ac6764
commit 80112da54e1aa8e64f73a2a5a6a4f73431ac6764
Merge: 955b966 e83cc94
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Mon Sep 24 22:06:20 2012 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Sun Sep 30 10:27:44 2012 -0400

    Merge topic 'AutomocUseTargetProperties' into export-sets
    
    Conflicts:
    	Source/cmGlobalGenerator.h

diff --cc Source/cmGlobalGenerator.h
index 71c3a4d,2f4ebc3..0aab2d6
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@@ -18,7 -18,7 +18,9 @@@
  #include "cmTarget.h" // For cmTargets
  #include "cmTargetDepend.h" // For cmTargetDependSet
  #include "cmSystemTools.h" // for cmSystemTools::OutputOption
 +#include "cmExportSetMap.h" // For cmExportSetMap
+ #include "cmGeneratorTarget.h"
++
  class cmake;
  class cmGeneratorTarget;
  class cmMakefile;

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=955b96629e05bf2ddb6c94fa7a130e2b5b744782
commit 955b96629e05bf2ddb6c94fa7a130e2b5b744782
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Sun Sep 23 19:19:55 2012 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Sun Sep 30 10:27:02 2012 -0400

    exports: add a test for exporting dependent targets
    
    The test exports two libraries into two separate exports,
    and then include()s the generated export files. This must not fail.
    
    Alex

diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt
index f118c30..e19ab88 100644
--- a/Tests/ExportImport/Export/CMakeLists.txt
+++ b/Tests/ExportImport/Export/CMakeLists.txt
@@ -87,6 +87,18 @@ target_link_libraries(testLibCycleA testLibCycleB)
 target_link_libraries(testLibCycleB testLibCycleA)
 set_property(TARGET testLibCycleA PROPERTY LINK_INTERFACE_MULTIPLICITY 3)
 
+# Test exporting dependent libraries into different exports
+add_library(testLibRequired testLibRequired.c)
+add_library(testLibDepends testLibDepends.c)
+target_link_libraries(testLibDepends testLibRequired)
+
+install(TARGETS testLibRequired EXPORT RequiredExp DESTINATION lib )
+install(EXPORT RequiredExp NAMESPACE Req:: FILE testLibRequiredConfig.cmake DESTINATION lib/cmake/testLibRequired)
+
+install(TARGETS testLibDepends EXPORT DependsExp DESTINATION lib )
+install(EXPORT DependsExp FILE testLibDependsConfig.cmake DESTINATION lib/cmake/testLibDepends)
+
+
 # Install and export from install tree.
 install(
   TARGETS
diff --git a/Tests/ExportImport/Export/testLibDepends.c b/Tests/ExportImport/Export/testLibDepends.c
new file mode 100644
index 0000000..2849b33
--- /dev/null
+++ b/Tests/ExportImport/Export/testLibDepends.c
@@ -0,0 +1,4 @@
+
+extern int testLibRequired(void);
+
+int testLibDepends(void) { return testLibRequired(); }
diff --git a/Tests/ExportImport/Export/testLibRequired.c b/Tests/ExportImport/Export/testLibRequired.c
new file mode 100644
index 0000000..e126d44
--- /dev/null
+++ b/Tests/ExportImport/Export/testLibRequired.c
@@ -0,0 +1 @@
+int testLibRequired(void) { return 0; }
diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt
index 650af6a..8841792 100644
--- a/Tests/ExportImport/Import/A/CMakeLists.txt
+++ b/Tests/ExportImport/Import/A/CMakeLists.txt
@@ -4,6 +4,10 @@ include(${Import_BINARY_DIR}/../Export/ExportBuildTree.cmake)
 # Import targets from the exported install tree.
 include(${CMAKE_INSTALL_PREFIX}/lib/exp/exp.cmake)
 
+# Import two exports, where the Depends one depends on an exported target from the Required one:
+include(${CMAKE_INSTALL_PREFIX}/lib/cmake/testLibRequired/testLibRequiredConfig.cmake)
+include(${CMAKE_INSTALL_PREFIX}/lib/cmake/testLibDepends/testLibDependsConfig.cmake)
+
 # Try referencing an executable imported from the install tree.
 add_custom_command(
   OUTPUT ${Import_BINARY_DIR}/exp_generated.c

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6f50a04cc1c4584472f850e06daad7ae20af45c4
commit 6f50a04cc1c4584472f850e06daad7ae20af45c4
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Sun Sep 23 18:40:40 2012 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Sun Sep 30 10:26:54 2012 -0400

    exports: define a CMAKE_FIND_PACKAGE_NAME var set by find_package()
    
    This way the name of the searched package can be accessed in find-modules,
    config-files and more importantly in generated target export files.
    This is now used when a target export file detects that a required
    target does not exist.
    
    Alex

diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 5d95668..8dffae4 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -389,8 +389,15 @@ void cmExportFileGenerator::GenerateMissingTargetsCheckCode(std::ostream& os,
   for(unsigned int i=0; i<missingTargets.size(); ++i)
     {
     os << "IF(NOT TARGET \"" << missingTargets[i] << "\" )\n"
-       << "  MESSAGE(FATAL_ERROR \"Required imported target \\\""
+       << "  IF(CMAKE_FIND_PACKAGE_NAME)\n"
+       << "    SET( ${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)\n"
+       << "    SET( ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "
+       << "\"Required imported target \\\"" << missingTargets[i]
+       << "\\\" not found ! \")\n"
+       << "  ELSE()\n"
+       << "    MESSAGE(FATAL_ERROR \"Required imported target \\\""
        << missingTargets[i] << "\\\" not found ! \")\n"
+       << "  ENDIF()\n"
        << "ENDIF()\n";
     }
   os << "\n";
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index c20941a..470ceca 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -840,6 +840,8 @@ bool cmFindPackageCommand
 //----------------------------------------------------------------------------
 void cmFindPackageCommand::SetModuleVariables(const std::string& components)
 {
+  this->AddFindDefinition("CMAKE_FIND_PACKAGE_NAME", this->Name.c_str());
+
   // Store the list of components.
   std::string components_var = this->Name + "_FIND_COMPONENTS";
   this->AddFindDefinition(components_var.c_str(), components.c_str());

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0cfd055acda3543d66690b5e92d8ee7c20e0654f
commit 0cfd055acda3543d66690b5e92d8ee7c20e0654f
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Fri Sep 28 21:47:37 2012 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Sun Sep 30 10:26:10 2012 -0400

    exports: move the handling of missing targets into subclasses
    
    Before, cmExportFileGenerator::ComplainAboutMissingTarget() was a virtual
    function which had to be implemented in the subclasses. It is not
    anymore. Instead, there is now a virtual function
    HandleMissingTargets(), which is implemented in the two subclasses.
    This makes e.g. dealing correctly with APPEND mode easier.
    
    Alex

diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index 22ae0e4..fb3f39f 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -135,10 +135,28 @@ cmExportBuildFileGenerator
 
 //----------------------------------------------------------------------------
 void
+cmExportBuildFileGenerator::HandleMissingTarget(
+  std::string& link_libs, std::vector<std::string>&,
+  cmMakefile*, 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);
+    }
+  // Assume the target will be exported by another command.
+  // Append it with the export namespace.
+  link_libs += this->Namespace;
+  link_libs += dependee->GetName();
+}
+
+//----------------------------------------------------------------------------
+void
 cmExportBuildFileGenerator
 ::ComplainAboutMissingTarget(cmTarget* depender,
-                             cmTarget* dependee,
-                             int occurrences)
+                             cmTarget* dependee)
 {
   if(!this->ExportCommand || !this->ExportCommand->ErrorMessage.empty())
     {
@@ -146,20 +164,10 @@ cmExportBuildFileGenerator
     }
 
   cmOStringStream e;
-  if (occurrences == 0)
-    {
-    e << "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.";
-    }
-  else
-    {
-    e << "called with target \"" << depender->GetName()
-      << "\" which requires target \"" << dependee->GetName()
-      << "\" that is exported " << occurrences << " times in other "
-      << "export ""lists.\n";
-    }
+  e << "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();
 }
diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h
index 69f8407..726537b 100644
--- a/Source/cmExportBuildFileGenerator.h
+++ b/Source/cmExportBuildFileGenerator.h
@@ -45,9 +45,14 @@ protected:
   virtual void GenerateImportTargetsConfig(std::ostream& os,
                                            const char* config,
                                            std::string const& suffix);
-  virtual void ComplainAboutMissingTarget(cmTarget* depender,
-                                          cmTarget* dependee,
-                                          int occurrences);
+  virtual void HandleMissingTarget(std::string& link_libs,
+                                   std::vector<std::string>& missingTargets,
+                                   cmMakefile* mf,
+                                   cmTarget* depender,
+                                   cmTarget* dependee);
+
+  void ComplainAboutMissingTarget(cmTarget* depender,
+                                  cmTarget* dependee);
 
   /** Fill in properties indicating built file locations.  */
   void SetImportLocationProperty(const char* config,
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index dc4fa31..5d95668 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -233,30 +233,7 @@ cmExportFileGenerator
         }
       else
         {
-        std::vector<std::string> namespaces = this->FindNamespaces(mf, *li);
-        int targetOccurrences = (int)namespaces.size();
-
-        if (targetOccurrences == 1)
-          {
-          std::string missingTarget = namespaces[0];
-          missingTarget += *li;
-          link_libs += missingTarget;
-          missingTargets.push_back(missingTarget);
-          }
-        else
-          {
-          // 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(target, tgt, targetOccurrences);
-            }
-          // Assume the target will be exported by another command.
-          // Append it with the export namespace.
-          link_libs += this->Namespace;
-          link_libs += *li;
-          }
+        this->HandleMissingTarget(link_libs, missingTargets, mf, target, tgt);
         }
       }
     else
@@ -274,47 +251,6 @@ cmExportFileGenerator
 
 
 //----------------------------------------------------------------------------
-std::vector<std::string> cmExportFileGenerator::FindNamespaces(cmMakefile* mf,
-                                                       const std::string& name)
-{
-  std::vector<std::string> namespaces;
-  cmGlobalGenerator* gg = mf->GetLocalGenerator()->GetGlobalGenerator();
-  const cmExportSetMap& exportSets = gg->GetExportSets();
-
-  for(cmExportSetMap::const_iterator expIt = exportSets.begin();
-      expIt != exportSets.end();
-      ++expIt)
-    {
-    const cmExportSet* exportSet = expIt->second;
-    std::vector<cmTargetExport*> const* targets =
-                                                 exportSet->GetTargetExports();
-
-    bool containsTarget = false;
-    for(unsigned int i=0; i<targets->size(); i++)
-      {
-      if (name == (*targets)[i]->Target->GetName())
-        {
-        containsTarget = true;
-        break;
-        }
-      }
-
-    if (containsTarget)
-      {
-      std::vector<cmInstallExportGenerator const*> const* installs =
-                                                 exportSet->GetInstallations();
-      for(unsigned int i=0; i<installs->size(); i++)
-        {
-        namespaces.push_back((*installs)[i]->GetNamespace());
-        }
-      }
-    }
-
-  return namespaces;
-}
-
-
-//----------------------------------------------------------------------------
 void cmExportFileGenerator::GenerateImportHeaderCode(std::ostream& os,
                                                      const char* config)
 {
diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h
index 5a99b54..70bc65d 100644
--- a/Source/cmExportFileGenerator.h
+++ b/Source/cmExportFileGenerator.h
@@ -84,15 +84,13 @@ protected:
                                            const char* config,
                                            std::string const& suffix) = 0;
 
-  /** Each subclass knows how to complain about a target that is
-      missing from an export set.  */
-  virtual void ComplainAboutMissingTarget(cmTarget* depender,
-                                          cmTarget* dependee,
-                                          int occurrences) = 0;
-
-  std::vector<std::string> FindNamespaces(cmMakefile* mf,
-                                          const std::string& name);
-
+  /** Each subclass knows how to deal with a target that is  missing from an
+   *  export set.  */
+  virtual void HandleMissingTarget(std::string& link_libs,
+                                   std::vector<std::string>& missingTargets,
+                                   cmMakefile* mf,
+                                   cmTarget* depender,
+                                   cmTarget* dependee) = 0;
 
   // The namespace in which the exports are placed in the generated file.
   std::string Namespace;
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index cd05e60..7841731 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -11,11 +11,14 @@
 ============================================================================*/
 #include "cmExportInstallFileGenerator.h"
 
+#include "cmExportSet.h"
+#include "cmExportSetMap.h"
 #include "cmGeneratedFileStream.h"
+#include "cmGlobalGenerator.h"
+#include "cmLocalGenerator.h"
 #include "cmInstallExportGenerator.h"
 #include "cmInstallTargetGenerator.h"
 #include "cmTargetExport.h"
-#include "cmExportSet.h"
 
 //----------------------------------------------------------------------------
 cmExportInstallFileGenerator
@@ -311,6 +314,72 @@ cmExportInstallFileGenerator
 
 //----------------------------------------------------------------------------
 void
+cmExportInstallFileGenerator::HandleMissingTarget(
+  std::string& link_libs, std::vector<std::string>& missingTargets,
+  cmMakefile* mf, cmTarget* depender, cmTarget* dependee)
+{
+  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 += name;
+    link_libs += missingTarget;
+    missingTargets.push_back(missingTarget);
+    }
+  else
+    {
+    // We are not appending, so all exported targets should be
+    // known here.  This is probably user-error.
+    this->ComplainAboutMissingTarget(depender, dependee, targetOccurrences);
+    }
+}
+
+//----------------------------------------------------------------------------
+std::vector<std::string>
+cmExportInstallFileGenerator
+::FindNamespaces(cmMakefile* mf, const std::string& name)
+{
+  std::vector<std::string> namespaces;
+  cmGlobalGenerator* gg = mf->GetLocalGenerator()->GetGlobalGenerator();
+  const cmExportSetMap& exportSets = gg->GetExportSets();
+
+  for(cmExportSetMap::const_iterator expIt = exportSets.begin();
+      expIt != exportSets.end();
+      ++expIt)
+    {
+    const cmExportSet* exportSet = expIt->second;
+    std::vector<cmTargetExport*> const* targets =
+                                                 exportSet->GetTargetExports();
+
+    bool containsTarget = false;
+    for(unsigned int i=0; i<targets->size(); i++)
+      {
+      if (name == (*targets)[i]->Target->GetName())
+        {
+        containsTarget = true;
+        break;
+        }
+      }
+
+    if (containsTarget)
+      {
+      std::vector<cmInstallExportGenerator const*> const* installs =
+                                                 exportSet->GetInstallations();
+      for(unsigned int i=0; i<installs->size(); i++)
+        {
+        namespaces.push_back((*installs)[i]->GetNamespace());
+        }
+      }
+    }
+
+  return namespaces;
+}
+
+
+//----------------------------------------------------------------------------
+void
 cmExportInstallFileGenerator
 ::ComplainAboutImportPrefix(cmInstallTargetGenerator* itgen)
 {
diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h
index f6f397e..e719ecc 100644
--- a/Source/cmExportInstallFileGenerator.h
+++ b/Source/cmExportInstallFileGenerator.h
@@ -57,9 +57,19 @@ protected:
   virtual void GenerateImportTargetsConfig(std::ostream& os,
                                            const char* config,
                                            std::string const& suffix);
-  virtual void ComplainAboutMissingTarget(cmTarget* depender,
-                                          cmTarget* dependee,
-                                          int occurrences);
+  virtual void HandleMissingTarget(std::string& link_libs,
+                                   std::vector<std::string>& missingTargets,
+                                   cmMakefile* mf,
+                                   cmTarget* depender,
+                                   cmTarget* dependee);
+
+  void ComplainAboutMissingTarget(cmTarget* depender,
+                                  cmTarget* dependee,
+                                  int occurrences);
+
+  std::vector<std::string> FindNamespaces(cmMakefile* mf,
+                                          const std::string& name);
+
 
   /** Generate a per-configuration file for the targets.  */
   bool GenerateImportFileConfig(const char* config);

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

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list