Skip to content

Commit 18ce8a8

Browse files
authored
Create an iOS and macOS preset (#11111)
### Summary * Create a `macos`, `ios`, and `ios-simulator` preset * The flags are copied from [scripts/build_apple_frameworks.sh](https://github.com/pytorch/executorch/blob/f2fb35159b2287ad8de2e0343b18520356abe305/scripts/build_apple_frameworks.sh#L177-L212). In an upcoming PR, I will replace that command with this preset ### Test plan CI + ``` $ cmake --preset macos && cmake --build cmake-out -j $(sysctl -n hw.ncpu) $ cmake --preset ios && cmake --build cmake-out -j $(sysctl -n hw.ncpu) $ cmake --preset ios-simulator && cmake --build cmake-out -j $(sysctl -n hw.ncpu) ``` cc @larryliu0820
1 parent f2fb351 commit 18ce8a8

File tree

5 files changed

+77
-5
lines changed

5 files changed

+77
-5
lines changed

.github/workflows/build-presets.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
strategy:
2121
fail-fast: false
2222
matrix:
23-
preset: [macos-arm64, pybind, llm]
23+
preset: [macos, ios, ios-simulator, pybind, llm]
2424
with:
2525
job-name: build
2626
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}

CMakePresets.json

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
"binaryDir": "${sourceDir}/cmake-out"
88
},
99
{
10-
"name": "macos-arm64",
11-
"displayName": "Build everything buildable on macOS arm64",
10+
"name": "macos",
11+
"displayName": "Build everything buildable on macOS",
1212
"inherits": ["common"],
1313
"generator": "Xcode",
1414
"cacheVariables": {
1515
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/third-party/ios-cmake/ios.toolchain.cmake",
16-
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/macos-arm64.cmake",
16+
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/macos.cmake",
1717
"PLATFORM": "MAC_ARM64",
1818
"DEPLOYMENT_TARGET": "10.15"
1919
},
@@ -23,6 +23,40 @@
2323
"rhs": "Darwin"
2424
}
2525
},
26+
{
27+
"name": "ios",
28+
"displayName": "Build everything buildable on iOS",
29+
"inherits": ["common"],
30+
"generator": "Xcode",
31+
"cacheVariables": {
32+
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/third-party/ios-cmake/ios.toolchain.cmake",
33+
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/ios.cmake",
34+
"PLATFORM": "OS64",
35+
"DEPLOYMENT_TARGET": "17.0"
36+
},
37+
"condition": {
38+
"lhs": "${hostSystemName}",
39+
"type": "equals",
40+
"rhs": "Darwin"
41+
}
42+
},
43+
{
44+
"name": "ios-simulator",
45+
"displayName": "Build everything buildable on iOS simulator",
46+
"inherits": ["common"],
47+
"generator": "Xcode",
48+
"cacheVariables": {
49+
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/third-party/ios-cmake/ios.toolchain.cmake",
50+
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/ios.cmake",
51+
"PLATFORM": "SIMULATORARM64",
52+
"DEPLOYMENT_TARGET": "17.0"
53+
},
54+
"condition": {
55+
"lhs": "${hostSystemName}",
56+
"type": "equals",
57+
"rhs": "Darwin"
58+
}
59+
},
2660
{
2761
"name": "pybind",
2862
"displayName": "Build pybindings exported in the wheel",

tools/cmake/preset/apple_common.cmake

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++${CMAKE_CXX_STANDARD}")
8+
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
9+
10+
set(
11+
_compiler_flags
12+
"-ffile-prefix-map=${PROJECT_SOURCE_DIR}=/executorch"
13+
"-fdebug-prefix-map=${PROJECT_SOURCE_DIR}=/executorch"
14+
)
15+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_compiler_flags}")
16+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_compiler_flags}")
17+
18+
set_overridable_option(EXECUTORCH_BUILD_XNNPACK ON)
19+
set_overridable_option(EXECUTORCH_BUILD_COREML ON)
20+
set_overridable_option(EXECUTORCH_BUILD_MPS ON)
21+
set_overridable_option(EXECUTORCH_XNNPACK_SHARED_WORKSPACE ON)
22+
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_APPLE ON)
23+
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
24+
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_MODULE ON)
25+
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TENSOR ON)
26+
set_overridable_option(EXECUTORCH_BUILD_KERNELS_CUSTOM ON)
27+
set_overridable_option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON)
28+
set_overridable_option(EXECUTORCH_BUILD_KERNELS_QUANTIZED ON)

tools/cmake/preset/macos-arm64.cmake renamed to tools/cmake/preset/ios.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# This source code is licensed under the BSD-style license found in the
55
# LICENSE file in the root directory of this source tree.
66

7-
set_overridable_option(EXECUTORCH_BUILD_COREML ON)
7+
include(${PROJECT_SOURCE_DIR}/tools/cmake/preset/apple_common.cmake)

tools/cmake/preset/macos.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
include(${PROJECT_SOURCE_DIR}/tools/cmake/preset/apple_common.cmake)
8+
include(${PROJECT_SOURCE_DIR}/tools/cmake/preset/pybind.cmake)
9+
10+
set_overridable_option(EXECUTORCH_BUILD_EXECUTOR_RUNNER ON)

0 commit comments

Comments
 (0)