# How do I build cmake from source as universal(arm64 and x86\_64) binary on Mac?

**URL:** https://discourse.cmake.org/t/how-do-i-build-cmake-from-source-as-universal-arm64-and-x86-64-binary-on-mac/5862
**Category:** Usage
**Created:** [June 14, 2022, 8:45am UTC](https://discourse.cmake.org/t/how-do-i-build-cmake-from-source-as-universal-arm64-and-x86-64-binary-on-mac/5862 "2022-06-14T08:45:58Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Diuming](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/c68b51/32.png) [@Diuming](https://discourse.cmake.org/u/Diuming)
#### Post date: [June 14, 2022, 8:45am UTC](https://discourse.cmake.org/t/how-do-i-build-cmake-from-source-as-universal-arm64-and-x86-64-binary-on-mac/5862/1 "2022-06-14T08:45:58Z")

</div>

as title:

I try with CFLAGS and CXXFLAGS, but not successful.  
./configure CFLAGS="-mmacosx-version-min=11.0 -arch x86\_64 -arch arm64" CXXFLAGS="-mmacosx-version-min=11.0 -arch x86\_64 -arch arm64" --prefix=/some/place/cmake-3.23.2

thx

---

<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: [June 14, 2022, 11:17am UTC](https://discourse.cmake.org/t/how-do-i-build-cmake-from-source-as-universal-arm64-and-x86-64-binary-on-mac/5862/2 "2022-06-14T11:17:49Z")

</div>

You need to tell CMake what is going on `"-DCMAKE_OSX_ARCHITECTURES=x86_64;arm64"`. Just doing it as flags makes CMake unaware that multi-arch binaries are being made and confuses some things.

---

<div class="post-metadata">

### Author: ![Diuming](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/c68b51/32.png) [@Diuming](https://discourse.cmake.org/u/Diuming)
#### Post date: [June 14, 2022, 4:27pm UTC](https://discourse.cmake.org/t/how-do-i-build-cmake-from-source-as-universal-arm64-and-x86-64-binary-on-mac/5862/3 "2022-06-14T16:27:30Z")

</div>

@ben.boeckel thank you for reply.  
sorry! english is not my mother language and maybe my question is not clear.  
I want to ask,  
How do I build `cmake command` as universal binary from source(cmake source)?

thank you.

---

<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: [June 14, 2022, 10:30pm UTC](https://discourse.cmake.org/t/how-do-i-build-cmake-from-source-as-universal-arm64-and-x86-64-binary-on-mac/5862/4 "2022-06-14T22:30:58Z")

</div>

AFAIK, passing that `-D` in when configuring should be enough. You can also set `CMAKE_OSX_DEPLOYMENT_TARGET` to manage the `-mmacosx-version-min=` flag.

---

<div class="post-metadata">

### Author: ![Diuming](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/c68b51/32.png) [@Diuming](https://discourse.cmake.org/u/Diuming)
#### Post date: [June 14, 2022, 11:57pm UTC](https://discourse.cmake.org/t/how-do-i-build-cmake-from-source-as-universal-arm64-and-x86-64-binary-on-mac/5862/5 "2022-06-14T23:57:35Z")

</div>

@ben.boeckel thanks

I know so far have 2 ways(configure and bootstrap) to compile `cmake` from cmake source.

You mentioned `-DCMAKE_OSX_ARCHITECTURES=x86_64;arm64` option.

I also try `./bootstrap -- -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" --prefix=/some/place/cmake-3.23.2` but failed.

```auto
CMake Error: Unknown argument --prefix=/some/place/cmake-3.23.2

```

How do I apply it with configure and bootstrap?  
Could you give me an example?

thx

---

<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: [June 15, 2022, 1:00pm UTC](https://discourse.cmake.org/t/how-do-i-build-cmake-from-source-as-universal-arm64-and-x86-64-binary-on-mac/5862/6 "2022-06-15T13:00:21Z")

</div>

I would guess that `--prefix=` goes before the `--` for `bootstrap`.

---

<div class="post-metadata">

### Author: ![Diuming](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/c68b51/32.png) [@Diuming](https://discourse.cmake.org/u/Diuming)
#### Post date: [June 15, 2022, 3:41pm UTC](https://discourse.cmake.org/t/how-do-i-build-cmake-from-source-as-universal-arm64-and-x86-64-binary-on-mac/5862/7 "2022-06-15T15:41:26Z")

</div>

@ben.boeckel thanks  
It works.
