Skip to content

CMake: Set CMAKE_OSX_ only on Darwin? #94952

@primeos

Description

@primeos

In 68513e4 (part of #77632) CMAKE_OSX_ARCHITECTURES=x86_64 was moved from pkgs/stdenv/darwin/default.nix to pkgs/development/tools/build-managers/cmake/setup-hook.sh. As a result -DCMAKE_OSX_ARCHITECTURES=x86_64 is since then set on Linux as well.
Until now this wasn't a problem as https://cmake.org/cmake/help/v3.18/variable/CMAKE_OSX_ARCHITECTURES.html states that:

This variable is ignored on platforms other than Apple.

Unfortunately that behaviour changed in CMake 3.18:

To avoid such regressions in the future it might be a good idea to set the following two CMake flags (source) only on Darwin:

    # on macOS i686 was only relevant for 10.5 or earlier.
    cmakeFlags="-DCMAKE_OSX_ARCHITECTURES=x86_64 $cmakeFlags"

    # we never want to use the global macOS SDK
    cmakeFlags="-DCMAKE_OSX_SYSROOT= $cmakeFlags"

cc CMake maintainers: @ttuegel @LnL7
cc @orivej (found this regression)

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: enhancementAdd something new or improve an existing system.6.topic: darwinRunning or building packages on Darwin

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions