Browse Source

OS X: Add support for @rpath in export files.

Also expand the IMPORTED_SONAME property for targets
to match the install_name.
Clinton Stimpson 12 years ago
parent
commit
8576b3f978

+ 16 - 0
Source/cmExportBuildFileGenerator.cxx

@@ -211,3 +211,19 @@ cmExportBuildFileGenerator
     << "consider using the APPEND option with multiple separate calls.";
   this->ExportCommand->ErrorMessage = e.str();
 }
+
+std::string
+cmExportBuildFileGenerator::InstallNameDir(cmTarget* target,
+                                           const std::string& config)
+{
+  std::string install_name_dir;
+
+  cmMakefile* mf = target->GetMakefile();
+  if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
+    {
+    install_name_dir =
+      target->GetInstallNameDirForBuildTree(config.c_str());
+    }
+
+  return install_name_dir;
+}

+ 2 - 0
Source/cmExportBuildFileGenerator.h

@@ -61,6 +61,8 @@ protected:
                                  cmTarget* target,
                                  ImportPropertyMap& properties);
 
+  std::string InstallNameDir(cmTarget* target, const std::string& config);
+
   std::vector<cmTarget*> const* Exports;
   cmExportCommand* ExportCommand;
 };

+ 5 - 1
Source/cmExportFileGenerator.cxx

@@ -624,8 +624,12 @@ cmExportFileGenerator
       std::string value;
       if(target->HasSOName(config))
         {
+        if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
+          {
+          value = this->InstallNameDir(target, config);
+          }
         prop = "IMPORTED_SONAME";
-        value = target->GetSOName(config);
+        value += target->GetSOName(config);
         }
       else
         {

+ 3 - 0
Source/cmExportFileGenerator.h

@@ -159,6 +159,9 @@ private:
                                     std::vector<std::string> &missingTargets);
 
   virtual void ReplaceInstallPrefix(std::string &input);
+
+  virtual std::string InstallNameDir(cmTarget* target,
+                                     const std::string& config) = 0;
 };
 
 #endif

+ 16 - 0
Source/cmExportInstallFileGenerator.cxx

@@ -490,3 +490,19 @@ cmExportInstallFileGenerator
     }
   cmSystemTools::Error(e.str().c_str());
 }
+
+std::string
+cmExportInstallFileGenerator::InstallNameDir(cmTarget* target,
+                                             const std::string&)
+{
+  std::string install_name_dir;
+
+  cmMakefile* mf = target->GetMakefile();
+  if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
+    {
+    install_name_dir =
+      target->GetInstallNameDirForInstallTree();
+    }
+
+  return install_name_dir;
+}

+ 2 - 0
Source/cmExportInstallFileGenerator.h

@@ -85,6 +85,8 @@ protected:
 
   void ComplainAboutImportPrefix(cmInstallTargetGenerator* itgen);
 
+  std::string InstallNameDir(cmTarget* target, const std::string& config);
+
   cmInstallExportGenerator* IEGen;
 
   std::string ImportPrefix;

+ 15 - 0
Source/cmExportTryCompileFileGenerator.cxx

@@ -112,3 +112,18 @@ cmExportTryCompileFileGenerator::PopulateProperties(cmTarget* target,
       }
     }
 }
+std::string
+cmExportTryCompileFileGenerator::InstallNameDir(cmTarget* target,
+                                                const std::string& config)
+{
+  std::string install_name_dir;
+
+  cmMakefile* mf = target->GetMakefile();
+  if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
+    {
+    install_name_dir =
+      target->GetInstallNameDirForBuildTree(config.c_str());
+    }
+
+  return install_name_dir;
+}

+ 2 - 0
Source/cmExportTryCompileFileGenerator.h

@@ -43,6 +43,8 @@ protected:
                           ImportPropertyMap& properties,
                           std::set<cmTarget*> &emitted);
 
+  std::string InstallNameDir(cmTarget* target,
+                             const std::string& config);
 private:
   std::string FindTargets(const char *prop, cmTarget *tgt,
                    std::set<cmTarget*> &emitted);

+ 4 - 0
Source/cmTarget.cxx

@@ -3782,6 +3782,10 @@ std::string cmTarget::GetSOName(const char* config)
       else
         {
         // Use the soname given if any.
+        if(info->SOName.find("@rpath/") == 0)
+          {
+          return info->SOName.substr(6);
+          }
         return info->SOName;
         }
       }