Skip to content

Commit a167d66

Browse files
committed
protect cmakelist for extension under NEURON_BUFFER_ALLOCATOR_LIB flag
1 parent 78df8b5 commit a167d66

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

extension/android/CMakeLists.txt

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -159,25 +159,27 @@ if(EXECUTORCH_BUILD_LLAMA_JNI)
159159
${CMAKE_CURRENT_BINARY_DIR}/../../examples/models/llama/runner
160160
)
161161

162-
target_sources(
163-
executorch_jni PRIVATE
164-
${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/mtk_llama_runner.cpp
165-
${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/LlamaModelChunk.cpp
166-
${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/LlamaRuntime.cpp
167-
${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/ModelChunk.cpp
168-
${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/MultiModelLoader.cpp
169-
${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/llm_helper/mask_builder.cpp
170-
${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/llm_helper/rotary_embedding.cpp
171-
${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/llm_helper/token_embedding.cpp
172-
)
173-
target_include_directories(
174-
executorch_jni PRIVATE
175-
${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/
176-
${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner
177-
)
178-
ADD_LIBRARY(libneuron_buffer_allocator SHARED IMPORTED)
179-
SET_PROPERTY(TARGET libneuron_buffer_allocator PROPERTY IMPORTED_LOCATION ${NEURON_BUFFER_ALLOCATOR_LIB})
180-
list(APPEND link_libraries neuron_backend libneuron_buffer_allocator)
162+
if(NEURON_BUFFER_ALLOCATOR_LIB)
163+
target_sources(
164+
executorch_jni PRIVATE
165+
${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/mtk_llama_runner.cpp
166+
${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/LlamaModelChunk.cpp
167+
${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/LlamaRuntime.cpp
168+
${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/ModelChunk.cpp
169+
${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/MultiModelLoader.cpp
170+
${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/llm_helper/mask_builder.cpp
171+
${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/llm_helper/rotary_embedding.cpp
172+
${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner/llm_helper/token_embedding.cpp
173+
)
174+
target_include_directories(
175+
executorch_jni PRIVATE
176+
${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/
177+
${EXECUTORCH_ROOT}/examples/mediatek/executor_runner/llama_runner
178+
)
179+
ADD_LIBRARY(libneuron_buffer_allocator SHARED IMPORTED)
180+
SET_PROPERTY(TARGET libneuron_buffer_allocator PROPERTY IMPORTED_LOCATION ${NEURON_BUFFER_ALLOCATOR_LIB})
181+
list(APPEND link_libraries neuron_backend libneuron_buffer_allocator)
182+
endif()
181183
endif()
182184

183185
target_include_directories(

0 commit comments

Comments
 (0)