Skip to content

Commit b85ed41

Browse files
committed
Update
[ghstack-poisoned]
1 parent 200b7dd commit b85ed41

File tree

1 file changed

+63
-7
lines changed

1 file changed

+63
-7
lines changed

tools/cmake/executorch-config.cmake

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,33 @@
2525

2626
cmake_minimum_required(VERSION 3.24)
2727
include("${CMAKE_CURRENT_LIST_DIR}/Utils.cmake")
28-
find_package(tokenizers REQUIRED)
28+
find_package(tokenizers) # not REQUIRED because building it is optional
2929

3030
set(_root "${CMAKE_CURRENT_LIST_DIR}/../../..")
31+
set(required_lib_list executorch executorch_core portable_kernels)
32+
set(EXECUTORCH_LIBRARIES)
3133
set(EXECUTORCH_INCLUDE_DIRS
3234
${_root}/include ${_root}/include/executorch/runtime/core/portable_type/c10
3335
${_root}/lib
3436
)
35-
set(non_exported_lib_list XNNPACK xnnpack-microkernels-prod kleidiai pthreadpool cpuinfo)
37+
foreach(lib ${required_lib_list})
38+
set(lib_var "LIB_${lib}")
39+
find_library(
40+
${lib_var} ${lib}
41+
HINTS "${_root}/lib"
42+
CMAKE_FIND_ROOT_PATH_BOTH
43+
)
44+
if(NOT ${lib_var})
45+
set(EXECUTORCH_FOUND OFF)
46+
return()
47+
endif()
48+
list(APPEND EXECUTORCH_LIBRARIES ${lib})
49+
endforeach()
50+
set(EXECUTORCH_FOUND ON)
51+
52+
set(non_exported_lib_list XNNPACK xnnpack-microkernels-prod kleidiai
53+
pthreadpool cpuinfo
54+
)
3655
foreach(lib ${non_exported_lib_list})
3756
# Name of the variable which stores result of the find_library search
3857
set(lib_var "LIB_${lib}")
@@ -48,14 +67,51 @@ foreach(lib ${non_exported_lib_list})
4867
else()
4968
add_library(${lib} STATIC IMPORTED)
5069
set_target_properties(${lib} PROPERTIES IMPORTED_LOCATION "${${lib_var}}")
51-
target_include_directories(
52-
${lib}
53-
INTERFACE ${EXECUTORCH_INCLUDE_DIRS}
54-
)
70+
target_include_directories(${lib} INTERFACE ${EXECUTORCH_INCLUDE_DIRS})
5571
list(APPEND EXECUTORCH_LIBRARIES ${lib})
5672
endif()
5773
endforeach()
5874

5975
include("${CMAKE_CURRENT_LIST_DIR}/ExecuTorchTargets.cmake")
6076

61-
# TODO: does ExecuTorchTargets.cmake set EXECUTORCH_FOUND?
77+
set(optional_lib_list
78+
flatccrt
79+
etdump
80+
bundled_program
81+
extension_data_loader
82+
extension_flat_tensor
83+
coreml_util
84+
coreml_inmemoryfs
85+
coremldelegate
86+
mpsdelegate
87+
neuron_backend
88+
qnn_executorch_backend
89+
portable_ops_lib
90+
custom_ops
91+
extension_module
92+
extension_module_static
93+
extension_runner_util
94+
extension_tensor
95+
extension_threadpool
96+
extension_training
97+
xnnpack_backend
98+
vulkan_backend
99+
optimized_kernels
100+
optimized_portable_kernels
101+
cpublas
102+
eigen_blas
103+
optimized_ops_lib
104+
optimized_native_cpu_ops_lib
105+
quantized_kernels
106+
quantized_ops_lib
107+
quantized_ops_aot_lib
108+
)
109+
foreach(lib ${optional_lib_list})
110+
if(TARGET ${lib})
111+
list(APPEND EXECUTORCH_LIBRARIES ${lib})
112+
else()
113+
message("${lib} library is not found.
114+
If needed rebuild with the proper options in CMakeLists.txt"
115+
)
116+
endif()
117+
endforeach()

0 commit comments

Comments
 (0)