# CMake 3.30 doesn't let me use $(ARCHS\_STANDARD) to set CMAKE\_OSX\_ARCHITECTURES

**URL:** https://discourse.cmake.org/t/cmake-3-30-doesnt-let-me-use-archs-standard-to-set-cmake-osx-architectures/11209
**Category:** Code
**Tags:** os:macos, gen:xcode
**Created:** [July 10, 2024, 9:29am UTC](https://discourse.cmake.org/t/cmake-3-30-doesnt-let-me-use-archs-standard-to-set-cmake-osx-architectures/11209 "2024-07-10T09:29:07Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Sidelobe](https://discourse.cmake.org/user_avatar/discourse.cmake.org/sidelobe/32/4744_2.png) [@Sidelobe](https://discourse.cmake.org/u/Sidelobe)
#### Post date: [July 10, 2024, 9:29am UTC](https://discourse.cmake.org/t/cmake-3-30-doesnt-let-me-use-archs-standard-to-set-cmake-osx-architectures/11209/1 "2024-07-10T09:29:07Z")

</div>

Cmake 3.30 seems to have broken my projects that build universal binaries (arm64;x86\_64)

I use this to create universal binaries when building via Xcode:

```cmake
if(CMAKE_GENERATOR STREQUAL "Xcode")
   set(CMAKE_OSX_ARCHITECTURES $(ARCHS_STANDARD) CACHE STRING "") 
endif()

```

Until Cmake 3.29.6 this still worked fine. I’m using Xcode 15.1.  
Now it seems the `$(ARCHS_STANDARD)` (which is resolved by Xcode) can no longer be used because of some “consistency check” that probably happens before this variable is resolved.

This is the commit that causes a FATAL\_ERROR

> <https://github.com/Kitware/CMake/commit/db409e5e681e75a322ee11c7bb0ad8d2be90cf5e>
>
> Not all compilers that can be used on APPLE platforms will respect
> the architect…ure(s) set in CMAKE\_OSX\_ARCHITECTURES and some will
> not raise an error if they are unable to do this. For instance,
> GCC will accept ignore additional architectures specified after the
> first -arch XXX (with a non-fatal warning) and will even link the
> simple test applications used in the ABI determination (and other
> tests that don't require external libraries) if an architecture
> is requested for which it doesn't have the required "multilib"
> set-up.
> 
> Prevent unexpected build results or build failures that may occur
> after a lengthy build process: verify that the binary used to obtain
> the ABI information contains the requested architectures.
> 
> Fixes: #25952

```auto
  The C compiler targets architectures:

    "x86_64;arm64"

  but CMAKE_OSX_ARCHITECTURES is

    "$(ARCHS_STANDARD)"

```

Is this a newly-introduced Cmake bug? Or is my way of using `$(ARCHS_STANDARD)` not proper or supported anymore?

If I set it explicitly to `set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "")`, everything works as expected.

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [July 10, 2024, 9:52am UTC](https://discourse.cmake.org/t/cmake-3-30-doesnt-let-me-use-archs-standard-to-set-cmake-osx-architectures/11209/2 "2024-07-10T09:52:25Z")

</div>

do you want to use an environment value?

```cmake
if(CMAKE_GENERATOR STREQUAL "Xcode")
   set(CMAKE_OSX_ARCHITECTURES $ENV{ARCHS_STANDARD} CACHE STRING "") 
endif()

```

---

<div class="post-metadata">

### Author: ![Sidelobe](https://discourse.cmake.org/user_avatar/discourse.cmake.org/sidelobe/32/4744_2.png) [@Sidelobe](https://discourse.cmake.org/u/Sidelobe)
#### Post date: [July 10, 2024, 10:12am UTC](https://discourse.cmake.org/t/cmake-3-30-doesnt-let-me-use-archs-standard-to-set-cmake-osx-architectures/11209/3 "2024-07-10T10:12:20Z")

</div>

`ARCHS_STANDARD` is not defined as an environment variable (?)

Or did you mean manually defining an env variable ARCHS\_STANDARD and assigning it " `"x86_64;arm64"`?

I thought about running `xcodebuild -showBuildSettings | grep ARCHS_STANDARD` from within Cmake, but this requires an existing Xcode project.

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [July 10, 2024, 4:33pm UTC](https://discourse.cmake.org/t/cmake-3-30-doesnt-let-me-use-archs-standard-to-set-cmake-osx-architectures/11209/4 "2024-07-10T16:33:11Z")

</div>

> [@Sidelobe](#):
>
> `ARCHS_STANDARD`

It seems to me that Xcode expect an environment var?  
see [TN3117: Resolving architecture build errors on Apple silicon | Apple Developer Documentation](https://developer.apple.com/documentation/technotes/tn3117-resolving-build-errors-for-apple-silicon)

---

<div class="post-metadata">

### Author: ![Sidelobe](https://discourse.cmake.org/user_avatar/discourse.cmake.org/sidelobe/32/4744_2.png) [@Sidelobe](https://discourse.cmake.org/u/Sidelobe)
#### Post date: [July 10, 2024, 7:15pm UTC](https://discourse.cmake.org/t/cmake-3-30-doesnt-let-me-use-archs-standard-to-set-cmake-osx-architectures/11209/5 "2024-07-10T19:15:33Z")

</div>

I’m not following you…

`$(ARCHS_STANDARD)` is a variable _defined by Xcode_, not an enviroment variable.

with this `set(CMAKE_OSX_ARCHITECTURES $(ARCHS_STANDARD) CACHE STRING "")` I’m assigning the literal string `$(ARCHS_STANDARD)` to `CMAKE_OSX_ARCHITECTURES`. Xcode will later resolve `$(ARCHS_STANDARD)` to e.g. “arm64 x86\_64”

That is not the problem – CMakeCache.txt shows the correct entry:  
`CMAKE_OSX_ARCHITECTURES:STRING=$(ARCHS_STANDARD)`

The problem is that, since Cmake 3.30, Cmake will abort because of some ‘consistency check’ because it cannot resolve $(ARCHS\_STANDARD) (which is obvious).

This is the ‘breaking change’: [APPLE: Check if compilers respect CMAKE\_OSX\_ARCHITECTURES · Kitware/CMake@db409e5 · GitHub](https://github.com/Kitware/CMake/commit/db409e5e681e75a322ee11c7bb0ad8d2be90cf5e)

If you are suggesting “pre-resolving” $(ARCHS\_STANDARD) e.g. with `xcodebuild -showBuildSettings | grep ARCHS_STANDARD` and saving it an environment variable and then using that within Cmake – yes, that would work, I guess.  
But I don’t get why this should be necessary - the “literal string” method has worked with Cmake for years (decades).

---

<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: [July 10, 2024, 10:21pm UTC](https://discourse.cmake.org/t/cmake-3-30-doesnt-let-me-use-archs-standard-to-set-cmake-osx-architectures/11209/6 "2024-07-10T22:21:46Z")

</div>

This sounds like a regression. Could you please file a bug report in the issue tracker here:

[https://gitlab.kitware.com/cmake/cmake/-/issues/new](https://gitlab.kitware.com/cmake/cmake/-/issues/new)

---

<div class="post-metadata">

### Author: ![Sidelobe](https://discourse.cmake.org/user_avatar/discourse.cmake.org/sidelobe/32/4744_2.png) [@Sidelobe](https://discourse.cmake.org/u/Sidelobe)
#### Post date: [July 11, 2024, 9:00am UTC](https://discourse.cmake.org/t/cmake-3-30-doesnt-let-me-use-archs-standard-to-set-cmake-osx-architectures/11209/7 "2024-07-11T09:00:22Z")

</div>

Thanks for confirming, Craig Scott

I’ve created an issue:  
[https://gitlab.kitware.com/cmake/cmake/-/issues/26128](https://gitlab.kitware.com/cmake/cmake/-/issues/26128)
