summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-02-09 16:37:11 (GMT)
committerBrad King <brad.king@kitware.com>2024-02-09 16:37:11 (GMT)
commit871a4c5aacce720c22dd5569f79c4dcb0ca3680a (patch)
tree69c2b0f66465e4a40ae472998eb13f07f03fd5bb /Source
parentc673511263822c688fa302120a29e1e0cf812c0b (diff)
parent22eb1b6d678f13506e9cfa92090d9ff9886f0c8c (diff)
downloadCMake-871a4c5aacce720c22dd5569f79c4dcb0ca3680a.zip
CMake-871a4c5aacce720c22dd5569f79c4dcb0ca3680a.tar.gz
CMake-871a4c5aacce720c22dd5569f79c4dcb0ca3680a.tar.bz2
Merge branch 'backport-3.28-visionOS' into visionOS
Diffstat (limited to 'Source')
-rw-r--r--Source/cmLocalGenerator.cxx51
1 files changed, 43 insertions, 8 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index e7fa717..0e539fe 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2011,14 +2011,49 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
cmValue deploymentTarget =
this->Makefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET");
- std::string deploymentTargetFlagVar =
- "CMAKE_" + lang + "_OSX_DEPLOYMENT_TARGET_FLAG";
- cmValue deploymentTargetFlag =
- this->Makefile->GetDefinition(deploymentTargetFlagVar);
- if (cmNonempty(deploymentTargetFlag) && cmNonempty(deploymentTarget)) {
- flags += " ";
- flags += *deploymentTargetFlag;
- flags += *deploymentTarget;
+ if (cmNonempty(deploymentTarget)) {
+ std::string deploymentTargetFlagVar =
+ "CMAKE_" + lang + "_OSX_DEPLOYMENT_TARGET_FLAG";
+ cmValue deploymentTargetFlag =
+ this->Makefile->GetDefinition(deploymentTargetFlagVar);
+ if (cmNonempty(deploymentTargetFlag) &&
+ // CMAKE_<LANG>_COMPILER_TARGET overrides a --target= for
+ // CMAKE_OSX_DEPLOYMENT_TARGET, e.g., for visionOS.
+ (!cmHasLiteralPrefix(*deploymentTarget, "--target=") ||
+ this->Makefile
+ ->GetDefinition(cmStrCat("CMAKE_", lang, "_COMPILER_TARGET"))
+ .IsEmpty())) {
+ std::string flag = *deploymentTargetFlag;
+
+ // Add the deployment target architecture to the flag, if needed.
+ static const std::string kARCH = "<ARCH>";
+ std::string::size_type archPos = flag.find(kARCH);
+ if (archPos != std::string::npos) {
+ // This placeholder is meant for visionOS, so default to arm64
+ // unless only non-arm64 archs are given.
+ std::string const arch =
+ (archs.empty() || cm::contains(archs, "arm64")) ? "arm64"
+ : archs[0];
+ // Replace the placeholder with its value.
+ flag = cmStrCat(flag.substr(0, archPos), arch,
+ flag.substr(archPos + kARCH.size()));
+ }
+
+ // Add the deployment target version to the flag.
+ static const std::string kVERSION_MIN = "<VERSION_MIN>";
+ std::string::size_type verPos = flag.find(kVERSION_MIN);
+ if (verPos != std::string::npos) {
+ // Replace the placeholder with its value.
+ flag = cmStrCat(flag.substr(0, verPos), *deploymentTarget,
+ flag.substr(verPos + kVERSION_MIN.size()));
+ } else {
+ // There is no placeholder, so append the value.
+ flag = cmStrCat(flag, *deploymentTarget);
+ }
+
+ flags += " ";
+ flags += flag;
+ }
}
}
}