# macOS: cmake detect system processor incorrectly on Apple Silicon?

**URL:** https://discourse.cmake.org/t/macos-cmake-detect-system-processor-incorrectly-on-apple-silicon/5129
**Category:** Usage
**Created:** [February 28, 2022, 1:26pm UTC](https://discourse.cmake.org/t/macos-cmake-detect-system-processor-incorrectly-on-apple-silicon/5129 "2022-02-28T13:26:36Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Cham\_Su](https://discourse.cmake.org/user_avatar/discourse.cmake.org/cham_su/32/2231_2.png) [@Cham\_Su](https://discourse.cmake.org/u/Cham_Su)
#### Post date: [February 28, 2022, 1:26pm UTC](https://discourse.cmake.org/t/macos-cmake-detect-system-processor-incorrectly-on-apple-silicon/5129/1 "2022-02-28T13:26:36Z")

</div>

When I use cmake(3.22 or 3.23), the CMAKE\_SYSTEM\_PROCESSOR equal “x86\_64” with Mac 1M silicon, while the expected value is “arm64”.  
I don’t know whether there are bugs or my environments errors.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [February 28, 2022, 5:14pm UTC](https://discourse.cmake.org/t/macos-cmake-detect-system-processor-incorrectly-on-apple-silicon/5129/2 "2022-02-28T17:14:58Z")

</div>

How did you get the CMake you are using? If you are using a CMake compiled only as x86\_64, the arm64-ness of the processor is hidden behind Rosetta2 and not accessible.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [February 28, 2022, 9:27pm UTC](https://discourse.cmake.org/t/macos-cmake-detect-system-processor-incorrectly-on-apple-silicon/5129/3 "2022-02-28T21:27:08Z")

</div>

I think there is a way for a x86\_64 process to tell what the underlying processor is even when running under Rosetta. I seem to recall past discussions about this and CMake might even be using it in some places. @brad.king might recall where this is used or was discussed.

---

<div class="post-metadata">

### Author: ![Cham\_Su](https://discourse.cmake.org/user_avatar/discourse.cmake.org/cham_su/32/2231_2.png) [@Cham\_Su](https://discourse.cmake.org/u/Cham_Su)
#### Post date: [March 1, 2022, 2:09am UTC](https://discourse.cmake.org/t/macos-cmake-detect-system-processor-incorrectly-on-apple-silicon/5129/4 "2022-03-01T02:09:50Z")

</div>

I install the cmake from homebrew.  
The issue found when I build OpenCV from source code.  
And I found the CMAKE\_SYSTEM\_PROCESSOR=“x86\_64” after the function `enable_language(CXX C)` done.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [March 1, 2022, 1:19pm UTC](https://discourse.cmake.org/t/macos-cmake-detect-system-processor-incorrectly-on-apple-silicon/5129/5 "2022-03-01T13:19:19Z")

</div>

> [@craig.scott](#):
>
> I think there is a way for a x86\_64 process to tell what the underlying processor is even when running under Rosetta.

Yes, but when executing a process, you’ll get the `x86_64` version, so it will be “cross compiling” as far as any tooling is concerned. It’s just easier to get a multi-arch CMake instead.

---

<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: [March 1, 2022, 2:12pm UTC](https://discourse.cmake.org/t/macos-cmake-detect-system-processor-incorrectly-on-apple-silicon/5129/6 "2022-03-01T14:12:29Z")

</div>

See the [CMAKE\_APPLE\_SILICON\_PROCESSOR](https://cmake.org/cmake/help/v3.23/variable/CMAKE_APPLE_SILICON_PROCESSOR.html) option, added by [CMake MR 5589](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5589).

For reference, the implementation is [here](https://gitlab.kitware.com/cmake/cmake/-/blob/v3.22.2/Modules/CMakeDetermineSystem.cmake#L50-84). It uses `sysctl -q hw.optional.arm64` to pierce Rosetta, but only to verify that it’s actually running on an `arm64` host, where `CMAKE_APPLE_SILICON_PROCESSOR` is documented to be meaningful.

As Ben said, the defaults are more reliable when one uses the official CMake binaries for macOS on `cmake.org`, which are universal binaries supporting `arm64` and `x86_64` hosts.
