summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-07-16 11:46:53 -0400
committerBrad King <brad.king@kitware.com>2020-07-20 10:03:15 -0400
commit26673bf48011a48fe0ad01e97409a32c1f50143d (patch)
tree38c4a14ec2adaa5ae451c1ce38afacbe0b1d7966 /Modules
parentce624cfbd4fcbf5c486850ac331fa1e1dba28f8b (diff)
downloadcmake-26673bf48011a48fe0ad01e97409a32c1f50143d.tar.gz
Xcode: Explicitly specify default native architecture on macOS
When `CMAKE_OSX_ARCHITECTURES` is not specified, we add the Xcode setting `ONLY_ACTIVE_ARCH = YES` with the intention of targeting the native architecture of the host. However, the default `ARCHS` value chosen by "Xcode 12 Universal Apps" includes multiple architectures. Add an explicit `ARCHS` setting with value `$(NATIVE_ARCH_ACTUAL)` to tell Xcode to use the host's native architecture only. Fixes: #20893
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake6
-rw-r--r--Modules/CompilerId/Xcode-3.pbxproj.in1
2 files changed, 7 insertions, 0 deletions
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index df48fa574f..44332a66a8 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -469,6 +469,12 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
set(id_clang_cxx_library "CLANG_CXX_LIBRARY = \"${CMAKE_MATCH_3}\";")
endif()
endif()
+ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_OSX_SYSROOT MATCHES "^$|[Mm][Aa][Cc][Oo][Ss]")
+ # When targeting macOS, use only the host architecture.
+ set(id_archs [[ARCHS = "$(NATIVE_ARCH_ACTUAL)";]])
+ else()
+ set(id_archs "")
+ endif()
configure_file(${CMAKE_ROOT}/Modules/CompilerId/Xcode-3.pbxproj.in
${id_dir}/CompilerId${lang}.xcodeproj/project.pbxproj @ONLY)
unset(_ENV_MACOSX_DEPLOYMENT_TARGET)
diff --git a/Modules/CompilerId/Xcode-3.pbxproj.in b/Modules/CompilerId/Xcode-3.pbxproj.in
index 672044e135..6fe17e541d 100644
--- a/Modules/CompilerId/Xcode-3.pbxproj.in
+++ b/Modules/CompilerId/Xcode-3.pbxproj.in
@@ -84,6 +84,7 @@
CODE_SIGNING_REQUIRED = NO;
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)";
SYMROOT = .;
+ @id_archs@
@id_toolset@
@id_lang_version@
@id_clang_cxx_library@