Search code examples
xcodemacoscmakeapple-siliconcmake-generators

Cmake 3.30 seems to break use of $(ARCHS_STANDARD) for Xcode Generator


In all my Cmake builds on macos devices, I've been using $(ARCHS_STANDARD) to configure the build to a 'fat library' or universal binary.

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

Since I updated to Cmake 3.30, this seems not to work anymore. Cmake 3.29.6 still works fine. I'm using Xcode 15.1.

I get the following error when trying to generate an Xcode project with Cmake:

  The C compiler targets architectures:

    "x86_64;arm64"

  but CMAKE_OSX_ARCHITECTURES is

    "$(ARCHS_STANDARD)"

If I set it explicitly to set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING ""), everything works as expected. I assume this new "consistency check" in Cmake is executed at a time where $(ARCHS_STANDARD) has not yet been evauluated.

Can anyone confirm this is Cmake bug? Or have I been doing this wrong all along (cf my Cmake snippet) and it's only now surfacing?


Solution

  • This was fixed in Cmake 3.30.2 after I reported the bug.