@@ -175,9 +175,8 @@ option(EXECUTORCH_BUILD_VULKAN "Build the Vulkan backend" OFF)
175
175
#
176
176
# pthreadpool: build pthreadpool library. Disable on unsupported platforms
177
177
#
178
- cmake_dependent_option(
179
- EXECUTORCH_BUILD_PTHREADPOOL "Build pthreadpool library." ON
180
- "NOT EXECUTORCH_BUILD_ARM_BAREMETAL" OFF )
178
+ cmake_dependent_option(EXECUTORCH_BUILD_PTHREADPOOL "Build pthreadpool library."
179
+ ON "NOT EXECUTORCH_BUILD_ARM_BAREMETAL" OFF )
181
180
182
181
#
183
182
# cpuinfo: build cpuinfo library. Disable on unsupported platforms
@@ -187,9 +186,6 @@ cmake_dependent_option(EXECUTORCH_BUILD_CPUINFO "Build cpuinfo library." ON
187
186
188
187
if (EXECUTORCH_BUILD_CPUINFO)
189
188
# --- cpuinfo
190
- set (ORIGINAL_CMAKE_POSITION_INDEPENDENT_CODE_FLAG
191
- ${CMAKE_POSITION_INDEPENDENT_CODE} )
192
- set (CMAKE_POSITION_INDEPENDENT_CODE ON )
193
189
set (CPUINFO_SOURCE_DIR "backends/xnnpack/third-party/cpuinfo" )
194
190
set (CPUINFO_BUILD_TOOLS
195
191
OFF
@@ -211,15 +207,10 @@ if(EXECUTORCH_BUILD_CPUINFO)
211
207
CACHE STRING "" )
212
208
set (CLOG_SOURCE_DIR "${CPUINFO_SOURCE_DIR} /deps/clog" )
213
209
add_subdirectory ("${CPUINFO_SOURCE_DIR} " )
214
- set (CMAKE_POSITION_INDEPENDENT_CODE
215
- ${ORIGINAL_CMAKE_POSITION_INDEPENDENT_CODE_FLAG} )
216
210
endif ()
217
211
218
212
if (EXECUTORCH_BUILD_PTHREADPOOL)
219
213
# --- pthreadpool
220
- set (ORIGINAL_CMAKE_POSITION_INDEPENDENT_CODE_FLAG
221
- ${CMAKE_POSITION_INDEPENDENT_CODE} )
222
- set (CMAKE_POSITION_INDEPENDENT_CODE ON )
223
214
set (PTHREADPOOL_SOURCE_DIR "backends/xnnpack/third-party/pthreadpool" )
224
215
set (PTHREADPOOL_BUILD_TESTS
225
216
OFF
@@ -239,8 +230,6 @@ if(EXECUTORCH_BUILD_PTHREADPOOL)
239
230
CACHE STRING "" )
240
231
endif ()
241
232
add_subdirectory ("${PTHREADPOOL_SOURCE_DIR} " )
242
- set (CMAKE_POSITION_INDEPENDENT_CODE
243
- ${ORIGINAL_CMAKE_POSITION_INDEPENDENT_CODE_FLAG} )
244
233
endif ()
245
234
246
235
if (NOT PYTHON_EXECUTABLE)
@@ -515,38 +504,25 @@ if(EXECUTORCH_BUILD_PYBIND)
515
504
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /sdk)
516
505
endif ()
517
506
518
- # find pytorch lib, to allow pybind to take at::Tensor as input/output
519
- find_package (Torch CONFIG REQUIRED)
520
- find_library (TORCH_PYTHON_LIBRARY torch_python
521
- PATHS "${TORCH_INSTALL_PREFIX} /lib" )
522
-
523
- set (_dep_libs
524
- ${TORCH_PYTHON_LIBRARY}
525
- bundled_program
526
- etdump
527
- executorch
528
- extension_data_loader
529
- portable_ops_lib
530
- util
531
- torch)
532
-
533
507
if (EXECUTORCH_BUILD_COREML)
534
- list ( APPEND _dep_libs coremldelegate)
508
+ set (PYBIND_LINK_COREML " coremldelegate" )
535
509
endif ()
536
510
537
511
if (EXECUTORCH_BUILD_MPS)
538
- list ( APPEND _dep_libs mpsdelegate)
512
+ set (PYBIND_LINK_MPS " mpsdelegate" )
539
513
endif ()
540
514
541
515
if (EXECUTORCH_BUILD_XNNPACK)
542
- # need to explicitly specify XNNPACK here otherwise uses XNNPACK symbols
543
- # from libtorch_cpu
544
- list ( APPEND _dep_libs xnnpack_backend XNNPACK)
516
+ # need to explicitly specify XNNPACK here
517
+ # otherwise uses XNNPACK symbols from libtorch_cpu
518
+ set (PYBIND_LINK_XNNPACK xnnpack_backend XNNPACK)
545
519
endif ()
546
520
547
- if (EXECUTORCH_BUILD_CUSTOM)
548
- list (APPEND _dep_libs custom_ops custom_ops_aot_lib)
549
- endif ()
521
+ # find pytorch lib, to allow pybind to take at::Tensor as input/output
522
+ find_package (Torch CONFIG REQUIRED)
523
+ find_library (TORCH_PYTHON_LIBRARY torch_python
524
+ PATHS "${TORCH_INSTALL_PREFIX} /lib" )
525
+
550
526
# compile options for pybind
551
527
552
528
set (_pybind_compile_options -Wno-deprecated-declarations -fPIC -frtti
@@ -568,7 +544,19 @@ if(EXECUTORCH_BUILD_PYBIND)
568
544
PUBLIC EXECUTORCH_PYTHON_MODULE_NAME=portable_lib)
569
545
target_include_directories (portable_lib PRIVATE ${TORCH_INCLUDE_DIRS} )
570
546
target_compile_options (portable_lib PUBLIC ${_pybind_compile_options} )
571
- target_link_libraries (portable_lib PUBLIC ${_dep_libs} )
547
+ target_link_libraries (
548
+ portable_lib
549
+ PUBLIC ${TORCH_PYTHON_LIBRARY}
550
+ bundled_program
551
+ etdump
552
+ executorch
553
+ extension_data_loader
554
+ portable_ops_lib
555
+ util
556
+ torch
557
+ ${PYBIND_LINK_COREML}
558
+ ${PYBIND_LINK_MPS}
559
+ ${PYBIND_LINK_XNNPACK} )
572
560
573
561
install (TARGETS portable_lib
574
562
LIBRARY DESTINATION executorch/extension/pybindings)
0 commit comments