mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-09 23:59:53 -05:00
Apple Framework: enhance path parsing
This commit is contained in:
@@ -59,8 +59,6 @@
|
||||
namespace {
|
||||
using LinkInterfaceFor = cmGeneratorTarget::LinkInterfaceFor;
|
||||
|
||||
const cmsys::RegularExpression FrameworkRegularExpression(
|
||||
"^(.*/)?([^/]*)\\.framework/(.*)$");
|
||||
const std::string kINTERFACE_LINK_LIBRARIES = "INTERFACE_LINK_LIBRARIES";
|
||||
const std::string kINTERFACE_LINK_LIBRARIES_DIRECT =
|
||||
"INTERFACE_LINK_LIBRARIES_DIRECT";
|
||||
@@ -2434,11 +2432,10 @@ std::string cmGeneratorTarget::GetSOName(
|
||||
}
|
||||
// Use the soname given if any.
|
||||
if (this->IsFrameworkOnApple()) {
|
||||
cmsys::RegularExpressionMatch match;
|
||||
if (FrameworkRegularExpression.find(info->SOName.c_str(), match)) {
|
||||
auto frameworkName = match.match(2);
|
||||
auto fileName = match.match(3);
|
||||
return cmStrCat(frameworkName, ".framework/", fileName);
|
||||
auto fwDescriptor = this->GetGlobalGenerator()->SplitFrameworkPath(
|
||||
info->SOName, cmGlobalGenerator::FrameworkFormat::Strict);
|
||||
if (fwDescriptor) {
|
||||
return fwDescriptor->GetVersionedName();
|
||||
}
|
||||
}
|
||||
if (cmHasLiteralPrefix(info->SOName, "@rpath/")) {
|
||||
@@ -7036,13 +7033,10 @@ std::string cmGeneratorTarget::GetDirectory(
|
||||
if (this->IsImported()) {
|
||||
auto fullPath = this->Target->ImportedGetFullPath(config, artifact);
|
||||
if (this->IsFrameworkOnApple()) {
|
||||
cmsys::RegularExpressionMatch match;
|
||||
if (FrameworkRegularExpression.find(fullPath.c_str(), match)) {
|
||||
auto path = match.match(1);
|
||||
if (!path.empty()) {
|
||||
path.erase(path.length() - 1);
|
||||
}
|
||||
return path;
|
||||
auto fwDescriptor = this->GetGlobalGenerator()->SplitFrameworkPath(
|
||||
fullPath, cmGlobalGenerator::FrameworkFormat::Strict);
|
||||
if (fwDescriptor) {
|
||||
return fwDescriptor->Directory;
|
||||
}
|
||||
}
|
||||
// Return the directory from which the target is imported.
|
||||
|
||||
@@ -2598,14 +2598,14 @@ cmGlobalGenerator::SplitFrameworkPath(const std::string& path,
|
||||
// or (/path/to/)?FwName.framework/FwName(.tbd)?
|
||||
// or (/path/to/)?FwName.framework/Versions/*/FwName(.tbd)?
|
||||
static cmsys::RegularExpression frameworkPath(
|
||||
"((.+)/)?(.+)\\.framework(/Versions/[^/]+)?(/(.+))?$");
|
||||
"((.+)/)?([^/]+)\\.framework(/Versions/([^/]+))?(/(.+))?$");
|
||||
|
||||
auto ext = cmSystemTools::GetFilenameLastExtension(path);
|
||||
if ((ext.empty() || ext == ".tbd" || ext == ".framework") &&
|
||||
frameworkPath.find(path)) {
|
||||
auto name = frameworkPath.match(3);
|
||||
auto libname =
|
||||
cmSystemTools::GetFilenameWithoutExtension(frameworkPath.match(6));
|
||||
cmSystemTools::GetFilenameWithoutExtension(frameworkPath.match(7));
|
||||
if (format == FrameworkFormat::Strict && libname.empty()) {
|
||||
return cm::nullopt;
|
||||
}
|
||||
@@ -2614,11 +2614,12 @@ cmGlobalGenerator::SplitFrameworkPath(const std::string& path,
|
||||
}
|
||||
|
||||
if (libname.empty() || name.size() == libname.size()) {
|
||||
return FrameworkDescriptor{ frameworkPath.match(2), name };
|
||||
return FrameworkDescriptor{ frameworkPath.match(2),
|
||||
frameworkPath.match(5), name };
|
||||
}
|
||||
|
||||
return FrameworkDescriptor{ frameworkPath.match(2), name,
|
||||
libname.substr(name.size()) };
|
||||
return FrameworkDescriptor{ frameworkPath.match(2), frameworkPath.match(5),
|
||||
name, libname.substr(name.size()) };
|
||||
}
|
||||
|
||||
if (format == FrameworkFormat::Extended) {
|
||||
|
||||
@@ -384,9 +384,17 @@ public:
|
||||
, Name(std::move(name))
|
||||
{
|
||||
}
|
||||
FrameworkDescriptor(std::string directory, std::string name,
|
||||
std::string suffix)
|
||||
FrameworkDescriptor(std::string directory, std::string version,
|
||||
std::string name)
|
||||
: Directory(std::move(directory))
|
||||
, Version(std::move(version))
|
||||
, Name(std::move(name))
|
||||
{
|
||||
}
|
||||
FrameworkDescriptor(std::string directory, std::string version,
|
||||
std::string name, std::string suffix)
|
||||
: Directory(std::move(directory))
|
||||
, Version(std::move(version))
|
||||
, Name(std::move(name))
|
||||
, Suffix(std::move(suffix))
|
||||
{
|
||||
@@ -400,6 +408,13 @@ public:
|
||||
{
|
||||
return cmStrCat(this->Name, ".framework/"_s, this->Name, this->Suffix);
|
||||
}
|
||||
std::string GetVersionedName() const
|
||||
{
|
||||
return this->Version.empty()
|
||||
? this->GetFullName()
|
||||
: cmStrCat(this->Name, ".framework/Versions/"_s, this->Version, '/',
|
||||
this->Name, this->Suffix);
|
||||
}
|
||||
std::string GetFrameworkPath() const
|
||||
{
|
||||
return this->Directory.empty()
|
||||
@@ -412,8 +427,15 @@ public:
|
||||
? this->GetFullName()
|
||||
: cmStrCat(this->Directory, '/', this->GetFullName());
|
||||
}
|
||||
std::string GetVersionedPath() const
|
||||
{
|
||||
return this->Directory.empty()
|
||||
? this->GetVersionedName()
|
||||
: cmStrCat(this->Directory, '/', this->GetVersionedName());
|
||||
}
|
||||
|
||||
const std::string Directory;
|
||||
const std::string Version;
|
||||
const std::string Name;
|
||||
const std::string Suffix;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user