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

Also expand the IMPORTED_SONAME property for targets
to match the install_name.
This commit is contained in:
Clinton Stimpson 2013-05-20 16:57:58 -06:00 committed by Brad King
parent 00d71bdd19
commit 8576b3f978
9 changed files with 65 additions and 1 deletions

View File

@ -211,3 +211,19 @@ cmExportBuildFileGenerator
<< "consider using the APPEND option with multiple separate calls."; << "consider using the APPEND option with multiple separate calls.";
this->ExportCommand->ErrorMessage = e.str(); 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;
}

View File

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

View File

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

View File

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

View File

@ -490,3 +490,19 @@ cmExportInstallFileGenerator
} }
cmSystemTools::Error(e.str().c_str()); 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;
}

View File

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

View File

@ -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;
}

View File

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

View File

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