CMAKE plugin and OS 11 Universal Binary

I was having some issues with my build server not producing a universal binary. I also wanted to support users on OSX 10.9.

First I tried exporting an Xcode project after adding these lines to my CMakeLists.txt:

if(APPLE)
    set (CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment version" FORCE)
    set (CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "Architectures" FORCE)
    set (CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET[arch=arm64] "11.0" CACHE STRING "arm 64 minimum deployment target" FORCE)
endif()

This worked, producing different minimum targets for each architecture. I then tried exporting to Ninja - this works even better as it integrates nicely into CMake and detects the number of available processors for parallel builds.

1 Like