mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-17 15:32:10 +08:00
INSTALL_NAME_DIR: Add support for generator expressions
This commit is contained in:
@@ -517,13 +517,14 @@ void cmExportInstallFileGenerator::ComplainAboutMissingTarget(
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string cmExportInstallFileGenerator::InstallNameDir(
|
std::string cmExportInstallFileGenerator::InstallNameDir(
|
||||||
cmGeneratorTarget* target, const std::string& /*config*/)
|
cmGeneratorTarget* target, const std::string& config)
|
||||||
{
|
{
|
||||||
std::string install_name_dir;
|
std::string install_name_dir;
|
||||||
|
|
||||||
cmMakefile* mf = target->Target->GetMakefile();
|
cmMakefile* mf = target->Target->GetMakefile();
|
||||||
if (mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
|
if (mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
|
||||||
install_name_dir = target->GetInstallNameDirForInstallTree();
|
install_name_dir =
|
||||||
|
target->GetInstallNameDirForInstallTree(config, "${_IMPORT_PREFIX}");
|
||||||
}
|
}
|
||||||
|
|
||||||
return install_name_dir;
|
return install_name_dir;
|
||||||
|
@@ -2125,7 +2125,9 @@ std::string cmGeneratorTarget::GetInstallNameDirForBuildTree(
|
|||||||
// If building directly for installation then the build tree install_name
|
// If building directly for installation then the build tree install_name
|
||||||
// is the same as the install tree.
|
// is the same as the install tree.
|
||||||
if (this->MacOSXUseInstallNameDir()) {
|
if (this->MacOSXUseInstallNameDir()) {
|
||||||
return this->GetInstallNameDirForInstallTree();
|
std::string installPrefix =
|
||||||
|
this->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
|
||||||
|
return this->GetInstallNameDirForInstallTree(config, installPrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use the build tree directory for the target.
|
// Use the build tree directory for the target.
|
||||||
@@ -2143,7 +2145,8 @@ std::string cmGeneratorTarget::GetInstallNameDirForBuildTree(
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const
|
std::string cmGeneratorTarget::GetInstallNameDirForInstallTree(
|
||||||
|
const std::string& config, const std::string& installPrefix) const
|
||||||
{
|
{
|
||||||
if (this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
|
if (this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
|
||||||
std::string dir;
|
std::string dir;
|
||||||
@@ -2151,7 +2154,13 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const
|
|||||||
|
|
||||||
if (this->CanGenerateInstallNameDir(INSTALL_NAME_FOR_INSTALL)) {
|
if (this->CanGenerateInstallNameDir(INSTALL_NAME_FOR_INSTALL)) {
|
||||||
if (install_name_dir && *install_name_dir) {
|
if (install_name_dir && *install_name_dir) {
|
||||||
dir = cmStrCat(install_name_dir, '/');
|
dir = install_name_dir;
|
||||||
|
cmGeneratorExpression::ReplaceInstallPrefix(dir, installPrefix);
|
||||||
|
dir =
|
||||||
|
cmGeneratorExpression::Evaluate(dir, this->LocalGenerator, config);
|
||||||
|
if (!dir.empty()) {
|
||||||
|
dir = cmStrCat(dir, '/');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!install_name_dir) {
|
if (!install_name_dir) {
|
||||||
|
@@ -276,7 +276,8 @@ public:
|
|||||||
|
|
||||||
/** Return the install name directory for the target in the
|
/** Return the install name directory for the target in the
|
||||||
* install tree. For example: "\@rpath/" or "\@loader_path/". */
|
* install tree. For example: "\@rpath/" or "\@loader_path/". */
|
||||||
std::string GetInstallNameDirForInstallTree() const;
|
std::string GetInstallNameDirForInstallTree(
|
||||||
|
const std::string& config, const std::string& installPrefix) const;
|
||||||
|
|
||||||
cmListFileBacktrace GetBacktrace() const;
|
cmListFileBacktrace GetBacktrace() const;
|
||||||
|
|
||||||
|
@@ -554,7 +554,8 @@ void cmInstallTargetGenerator::AddInstallNamePatchRule(
|
|||||||
// components of the install_name field then we need to create a
|
// components of the install_name field then we need to create a
|
||||||
// mapping to be applied after installation.
|
// mapping to be applied after installation.
|
||||||
std::string for_build = tgt->GetInstallNameDirForBuildTree(config);
|
std::string for_build = tgt->GetInstallNameDirForBuildTree(config);
|
||||||
std::string for_install = tgt->GetInstallNameDirForInstallTree();
|
std::string for_install = tgt->GetInstallNameDirForInstallTree(
|
||||||
|
config, "${CMAKE_INSTALL_PREFIX}");
|
||||||
if (for_build != for_install) {
|
if (for_build != for_install) {
|
||||||
// The directory portions differ. Append the filename to
|
// The directory portions differ. Append the filename to
|
||||||
// create the mapping.
|
// create the mapping.
|
||||||
@@ -577,7 +578,8 @@ void cmInstallTargetGenerator::AddInstallNamePatchRule(
|
|||||||
if (this->Target->GetType() == cmStateEnums::SHARED_LIBRARY) {
|
if (this->Target->GetType() == cmStateEnums::SHARED_LIBRARY) {
|
||||||
std::string for_build =
|
std::string for_build =
|
||||||
this->Target->GetInstallNameDirForBuildTree(config);
|
this->Target->GetInstallNameDirForBuildTree(config);
|
||||||
std::string for_install = this->Target->GetInstallNameDirForInstallTree();
|
std::string for_install = this->Target->GetInstallNameDirForInstallTree(
|
||||||
|
config, "${CMAKE_INSTALL_PREFIX}");
|
||||||
|
|
||||||
if (this->Target->IsFrameworkOnApple() && for_install.empty()) {
|
if (this->Target->IsFrameworkOnApple() && for_install.empty()) {
|
||||||
// Frameworks seem to have an id corresponding to their own full
|
// Frameworks seem to have an id corresponding to their own full
|
||||||
|
Reference in New Issue
Block a user