summaryrefslogtreecommitdiffstats
path: root/Source/cmInstallCommand.cxx
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2023-02-01 16:58:30 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2023-03-01 11:23:28 (GMT)
commitede33f30cfef9e03ecccdb9ce4c7fdf1e8208d75 (patch)
tree338052612b36c9394f6f0ad71bab57109cf60957 /Source/cmInstallCommand.cxx
parentfcbd723a5085c11c57ec966f8aea605a55d0bdd5 (diff)
downloadCMake-ede33f30cfef9e03ecccdb9ce4c7fdf1e8208d75.zip
CMake-ede33f30cfef9e03ecccdb9ce4c7fdf1e8208d75.tar.gz
CMake-ede33f30cfef9e03ecccdb9ce4c7fdf1e8208d75.tar.bz2
Apple: Handle generation and comsuption of text-based stubs (.tbd files)
Fixes: #24123
Diffstat (limited to 'Source/cmInstallCommand.cxx')
-rw-r--r--Source/cmInstallCommand.cxx73
1 files changed, 58 insertions, 15 deletions
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 56c8b26..40230d9 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -553,34 +553,35 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
// Enforce argument rules too complex to specify for the
// general-purpose parser.
- if (archiveArgs.GetNamelinkOnly() || runtimeArgs.GetNamelinkOnly() ||
- objectArgs.GetNamelinkOnly() || frameworkArgs.GetNamelinkOnly() ||
- bundleArgs.GetNamelinkOnly() || privateHeaderArgs.GetNamelinkOnly() ||
+ if (runtimeArgs.GetNamelinkOnly() || objectArgs.GetNamelinkOnly() ||
+ frameworkArgs.GetNamelinkOnly() || bundleArgs.GetNamelinkOnly() ||
+ privateHeaderArgs.GetNamelinkOnly() ||
publicHeaderArgs.GetNamelinkOnly() || resourceArgs.GetNamelinkOnly() ||
std::any_of(fileSetArgs.begin(), fileSetArgs.end(),
[](const cmInstallCommandFileSetArguments& fileSetArg)
-> bool { return fileSetArg.GetNamelinkOnly(); }) ||
cxxModuleBmiArgs.GetNamelinkOnly()) {
status.SetError(
- "TARGETS given NAMELINK_ONLY option not in LIBRARY group. "
- "The NAMELINK_ONLY option may be specified only following LIBRARY.");
+ "TARGETS given NAMELINK_ONLY option not in LIBRARY or ARCHIVE group. "
+ "The NAMELINK_ONLY option may be specified only following LIBRARY or "
+ "ARCHIVE.");
return false;
}
- if (archiveArgs.GetNamelinkSkip() || runtimeArgs.GetNamelinkSkip() ||
- objectArgs.GetNamelinkSkip() || frameworkArgs.GetNamelinkSkip() ||
- bundleArgs.GetNamelinkSkip() || privateHeaderArgs.GetNamelinkSkip() ||
+ if (runtimeArgs.GetNamelinkSkip() || objectArgs.GetNamelinkSkip() ||
+ frameworkArgs.GetNamelinkSkip() || bundleArgs.GetNamelinkSkip() ||
+ privateHeaderArgs.GetNamelinkSkip() ||
publicHeaderArgs.GetNamelinkSkip() || resourceArgs.GetNamelinkSkip() ||
std::any_of(fileSetArgs.begin(), fileSetArgs.end(),
[](const cmInstallCommandFileSetArguments& fileSetArg)
-> bool { return fileSetArg.GetNamelinkSkip(); }) ||
cxxModuleBmiArgs.GetNamelinkSkip()) {
status.SetError(
- "TARGETS given NAMELINK_SKIP option not in LIBRARY group. "
- "The NAMELINK_SKIP option may be specified only following LIBRARY.");
+ "TARGETS given NAMELINK_SKIP option not in LIBRARY or ARCHIVE group. "
+ "The NAMELINK_SKIP option may be specified only following LIBRARY or "
+ "ARCHIVE.");
return false;
}
- if (archiveArgs.HasNamelinkComponent() ||
- runtimeArgs.HasNamelinkComponent() ||
+ if (runtimeArgs.HasNamelinkComponent() ||
objectArgs.HasNamelinkComponent() ||
frameworkArgs.HasNamelinkComponent() ||
bundleArgs.HasNamelinkComponent() ||
@@ -592,9 +593,9 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
-> bool { return fileSetArg.HasNamelinkComponent(); }) ||
cxxModuleBmiArgs.HasNamelinkComponent()) {
status.SetError(
- "TARGETS given NAMELINK_COMPONENT option not in LIBRARY group. "
- "The NAMELINK_COMPONENT option may be specified only following "
- "LIBRARY.");
+ "TARGETS given NAMELINK_COMPONENT option not in LIBRARY or ARCHIVE "
+ "group. The NAMELINK_COMPONENT option may be specified only following "
+ "LIBRARY or ARCHIVE.");
return false;
}
if (libraryArgs.GetNamelinkOnly() && libraryArgs.GetNamelinkSkip()) {
@@ -674,6 +675,14 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
} else if (libraryArgs.GetNamelinkSkip()) {
namelinkMode = cmInstallTargetGenerator::NamelinkModeSkip;
}
+ // Select the mode for installing symlinks to versioned imported libraries.
+ cmInstallTargetGenerator::NamelinkModeType importlinkMode =
+ cmInstallTargetGenerator::NamelinkModeNone;
+ if (archiveArgs.GetNamelinkOnly()) {
+ importlinkMode = cmInstallTargetGenerator::NamelinkModeOnly;
+ } else if (archiveArgs.GetNamelinkSkip()) {
+ importlinkMode = cmInstallTargetGenerator::NamelinkModeSkip;
+ }
// Check if there is something to do.
if (targetList.empty()) {
@@ -725,6 +734,7 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
bool installsArchive = false;
bool installsLibrary = false;
bool installsNamelink = false;
+ bool installsImportlink = false;
bool installsRuntime = false;
bool installsObject = false;
bool installsFramework = false;
@@ -742,6 +752,7 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
std::unique_ptr<cmInstallTargetGenerator> archiveGenerator;
std::unique_ptr<cmInstallTargetGenerator> libraryGenerator;
std::unique_ptr<cmInstallTargetGenerator> namelinkGenerator;
+ std::unique_ptr<cmInstallTargetGenerator> importlinkGenerator;
std::unique_ptr<cmInstallTargetGenerator> runtimeGenerator;
std::unique_ptr<cmInstallTargetGenerator> objectGenerator;
std::unique_ptr<cmInstallTargetGenerator> frameworkGenerator;
@@ -885,6 +896,32 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
}
namelinkOnly =
(namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly);
+
+ if (target.GetMakefile()->PlatformSupportsAppleTextStubs() &&
+ target.IsSharedLibraryWithExports()) {
+ // Apple .tbd files use the ARCHIVE properties
+ if (!archiveArgs.GetDestination().empty()) {
+ artifactsSpecified = true;
+ }
+ if (importlinkMode !=
+ cmInstallTargetGenerator::NamelinkModeOnly) {
+ archiveGenerator = CreateInstallTargetGenerator(
+ target, archiveArgs, true, helper.Makefile->GetBacktrace(),
+ helper.GetLibraryDestination(&archiveArgs));
+ archiveGenerator->SetImportlinkMode(
+ cmInstallTargetGenerator::NamelinkModeSkip);
+ }
+ if (importlinkMode !=
+ cmInstallTargetGenerator::NamelinkModeSkip) {
+ importlinkGenerator = CreateInstallTargetGenerator(
+ target, archiveArgs, true, helper.Makefile->GetBacktrace(),
+ helper.GetLibraryDestination(&archiveArgs), false, true);
+ importlinkGenerator->SetImportlinkMode(
+ cmInstallTargetGenerator::NamelinkModeOnly);
+ }
+ namelinkOnly =
+ (importlinkMode == cmInstallTargetGenerator::NamelinkModeOnly);
+ }
}
if (runtimeDependencySet && libraryGenerator) {
runtimeDependencySet->AddLibrary(libraryGenerator.get());
@@ -1157,6 +1194,7 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
installsArchive = installsArchive || archiveGenerator;
installsLibrary = installsLibrary || libraryGenerator;
installsNamelink = installsNamelink || namelinkGenerator;
+ installsImportlink = installsImportlink || importlinkGenerator;
installsRuntime = installsRuntime || runtimeGenerator;
installsObject = installsObject || objectGenerator;
installsFramework = installsFramework || frameworkGenerator;
@@ -1169,6 +1207,7 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
helper.Makefile->AddInstallGenerator(std::move(archiveGenerator));
helper.Makefile->AddInstallGenerator(std::move(libraryGenerator));
helper.Makefile->AddInstallGenerator(std::move(namelinkGenerator));
+ helper.Makefile->AddInstallGenerator(std::move(importlinkGenerator));
helper.Makefile->AddInstallGenerator(std::move(runtimeGenerator));
helper.Makefile->AddInstallGenerator(std::move(objectGenerator));
helper.Makefile->AddInstallGenerator(std::move(frameworkGenerator));
@@ -1203,6 +1242,10 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
helper.Makefile->GetGlobalGenerator()->AddInstallComponent(
libraryArgs.GetNamelinkComponent());
}
+ if (installsImportlink) {
+ helper.Makefile->GetGlobalGenerator()->AddInstallComponent(
+ archiveArgs.GetNamelinkComponent());
+ }
if (installsRuntime) {
helper.Makefile->GetGlobalGenerator()->AddInstallComponent(
runtimeArgs.GetComponent());