Issue and Fixing Patch - CMake tests on macOS with M chip

The make test command fails on macOS with M chip, because of the test BuildDepends failing.

In order to reproduce the issue, you need to make sure Rosetta is not installed on your machine. Otherwise the test will succeed.

The reason behind this fail is because the binary is not compiled for arm architecture. The following patch works on Apple with M chip, but I’m not sure about the minimum required version of XCode for that, neither if this would work on mac computers with Intel chips:

diff -ruN a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt
--- a/Tests/BuildDepends/Project/CMakeLists.txt
+++ b/Tests/BuildDepends/Project/CMakeLists.txt
@@ -19,7 +19,7 @@
   if(EXISTS "${CMAKE_OSX_SYSROOT}" AND NOT "${CMAKE_GENERATOR}" MATCHES "Ninja")
     if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 10)
       # Arch 'i386' no longer works in Xcode 10.
-      set(CMAKE_OSX_ARCHITECTURES x86_64)
+      set(CMAKE_OSX_ARCHITECTURES x86_64 arm64)
     elseif(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 4)
       # Arch 'ppc' no longer works in Xcode 4.
       set(CMAKE_OSX_ARCHITECTURES i386 x86_64)

@Gaahfy thanks. Please try CMake MR 9277.

Thanks a lot @brad.king for the Merge request

Works well on macOS Sonoma 14.3.1 Macbook Pro M2 with XCode 15.2 (15C500b) - Rosetta not installed

1 Like