Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • CMake CMake
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,924
    • Issues 3,924
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 20
    • Merge requests 20
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMake
  • CMakeCMake
  • Merge requests
  • !5589

macOS: Offer control over host architecture on Apple Silicon hosts

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Brad King requested to merge brad.king/cmake:apple-silicon-host-arch into master Dec 08, 2020
  • Overview 18
  • Commits 2
  • Pipelines 8
  • Changes 22

Since !5291 (merged) we use sysctl to detect that we are running on Apple Silicon in a way that pierces Rosetta. This always sets CMAKE_HOST_SYSTEM_PROCESSOR to be arm64 on such hosts. However, macOS offers strong support for running processes under an emulated x86_64 architecture.

Teach CMake to select either arm64 or x86_64 as the host architecture on Apple Silicon based on the architecture of its own process. When CMake is built as a universal binary, macOS will select whichever slice (architecture) is appropriate under the user's shell, and CMAKE_HOST_SYSTEM_PROCESSOR will match.

Also offer a CMAKE_APPLE_SILICON_PROCESSOR variable and environment variable to provide users with explicit control over the host architecture selection regardless of CMake's own architecture.

Finally, if CMAKE_OSX_ARCHITECTURES is not set, pass explicit flags to the toolchain to use selected host architecture instead of letting the toolchain pick.

Fixes: #21554 (closed)
Backport: release

Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: apple-silicon-host-arch