Skip to content

Commit 9d4a07c

Browse files
authored
Create CMakeLists.txt for extension/llm/apple (#12626)
1 parent 934b964 commit 9d4a07c

File tree

4 files changed

+62
-1
lines changed

4 files changed

+62
-1
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,10 @@ if(EXECUTORCH_BUILD_EXTENSION_LLM)
562562
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/llm/tokenizers)
563563
endif()
564564

565+
if(EXECUTORCH_BUILD_EXTENSION_LLM_APPLE)
566+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/llm/apple)
567+
endif()
568+
565569
if(EXECUTORCH_BUILD_EXTENSION_LLM_RUNNER)
566570
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/llm/runner)
567571
endif()

extension/llm/apple/CMakeLists.txt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
# Please this file formatted by running:
8+
# ~~~
9+
# cmake-format -i CMakeLists.txt
10+
# ~~~
11+
12+
cmake_minimum_required(VERSION 3.19)
13+
14+
enable_language(Swift)
15+
16+
# Source root directory for executorch.
17+
if(NOT EXECUTORCH_ROOT)
18+
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
19+
endif()
20+
21+
add_library(extension_llm_apple)
22+
23+
file(GLOB OBJC_SOURCES
24+
ExecuTorchLLM/Exported/*.m
25+
ExecuTorchLLM/Exported/*.mm
26+
)
27+
28+
target_sources(extension_llm_apple PRIVATE
29+
${OBJC_SOURCES}
30+
)
31+
32+
target_include_directories(extension_llm_apple
33+
PUBLIC ExecuTorchLLM/Exported
34+
)
35+
36+
if(NOT TARGET extension_llm_runner)
37+
add_subdirectory(
38+
${EXECUTORCH_ROOT}/extension/llm/runner
39+
${CMAKE_CURRENT_BINARY_DIR}/../runner
40+
)
41+
endif()
42+
43+
find_library(FOUNDATION_FRAMEWORK Foundation)
44+
target_link_libraries(extension_llm_apple
45+
PRIVATE extension_llm_runner ${FOUNDATION_FRAMEWORK}
46+
)
47+
48+
set_source_files_properties(${OBJC_SOURCES} PROPERTIES COMPILE_FLAGS
49+
"-fobjc-arc"
50+
"-fno-exceptions"
51+
"-fno-rtti"
52+
)

tools/cmake/preset/apple_common.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ set_overridable_option(EXECUTORCH_BUILD_MPS ON)
2020
set_overridable_option(EXECUTORCH_XNNPACK_SHARED_WORKSPACE ON)
2121
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_APPLE ON)
2222
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
23-
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_LLM_RUNNER ON)
23+
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_LLM_APPLE ON)
2424
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_MODULE ON)
2525
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
2626
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TENSOR ON)

tools/cmake/preset/default.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ define_overridable_option(
9494
"Build the LLM extension"
9595
BOOL OFF
9696
)
97+
define_overridable_option(
98+
EXECUTORCH_BUILD_EXTENSION_LLM_APPLE
99+
"Build the LLM Apple extension"
100+
BOOL OFF
101+
)
97102
define_overridable_option(
98103
EXECUTORCH_BUILD_EXTENSION_MODULE
99104
"Build the Module extension"

0 commit comments

Comments
 (0)