From 9ace4dee0828bce6f68544f3987c4549378c0d8c Mon Sep 17 00:00:00 2001 From: jathu Date: Fri, 23 May 2025 13:29:46 -0700 Subject: [PATCH] =?UTF-8?q?wip=20=E2=88=AB=20MAY=2023=202025=2013:29:44?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-presets.yml | 2 +- CMakePresets.json | 40 +++++++++++++++++-- tools/cmake/preset/apple_common.cmake | 28 +++++++++++++ .../preset/{macos-arm64.cmake => ios.cmake} | 2 +- tools/cmake/preset/macos.cmake | 10 +++++ 5 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 tools/cmake/preset/apple_common.cmake rename tools/cmake/preset/{macos-arm64.cmake => ios.cmake} (75%) create mode 100644 tools/cmake/preset/macos.cmake diff --git a/.github/workflows/build-presets.yml b/.github/workflows/build-presets.yml index 306987a9a90..1cf1f165ca9 100644 --- a/.github/workflows/build-presets.yml +++ b/.github/workflows/build-presets.yml @@ -20,7 +20,7 @@ jobs: strategy: fail-fast: false matrix: - preset: [macos-arm64, pybind, llm] + preset: [macos, ios, ios-simulator, pybind, llm] with: job-name: build ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} diff --git a/CMakePresets.json b/CMakePresets.json index ff30558d268..85452d18822 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -7,13 +7,13 @@ "binaryDir": "${sourceDir}/cmake-out" }, { - "name": "macos-arm64", - "displayName": "Build everything buildable on macOS arm64", + "name": "macos", + "displayName": "Build everything buildable on macOS", "inherits": ["common"], "generator": "Xcode", "cacheVariables": { "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/third-party/ios-cmake/ios.toolchain.cmake", - "EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/macos-arm64.cmake", + "EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/macos.cmake", "PLATFORM": "MAC_ARM64", "DEPLOYMENT_TARGET": "10.15" }, @@ -23,6 +23,40 @@ "rhs": "Darwin" } }, + { + "name": "ios", + "displayName": "Build everything buildable on iOS", + "inherits": ["common"], + "generator": "Xcode", + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/third-party/ios-cmake/ios.toolchain.cmake", + "EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/ios.cmake", + "PLATFORM": "OS64", + "DEPLOYMENT_TARGET": "17.0" + }, + "condition": { + "lhs": "${hostSystemName}", + "type": "equals", + "rhs": "Darwin" + } + }, + { + "name": "ios-simulator", + "displayName": "Build everything buildable on iOS simulator", + "inherits": ["common"], + "generator": "Xcode", + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/third-party/ios-cmake/ios.toolchain.cmake", + "EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/ios.cmake", + "PLATFORM": "SIMULATORARM64", + "DEPLOYMENT_TARGET": "17.0" + }, + "condition": { + "lhs": "${hostSystemName}", + "type": "equals", + "rhs": "Darwin" + } + }, { "name": "pybind", "displayName": "Build pybindings exported in the wheel", diff --git a/tools/cmake/preset/apple_common.cmake b/tools/cmake/preset/apple_common.cmake new file mode 100644 index 00000000000..c4f0c0a5fc8 --- /dev/null +++ b/tools/cmake/preset/apple_common.cmake @@ -0,0 +1,28 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++${CMAKE_CXX_STANDARD}") +set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") + +set( + _compiler_flags + "-ffile-prefix-map=${PROJECT_SOURCE_DIR}=/executorch" + "-fdebug-prefix-map=${PROJECT_SOURCE_DIR}=/executorch" +) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_compiler_flags}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_compiler_flags}") + +set_overridable_option(EXECUTORCH_BUILD_XNNPACK ON) +set_overridable_option(EXECUTORCH_BUILD_COREML ON) +set_overridable_option(EXECUTORCH_BUILD_MPS ON) +set_overridable_option(EXECUTORCH_XNNPACK_SHARED_WORKSPACE ON) +set_overridable_option(EXECUTORCH_BUILD_EXTENSION_APPLE ON) +set_overridable_option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON) +set_overridable_option(EXECUTORCH_BUILD_EXTENSION_MODULE ON) +set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TENSOR ON) +set_overridable_option(EXECUTORCH_BUILD_KERNELS_CUSTOM ON) +set_overridable_option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON) +set_overridable_option(EXECUTORCH_BUILD_KERNELS_QUANTIZED ON) diff --git a/tools/cmake/preset/macos-arm64.cmake b/tools/cmake/preset/ios.cmake similarity index 75% rename from tools/cmake/preset/macos-arm64.cmake rename to tools/cmake/preset/ios.cmake index 84e60c50b92..0fc3b36f3ed 100644 --- a/tools/cmake/preset/macos-arm64.cmake +++ b/tools/cmake/preset/ios.cmake @@ -4,4 +4,4 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -set_overridable_option(EXECUTORCH_BUILD_COREML ON) +include(${PROJECT_SOURCE_DIR}/tools/cmake/preset/apple_common.cmake) diff --git a/tools/cmake/preset/macos.cmake b/tools/cmake/preset/macos.cmake new file mode 100644 index 00000000000..fc7a5872d9a --- /dev/null +++ b/tools/cmake/preset/macos.cmake @@ -0,0 +1,10 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +include(${PROJECT_SOURCE_DIR}/tools/cmake/preset/apple_common.cmake) +include(${PROJECT_SOURCE_DIR}/tools/cmake/preset/pybind.cmake) + +set_overridable_option(EXECUTORCH_BUILD_EXECUTOR_RUNNER ON)