Skip to content

Commit ab99d19

Browse files
committed
Can this work
1 parent 06f9928 commit ab99d19

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,4 +721,8 @@ if(EXECUTORCH_BUILD_VULKAN)
721721
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/vulkan)
722722
endif()
723723

724+
if(ANDROID)
725+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/android)
726+
endif()
727+
724728
include(Test.cmake)

extension/android/CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
cmake_minimum_required(VERSION 3.24) # 3.24 is required for WHOLE_ARCHIVE
88

9-
project(executorch_jni)
9+
if(NOT EXECUTORCH_ROOT)
10+
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)
11+
endif()
1012

1113
if(NOT CMAKE_CXX_STANDARD)
1214
set(CMAKE_CXX_STANDARD 17)
@@ -16,7 +18,6 @@ if(NOT ANDROID)
1618
message(FATAL_ERROR "This directory is for Android build only")
1719
endif()
1820

19-
set(EXECUTORCH_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../..")
2021
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
2122
set(_common_compile_options -Wno-deprecated-declarations -fPIC)
2223
set(_common_include_directories ${EXECUTORCH_ROOT}/..)
@@ -60,8 +61,6 @@ set_target_properties(fbjni PROPERTIES
6061
IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/third-party/fbjni/prefab/modules/fbjni/libs/android.${ANDROID_ABI}/libfbjni.so"
6162
)
6263

63-
set(executorch_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../lib/cmake/ExecuTorch)
64-
find_package(executorch CONFIG REQUIRED)
6564
target_link_options_shared_lib(executorch)
6665

6766
add_library(executorch_jni SHARED jni/jni_layer.cpp jni/log.cpp jni/jni_layer_runtime.cpp)
@@ -152,12 +151,12 @@ if(EXECUTORCH_BUILD_LLAMA_JNI)
152151
target_compile_definitions(executorch_jni PUBLIC EXECUTORCH_BUILD_LLAMA_JNI=1)
153152
add_subdirectory(
154153
${EXECUTORCH_ROOT}/examples/models/llava/runner
155-
${CMAKE_CURRENT_BINARY_DIR}/../../examples/models/llava/runner
154+
${CMAKE_CURRENT_BINARY_DIR}/examples/models/llava/runner
156155
)
157156

158157
add_subdirectory(
159158
${EXECUTORCH_ROOT}/examples/models/llama/runner
160-
${CMAKE_CURRENT_BINARY_DIR}/../../examples/models/llama/runner
159+
${CMAKE_CURRENT_BINARY_DIR}/examples/models/llama/runner
161160
)
162161

163162
if(NEURON_BUFFER_ALLOCATOR_LIB)

extension/android/executorch_android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ android {
2525
cmake {
2626
abiFilters "arm64-v8a"
2727
targets "executorch_jni"
28-
arguments "-DBUILD_TESTING=OFF", "-DCMAKE_INSTALL_PREFIX=/Users/hsz/executorch/cmake-out-android-arm64-v8a", "-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH"
28+
arguments "-DBUILD_TESTING=OFF", "-DCMAKE_POLICY_VERSION_MINIMUM=3.24", "-DEXECUTORCH_BUILD_XNNPACK=ON", "-DEXECUTORCH_XNNPACK_SHARED_WORKSPACE=ON", "-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON", "-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON", "-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON", "-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON", "-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON", "-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON"
2929
}
3030
}
3131

@@ -47,7 +47,7 @@ android {
4747

4848
externalNativeBuild {
4949
cmake {
50-
path "../CMakeLists.txt"
50+
path "../../../CMakeLists.txt"
5151
}
5252
}
5353
}

0 commit comments

Comments
 (0)