@@ -30,6 +30,8 @@ set(executorch_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../lib/cmake/ExecuTorch)
30
30
find_package (executorch CONFIG REQUIRED )
31
31
target_link_options_shared_lib (executorch )
32
32
33
+ add_library (executorch_jni SHARED jni/jni_layer.cpp )
34
+
33
35
set (link_libraries )
34
36
list (
35
37
APPEND
@@ -58,13 +60,21 @@ else()
58
60
list (APPEND link_libraries portable_ops_lib portable_kernels )
59
61
target_link_options_shared_lib (portable_ops_lib )
60
62
endif ()
63
+
64
+ if (TARGET quantized_kernels )
65
+ list (APPEND link_libraries quantized_kernels quantized_ops_lib )
66
+ target_link_options_shared_lib (quantized_ops_lib )
67
+ endif ()
68
+
61
69
if (TARGET qnn_executorch_backend )
62
70
list (APPEND link_libraries qnn_executorch_backend )
63
71
endif ()
72
+
64
73
if (TARGET xnnpack_backend )
65
74
target_link_options_shared_lib (xnnpack_backend )
66
75
list (APPEND link_libraries xnnpack_backend XNNPACK pthreadpool cpuinfo )
67
76
endif ()
77
+
68
78
if (TARGET vulkan_backend )
69
79
target_link_options_shared_lib (vulkan_backend )
70
80
list (APPEND link_libraries vulkan_backend )
@@ -79,7 +89,27 @@ if(EXECUTORCH_BUILD_KERNELS_CUSTOM)
79
89
target_link_options_shared_lib (custom_ops )
80
90
endif ()
81
91
82
- add_library (executorch_jni SHARED jni/jni_layer.cpp )
92
+ if (TARGET pthreadpool )
93
+ target_compile_definitions (executorch_jni PRIVATE ET_USE_THREADPOOL=1 )
94
+ target_include_directories (
95
+ executorch_jni
96
+ PUBLIC
97
+ ${CMAKE_CURRENT_SOURCE_DIR} /../../backends/xnnpack/third-party/cpuinfo/include
98
+ )
99
+ target_include_directories (
100
+ executorch_jni
101
+ PUBLIC
102
+ ${CMAKE_CURRENT_SOURCE_DIR} /../../backends/xnnpack/third-party/pthreadpool/include
103
+ )
104
+ endif ()
105
+
106
+ if (EXECUTORCH_JNI_CUSTOM_LIBRARY )
107
+ list (APPEND link_libraries ${EXECUTORCH_JNI_CUSTOM_LIBRARY} )
108
+ target_link_libraries (
109
+ executorch_jni -Wl,--whole-archive ${EXECUTORCH_JNI_CUSTOM_LIBRARY}
110
+ -Wl,--no-whole-archive
111
+ )
112
+ endif ()
83
113
84
114
if (EXECUTORCH_BUILD_LLAMA_JNI )
85
115
target_sources (executorch_jni PRIVATE jni/jni_layer_llama.cpp )
@@ -96,29 +126,10 @@ if(EXECUTORCH_BUILD_LLAMA_JNI)
96
126
)
97
127
endif ()
98
128
99
- if (TARGET quantized_kernels )
100
- list (APPEND link_libraries quantized_kernels quantized_ops_lib )
101
- target_link_options_shared_lib (quantized_ops_lib )
102
- endif ()
103
-
104
129
target_include_directories (
105
130
executorch_jni PRIVATE ${_common_include_directories}
106
131
)
107
132
108
133
target_compile_options (executorch_jni PUBLIC ${_common_compile_options} )
109
134
110
135
target_link_libraries (executorch_jni ${link_libraries} )
111
-
112
- if (TARGET pthreadpool )
113
- target_compile_definitions (executorch_jni PRIVATE ET_USE_THREADPOOL=1 )
114
- target_include_directories (
115
- executorch_jni
116
- PUBLIC
117
- ${CMAKE_CURRENT_SOURCE_DIR} /../../backends/xnnpack/third-party/cpuinfo/include
118
- )
119
- target_include_directories (
120
- executorch_jni
121
- PUBLIC
122
- ${CMAKE_CURRENT_SOURCE_DIR} /../../backends/xnnpack/third-party/pthreadpool/include
123
- )
124
- endif ()
0 commit comments