Skip to content

Commit 862af95

Browse files
committed
append to CMAKE_PREFIX_PATH instead of setting executorch_DIR
I think the <package>_DIR mechanism is too low-level -- it helps find <package>, but not any dependencies that <package> also installed next to itself. CMAKE_PREFIX_PATH does both. ghstack-source-id: 7da76ee ghstack-comment-id: 3085703979 Pull-Request: #12618
1 parent d05008f commit 862af95

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

examples/models/llama/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,11 @@ find_package(gflags REQUIRED)
7777
# llama_main: test binary to run llama, with tokenizer and sampler integrated
7878
#
7979

80-
# find `executorch` libraries Same as for gflags
81-
set(executorch_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../../lib/cmake/ExecuTorch)
82-
find_package(executorch CONFIG REQUIRED)
80+
# find `executorch` libraries. CMAKE_PREFIX_PATH would work for host
81+
# compilation, but CMAKE_FIND_ROOT_PATH appears to be necessary for
82+
# cross-compiling (e.g., to Android) to work as well.
83+
list(APPEND CMAKE_FIND_ROOT_PATH ${CMAKE_CURRENT_BINARY_DIR}/../../..)
84+
find_package(executorch CONFIG REQUIRED FIND_ROOT_PATH_BOTH)
8385
target_link_options_shared_lib(executorch)
8486

8587
# llama_runner library

examples/models/llava/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ find_package(gflags REQUIRED)
7676
#
7777

7878
# find `executorch` libraries Same as for gflags
79-
set(executorch_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../../lib/cmake/ExecuTorch)
80-
find_package(executorch CONFIG REQUIRED)
79+
list(APPEND CMAKE_FIND_ROOT_PATH ${CMAKE_CURRENT_BINARY_DIR}/../../..)
80+
find_package(executorch CONFIG REQUIRED FIND_ROOT_PATH_BOTH)
8181
target_link_options_shared_lib(executorch)
8282

8383
# llava_runner library

examples/models/phi-3-mini/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ set(EXECUTORCH_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../..")
2424
set(_common_include_directories
2525
${EXECUTORCH_ROOT}/.. ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
2626
)
27-
set(executorch_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../../lib/cmake/ExecuTorch)
28-
find_package(executorch CONFIG REQUIRED)
27+
list(APPEND CMAKE_FIND_ROOT_PATH ${CMAKE_CURRENT_BINARY_DIR}/../../..)
28+
find_package(executorch CONFIG REQUIRED FIND_ROOT_PATH_BOTH)
2929

3030
target_link_options_shared_lib(executorch)
3131

extension/android/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ set_target_properties(fbjni PROPERTIES
6060
IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/third-party/fbjni/prefab/modules/fbjni/libs/android.${ANDROID_ABI}/libfbjni.so"
6161
)
6262

63-
set(executorch_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../lib/cmake/ExecuTorch)
6463
target_link_options_shared_lib(executorch)
6564

6665
add_library(executorch_jni SHARED jni/jni_layer.cpp jni/log.cpp jni/jni_layer_runtime.cpp)

0 commit comments

Comments
 (0)