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

**URL:** https://discourse.cmake.org/t/issue-and-fixing-patch-cmake-tests-on-macos-with-m-chip/10144
**Category:** Development
**Created:** [February 21, 2024, 3:25am UTC](https://discourse.cmake.org/t/issue-and-fixing-patch-cmake-tests-on-macos-with-m-chip/10144 "2024-02-21T03:25:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Gaahfy](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/g/5fc32e/32.png) [@Gaahfy](https://discourse.cmake.org/u/Gaahfy)
#### Post date: [February 21, 2024, 3:25am UTC](https://discourse.cmake.org/t/issue-and-fixing-patch-cmake-tests-on-macos-with-m-chip/10144/1 "2024-02-21T03:25:22Z")

</div>

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:

```patch
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)

```

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [February 21, 2024, 1:57pm UTC](https://discourse.cmake.org/t/issue-and-fixing-patch-cmake-tests-on-macos-with-m-chip/10144/2 "2024-02-21T13:57:53Z")

</div>

@Gaahfy thanks. Please try [CMake MR 9277](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9277).

---

<div class="post-metadata">

### Author: ![Gaahfy](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/g/5fc32e/32.png) [@Gaahfy](https://discourse.cmake.org/u/Gaahfy)
#### Post date: [February 21, 2024, 2:40pm UTC](https://discourse.cmake.org/t/issue-and-fixing-patch-cmake-tests-on-macos-with-m-chip/10144/3 "2024-02-21T14:40:08Z")

</div>

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
