Skip to content

Create a macos-arm64 preset #10768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/build-presets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,20 @@ on:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }}
cancel-in-progress: true

jobs:
apple:
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
strategy:
matrix:
preset: [macos-arm64]
with:
job-name: build
runner: macos-latest-xlarge
python-version: 3.12
submodules: recursive
script: |
set -eux
${CONDA_RUN} ./install_requirements.sh > /dev/null
${CONDA_RUN} cmake --preset ${{ matrix.preset }}
${CONDA_RUN} cmake --build cmake-out --parallel
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ project(executorch)
# MARK: - Start EXECUTORCH_H12025_BUILD_MIGRATION --------------------------------------------------

include(${PROJECT_SOURCE_DIR}/tools/cmake/common/preset.cmake)

load_build_preset()
include(${PROJECT_SOURCE_DIR}/tools/cmake/preset/default.cmake)

# Print all the configs that were called with announce_configured_options.
Expand Down
33 changes: 33 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"version": 10,
"cmakeMinimumRequired": {
"major": 3,
"minor": 31,
"patch": 0
},
"$comment": "On-device AI across mobile, embedded and edge for PyTorch.",
"configurePresets": [
{
"name": "common",
"hidden": true,
"binaryDir": "${sourceDir}/cmake-out",
"generator": "Unix Makefiles"
},
{
"name": "macos-arm64",
"inherits": ["common"],
"generator": "Xcode",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/third-party/ios-cmake/ios.toolchain.cmake",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we using the iOS toolchain on macOS?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/macos-arm64.cmake",
"PLATFORM": "MAC_ARM64",
"DEPLOYMENT_TARGET": "10.15"
},
"condition": {
"lhs": "${hostSystemName}",
"type": "equals",
"rhs": "Darwin"
}
}
]
}
5 changes: 5 additions & 0 deletions tools/cmake/Utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,11 @@ function(resolve_python_executable)
python
PARENT_SCOPE
)
elseif(DEFINED ENV{VIRTUAL_ENV})
set(PYTHON_EXECUTABLE
$ENV{VIRTUAL_ENV}/bin/python3
PARENT_SCOPE
)
else()
set(PYTHON_EXECUTABLE
python3
Expand Down
11 changes: 11 additions & 0 deletions tools/cmake/common/preset.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,14 @@ macro(set_overridable_option NAME VALUE)

set(${NAME} ${VALUE} CACHE STRING "")
endmacro()

# Detemine the build preset and load it.
macro(load_build_preset)
if(DEFINED EXECUTORCH_BUILD_PRESET_FILE)
announce_configured_options(EXECUTORCH_BUILD_PRESET_FILE)
message(STATUS "Loading build preset: ${EXECUTORCH_BUILD_PRESET_FILE}")
include(${EXECUTORCH_BUILD_PRESET_FILE})
endif()
# For now, just continue if the preset file is not set. In the future, we will
# try to determine a preset file.
endmacro()
Loading