[Cmake-commits] CMake branch, next, updated. v2.8.6-1913-gf971d85

Alexander Neundorf neundorf at kde.org
Wed Nov 16 15:57:03 EST 2011


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  f971d858190fa56c79899de81d2415aa47c15fc1 (commit)
       via  3c265207e3e49abc92c2275de25fd5cdffbf808b (commit)
       via  caf3de0e911f0648e0b440276b6233bbe96b960f (commit)
      from  67d15e668e65940d9bb04eddb239e97e5608f79d (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=f971d858190fa56c79899de81d2415aa47c15fc1
commit f971d858190fa56c79899de81d2415aa47c15fc1
Merge: 67d15e6 3c26520
Author:     Alexander Neundorf <neundorf at kde.org>
AuthorDate: Wed Nov 16 15:56:58 2011 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Nov 16 15:56:58 2011 -0500

    Merge topic 'CheckImportedFileExistenceInConfigDotCMakeFiles' into next
    
    3c26520 Move code for checking whether a file exists into one loop at the end
    caf3de0 Config.cmake: add cmake code which ensures imported files actually exist


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3c265207e3e49abc92c2275de25fd5cdffbf808b
commit 3c265207e3e49abc92c2275de25fd5cdffbf808b
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Tue Nov 15 21:11:58 2011 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Wed Nov 16 21:50:47 2011 +0100

    Move code for checking whether a file exists into one loop at the end
    
    This way less code is duplicated in the generated Config.cmake file.
    
    Alex

diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index ed29920..b754420 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -89,6 +89,8 @@ cmExportBuildFileGenerator
                                            importedLocations);
       }
     }
+
+  this->GenerateImportedFileCheckLoop(os);
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 349e76e..a645464 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -372,6 +372,41 @@ cmExportFileGenerator
 
 //----------------------------------------------------------------------------
 void
+cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os)
+{
+  // Add code which verifies at cmake time that the file which is being
+  // imported actually exists on disk. This should in theory always be theory
+  // case, but still when packages are split into normal and development
+  // packages this might get broken (e.g. the Config.cmake could be part of
+  // the non-development package, something similar happened to me without
+  // on SUSE with a mysql pkg-config file, which claimed everything is fine,
+  // but the development package was not installed.).
+  os << "# Loop over all imported files and verify that they actually exist\n"
+        "FOREACH(target ${_IMPORT_CHECK_TARGETS} )\n"
+        "  FOREACH(file ${_IMPORT_CHECK_FILES_FOR_${target}} )\n"
+        "    IF(NOT EXISTS \"${file}\" )\n"
+        "      MESSAGE(FATAL_ERROR \"The file \\\"${file}\\\" "
+        "for the imported target \\\"${target}\\\" does not exist.\n"
+        "There are multiple possible reasons:\n"
+        " * the file \\\"${file}\\\" has been manually "
+        "deleted, renamed or moved to another location\n"
+        " * a previous install or uninstall procedure did not run "
+        " successfully to its end\n"
+        " * the installation package was faulty, and contained \\\""
+        "${CMAKE_CURRENT_LIST_FILE}\\\", but not \\\"${file}\\\", which "
+        "must always be installed together.\\n\"\n"
+        "             )\n"
+        "    ENDIF()\n"
+        "  ENDFOREACH()\n"
+        "  UNSET(_IMPORT_CHECK_FILES_FOR_${target})\n"
+        "ENDFOREACH()\n"
+        "UNSET(_IMPORT_CHECK_TARGETS)\n"
+        "\n";
+}
+
+
+//----------------------------------------------------------------------------
+void
 cmExportFileGenerator
 ::GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target,
                                  ImportPropertyMap const& properties,
@@ -381,13 +416,9 @@ cmExportFileGenerator
   std::string targetName = this->Namespace;
   targetName += target->GetName();
 
-  // Add code which verifies at cmake time that the file which is being
-  // imported actually exists on disk. This should in theory always be theory
-  // case, but still when packages are split into normal and development
-  // packages this might get broken (e.g. the Config.cmake could be part of
-  // the non-development package, something similar happened to me without
-  // on SUSE with a mysql pkg-config file, which claimed everything is fine,
-  // but the development package was not installed.).
+  os << "LIST(APPEND _IMPORT_CHECK_TARGETS " << targetName << " )\n"
+        "LIST(APPEND _IMPORT_CHECK_FILES_FOR_" << targetName << " ";
+
   for(std::set<std::string>::const_iterator li = importedLocations.begin();
       li != importedLocations.end();
       ++li)
@@ -395,22 +426,9 @@ cmExportFileGenerator
     ImportPropertyMap::const_iterator pi = properties.find(*li);
     if (pi != properties.end())
       {
-      std::string filename = pi->second;
-      os << "IF(NOT EXISTS \"" << filename << "\" )\n"
-            "  MESSAGE(FATAL_ERROR \"The file \\\"" << filename << "\\\" "
-            "for the imported target \\\"" << targetName <<"\\\" "
-            "does not exist.\n"
-            "There are multiple possible reasons:\n"
-            " * the file \\\"" << filename << "\\\" has been manually "
-            "deleted, renamed or moved to another location\n"
-            " * a previous install or uninstall procedure did not run "
-            " successfully to its end\n"
-            " * the installation package was faulty, and contained \\\""
-        << cmSystemTools::GetFilenameName(this->MainImportFile)
-        << "\\\", but not \\\" " << filename
-        << "\\\", which must always be installed together.\n"
-            "\")\n"
-            "ENDIF()"<< "\n\n";
+      os << "\"" << pi->second << "\" ";
       }
     }
+
+  os << ")\n\n";
 }
diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h
index 3b24911..f271e55 100644
--- a/Source/cmExportFileGenerator.h
+++ b/Source/cmExportFileGenerator.h
@@ -59,6 +59,7 @@ protected:
   void GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target,
                                       ImportPropertyMap const& properties,
                                const std::set<std::string>& importedLocations);
+  void GenerateImportedFileCheckLoop(std::ostream& os);
 
 
   // Collect properties with detailed information about targets beyond
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index 6b8e228..0bf226e 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -200,6 +200,8 @@ cmExportInstallFileGenerator
       }
     }
 
+  this->GenerateImportedFileCheckLoop(os);
+
   // Cleanup the import prefix variable.
   if(!this->ImportPrefix.empty())
     {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=caf3de0e911f0648e0b440276b6233bbe96b960f
commit caf3de0e911f0648e0b440276b6233bbe96b960f
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Sat Nov 12 18:12:07 2011 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Mon Nov 14 21:52:31 2011 +0100

    Config.cmake: add cmake code which ensures imported files actually exist
    
    When using Config.cmake files for find_package(), we rely only on the
    information in these files. They might be wrong, for whatever reasons,
    like people manually deleted files, projects were packaged wrong by
    distributions, whatever.
    To protect against this, add checks that the file locations we are
    importing actually exist on disk.
    
    Alex

diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index 7e73e36..ed29920 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -68,7 +68,9 @@ cmExportBuildFileGenerator
     // Collect import properties for this target.
     cmTarget* target = *tei;
     ImportPropertyMap properties;
-    this->SetImportLocationProperty(config, suffix, target, properties);
+    std::set<std::string> importedLocations;
+    this->SetImportLocationProperty(config, suffix, target, properties,
+                                    importedLocations);
     if(!properties.empty())
       {
       // Get the rest of the target details.
@@ -83,6 +85,8 @@ cmExportBuildFileGenerator
 
       // Generate code in the export file.
       this->GenerateImportPropertyCode(os, config, target, properties);
+      this->GenerateImportedFileChecksCode(os, target, properties,
+                                           importedLocations);
       }
     }
 }
@@ -91,7 +95,8 @@ cmExportBuildFileGenerator
 void
 cmExportBuildFileGenerator
 ::SetImportLocationProperty(const char* config, std::string const& suffix,
-                            cmTarget* target, ImportPropertyMap& properties)
+                            cmTarget* target, ImportPropertyMap& properties,
+                            std::set<std::string>& importedLocations)
 {
   // Get the makefile in which to lookup target information.
   cmMakefile* mf = target->GetMakefile();
@@ -110,6 +115,7 @@ cmExportBuildFileGenerator
     value = target->GetFullPath(config, false, true);
     }
   properties[prop] = value;
+  importedLocations.insert(prop);
   }
 
   // Check whether this is a DLL platform.
@@ -126,6 +132,7 @@ cmExportBuildFileGenerator
     prop += suffix;
     std::string value = target->GetFullPath(config, true);
     properties[prop] = value;
+    importedLocations.insert(prop);
     }
 }
 
diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h
index 0f37626..18be68e 100644
--- a/Source/cmExportBuildFileGenerator.h
+++ b/Source/cmExportBuildFileGenerator.h
@@ -52,7 +52,8 @@ protected:
   void SetImportLocationProperty(const char* config,
                                  std::string const& suffix,
                                  cmTarget* target,
-                                 ImportPropertyMap& properties);
+                                 ImportPropertyMap& properties,
+                                 std::set<std::string>& importedLocations);
 
   std::vector<cmTarget*> const* Exports;
   cmExportCommand* ExportCommand;
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 9e5c91e..349e76e 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -368,3 +368,49 @@ cmExportFileGenerator
   os << "  )\n"
      << "\n";
 }
+
+
+//----------------------------------------------------------------------------
+void
+cmExportFileGenerator
+::GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target,
+                                 ImportPropertyMap const& properties,
+                                const std::set<std::string>& importedLocations)
+{
+  // Construct the imported target name.
+  std::string targetName = this->Namespace;
+  targetName += target->GetName();
+
+  // Add code which verifies at cmake time that the file which is being
+  // imported actually exists on disk. This should in theory always be theory
+  // case, but still when packages are split into normal and development
+  // packages this might get broken (e.g. the Config.cmake could be part of
+  // the non-development package, something similar happened to me without
+  // on SUSE with a mysql pkg-config file, which claimed everything is fine,
+  // but the development package was not installed.).
+  for(std::set<std::string>::const_iterator li = importedLocations.begin();
+      li != importedLocations.end();
+      ++li)
+    {
+    ImportPropertyMap::const_iterator pi = properties.find(*li);
+    if (pi != properties.end())
+      {
+      std::string filename = pi->second;
+      os << "IF(NOT EXISTS \"" << filename << "\" )\n"
+            "  MESSAGE(FATAL_ERROR \"The file \\\"" << filename << "\\\" "
+            "for the imported target \\\"" << targetName <<"\\\" "
+            "does not exist.\n"
+            "There are multiple possible reasons:\n"
+            " * the file \\\"" << filename << "\\\" has been manually "
+            "deleted, renamed or moved to another location\n"
+            " * a previous install or uninstall procedure did not run "
+            " successfully to its end\n"
+            " * the installation package was faulty, and contained \\\""
+        << cmSystemTools::GetFilenameName(this->MainImportFile)
+        << "\\\", but not \\\" " << filename
+        << "\\\", which must always be installed together.\n"
+            "\")\n"
+            "ENDIF()"<< "\n\n";
+      }
+    }
+}
diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h
index 05f73a2..3b24911 100644
--- a/Source/cmExportFileGenerator.h
+++ b/Source/cmExportFileGenerator.h
@@ -56,6 +56,10 @@ protected:
   void GenerateImportPropertyCode(std::ostream& os, const char* config,
                                   cmTarget* target,
                                   ImportPropertyMap const& properties);
+  void GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target,
+                                      ImportPropertyMap const& properties,
+                               const std::set<std::string>& importedLocations);
+
 
   // Collect properties with detailed information about targets beyond
   // their location on disk.
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index 23ff5fb..6b8e228 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -167,16 +167,17 @@ cmExportInstallFileGenerator
     // Collect import properties for this target.
     cmTargetExport* te = *tei;
     ImportPropertyMap properties;
+    std::set<std::string> importedLocations;
+    this->SetImportLocationProperty(config, suffix, te->ArchiveGenerator,
+                                    properties, importedLocations);
+    this->SetImportLocationProperty(config, suffix, te->LibraryGenerator,
+                                    properties, importedLocations);
     this->SetImportLocationProperty(config, suffix,
-                                    te->ArchiveGenerator, properties);
-    this->SetImportLocationProperty(config, suffix,
-                                    te->LibraryGenerator, properties);
-    this->SetImportLocationProperty(config, suffix,
-                                    te->RuntimeGenerator, properties);
-    this->SetImportLocationProperty(config, suffix,
-                                    te->FrameworkGenerator, properties);
-    this->SetImportLocationProperty(config, suffix,
-                                    te->BundleGenerator, properties);
+                                    te->RuntimeGenerator, properties, importedLocations);
+    this->SetImportLocationProperty(config, suffix, te->FrameworkGenerator,
+                                    properties, importedLocations);
+    this->SetImportLocationProperty(config, suffix, te->BundleGenerator,
+                                    properties, importedLocations);
 
     // If any file location was set for the target add it to the
     // import file.
@@ -194,6 +195,8 @@ cmExportInstallFileGenerator
 
       // Generate code in the export file.
       this->GenerateImportPropertyCode(os, config, te->Target, properties);
+      this->GenerateImportedFileChecksCode(os, te->Target, properties,
+                                           importedLocations);
       }
     }
 
@@ -211,7 +214,9 @@ void
 cmExportInstallFileGenerator
 ::SetImportLocationProperty(const char* config, std::string const& suffix,
                             cmInstallTargetGenerator* itgen,
-                            ImportPropertyMap& properties)
+                            ImportPropertyMap& properties,
+                            std::set<std::string>& importedLocations
+                           )
 {
   // Skip rules that do not match this configuration.
   if(!(itgen && itgen->InstallsForConfig(config)))
@@ -249,6 +254,7 @@ cmExportInstallFileGenerator
 
     // Store the property.
     properties[prop] = value;
+    importedLocations.insert(prop);
     }
   else
     {
@@ -291,6 +297,7 @@ cmExportInstallFileGenerator
 
     // Store the property.
     properties[prop] = value;
+    importedLocations.insert(prop);
     }
 }
 
diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h
index 8c8fb44..fb678e8 100644
--- a/Source/cmExportInstallFileGenerator.h
+++ b/Source/cmExportInstallFileGenerator.h
@@ -75,7 +75,9 @@ protected:
   void SetImportLocationProperty(const char* config,
                                  std::string const& suffix,
                                  cmInstallTargetGenerator* itgen,
-                                 ImportPropertyMap& properties);
+                                 ImportPropertyMap& properties,
+                                 std::set<std::string>& importedLocations
+                                );
 
   void ComplainAboutImportPrefix(cmInstallTargetGenerator* itgen);
 

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

Summary of changes:
 Source/cmExportBuildFileGenerator.cxx   |   13 +++++-
 Source/cmExportBuildFileGenerator.h     |    3 +-
 Source/cmExportFileGenerator.cxx        |   64 +++++++++++++++++++++++++++++++
 Source/cmExportFileGenerator.h          |    5 ++
 Source/cmExportInstallFileGenerator.cxx |   29 +++++++++-----
 Source/cmExportInstallFileGenerator.h   |    4 +-
 6 files changed, 104 insertions(+), 14 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list