diff options
author | Brad King <brad.king@kitware.com> | 2023-03-15 14:20:27 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-03-15 14:50:26 (GMT) |
commit | 98e319a88f0be4fdc5d374cdf5a3d5c0e295699d (patch) | |
tree | f11356225de33b5bf02abc201dec43703b1b6652 /Source | |
parent | 43e973eba2681788c7acf7a4fcdf261bcf6a622a (diff) | |
download | CMake-98e319a88f0be4fdc5d374cdf5a3d5c0e295699d.zip CMake-98e319a88f0be4fdc5d374cdf5a3d5c0e295699d.tar.gz CMake-98e319a88f0be4fdc5d374cdf5a3d5c0e295699d.tar.bz2 |
macOS: Suppress default '-arch arm64' with CMAKE_<LANG>_COMPILER_TARGET
Since commit b6c60f14b6 (macOS: Default to arm64 architecture on Apple
Silicon hosts, 2020-09-28, v3.19.0-rc1~63^2) we add `-arch arm64` by
default on Apple Silicon hosts if `CMAKE_OSX_ARCHITECTURES` is not set.
This is necessary to prevent the toolchain from selecting its own
default architecture based on that of the build tool (e.g., `x86_64`).
If `CMAKE_<LANG>_COMPILER_TARGET` is set, its `-target` flag tells the
compiler what architecture to use, so do not add `-arch arm64`.
Fixes: #24599
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 0b376c1..8a14eaf 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3451,7 +3451,6 @@ std::string cmGeneratorTarget::GetCompilePDBDirectory( std::vector<std::string> cmGeneratorTarget::GetAppleArchs( std::string const& config, cm::optional<std::string> lang) const { - static_cast<void>(lang); std::vector<std::string> archVec; if (!this->IsApple()) { return archVec; @@ -3468,7 +3467,12 @@ std::vector<std::string> cmGeneratorTarget::GetAppleArchs( if (archs) { cmExpandList(*archs, archVec); } - if (archVec.empty()) { + if (archVec.empty() && + // Fall back to a default architecture if no compiler target is set. + (!lang || + this->Makefile + ->GetDefinition(cmStrCat("CMAKE_", *lang, "_COMPILER_TARGET")) + .IsEmpty())) { this->Makefile->GetDefExpandList("_CMAKE_APPLE_ARCHS_DEFAULT", archVec); } return archVec; |