Skip to content

Commit 02e50cc

Browse files
authored
Add top-level CMake backends target (#12689)
Add a top level backends CMake target, which includes all configured backends. I validate this change by building a simple runner using the executorch_backends target and verifying that it was able to build and run an XNNPACK-delegated binary. Once the changes land in ExecuTorch, this will be long-term validated in executorch-examples CI. To allow the executor runner target to use the executorch_backends target, I've also moved the Vulkan defs above the runner. This causes issues with the vulkan_executor_runner target, so I'm updating the main runner to include Vulkan and remove the Vulkan-specific one (subject to @SS-JIA's signoff). This is done in the context of top-level CMake targets, tracked in #12293.
1 parent 37e3003 commit 02e50cc

File tree

2 files changed

+36
-37
lines changed

2 files changed

+36
-37
lines changed

CMakeLists.txt

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,9 @@ add_library(executorch_core ${_executorch_core__srcs})
380380
# Legacy name alias.
381381
add_library(executorch_no_prim_ops ALIAS executorch_core)
382382

383+
# A list of all configured backends.
384+
set(_executorch_backends "")
385+
383386
target_link_libraries(executorch_core PRIVATE program_schema)
384387
if(ANDROID)
385388
target_link_libraries(executorch_core PUBLIC log)
@@ -524,6 +527,7 @@ install(FILES tools/cmake/executorch-config.cmake
524527

525528
if(EXECUTORCH_BUILD_ARM_BAREMETAL)
526529
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/arm)
530+
list(APPEND _executorch_backends executorch_delegate_ethos_u)
527531
endif()
528532

529533
if(EXECUTORCH_BUILD_CADENCE)
@@ -532,30 +536,37 @@ endif()
532536

533537
if(EXECUTORCH_BUILD_NXP_NEUTRON)
534538
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/nxp)
539+
list(APPEND _executorch_backends executorch_delegate_neutron)
535540
endif()
536541

537542
if(EXECUTORCH_BUILD_COREML)
538543
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/apple/coreml)
544+
list(APPEND _executorch_backends coremldelegate)
539545
endif()
540546

541547
if(EXECUTORCH_BUILD_MPS)
542548
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/apple/mps)
549+
list(APPEND _executorch_backends mpsdelegate)
543550
endif()
544551

545552
if(EXECUTORCH_BUILD_NEURON)
546553
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/mediatek)
554+
list(APPEND _executorch_backends neuron_backend)
547555
endif()
548556

549557
if(EXECUTORCH_BUILD_OPENVINO)
550558
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/openvino)
559+
list(APPEND _executorch_backends openvino_backend)
551560
endif()
552561

553562
if(EXECUTORCH_BUILD_QNN)
554563
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/qualcomm)
564+
list(APPEND _executorch_backends qnn_executorch_backend)
555565
endif()
556566

557567
if(EXECUTORCH_BUILD_XNNPACK)
558568
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/xnnpack)
569+
list(APPEND _executorch_backends xnnpack_backend)
559570
endif()
560571

561572
if(EXECUTORCH_BUILD_CORTEX_M)
@@ -757,10 +768,35 @@ if(EXECUTORCH_BUILD_KERNELS_QUANTIZED)
757768
executorch_target_link_options_shared_lib(quantized_ops_lib)
758769
endif()
759770

771+
if(EXECUTORCH_BUILD_VULKAN)
772+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/vulkan)
773+
list(APPEND _executorch_backends vulkan_backend vulkan_schema)
774+
endif()
775+
776+
if(EXECUTORCH_BUILD_VGF)
777+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/arm)
778+
list(APPEND _executorch_backends vgf_backend)
779+
endif()
780+
781+
782+
# Top-level interface targets.
783+
add_library(executorch_backends INTERFACE)
784+
add_library(executorch::backends ALIAS executorch_backends)
785+
786+
# A target containing all configured backends.
787+
target_link_libraries(executorch_backends INTERFACE ${_executorch_backends})
788+
789+
install(
790+
TARGETS executorch_backends
791+
INCLUDES
792+
DESTINATION ${_common_include_directories}
793+
)
794+
760795
if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
761796
# Baseline libraries that executor_runner will link against.
762797
set(_executor_runner_libs executorch extension_evalue_util
763798
extension_runner_util gflags
799+
executorch_backends
764800
)
765801

766802
if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED)
@@ -780,18 +816,10 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
780816
list(APPEND _executor_runner_libs $<LINK_LIBRARY:WHOLE_ARCHIVE,custom_ops>)
781817
endif()
782818

783-
if(EXECUTORCH_BUILD_XNNPACK)
784-
list(APPEND _executor_runner_libs xnnpack_backend)
785-
endif()
786-
787819
if(EXECUTORCH_ENABLE_EVENT_TRACER)
788820
list(APPEND _executor_runner_libs etdump flatccrt)
789821
endif()
790822

791-
if(EXECUTORCH_BUILD_COREML AND APPLE)
792-
list(APPEND _executor_runner_libs coremldelegate)
793-
endif()
794-
795823
add_executable(executor_runner ${_executor_runner__srcs})
796824
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
797825
target_link_options_gc_sections(executor_runner)
@@ -814,14 +842,6 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
814842
endif()
815843
endif()
816844

817-
if(EXECUTORCH_BUILD_VULKAN)
818-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/vulkan)
819-
endif()
820-
if(EXECUTORCH_BUILD_VGF)
821-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/arm)
822-
endif()
823-
824-
825845
if(EXECUTORCH_BUILD_ANDROID_JNI)
826846
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/android)
827847
endif()

backends/vulkan/CMakeLists.txt

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -122,27 +122,6 @@ executorch_target_link_options_shared_lib(vulkan_backend)
122122

123123
set_property(TARGET vulkan_backend PROPERTY CXX_STANDARD 17)
124124

125-
# Executor Runner
126-
127-
if(NOT CMAKE_TOOLCHAIN_FILE MATCHES ".*(iOS|ios\.toolchain)\.cmake$")
128-
set(VULKAN_RUNNER_SRCS ${_executor_runner__srcs})
129-
list(TRANSFORM VULKAN_RUNNER_SRCS PREPEND "${EXECUTORCH_ROOT}/")
130-
131-
set(VGF_BACKEND )
132-
if(EXECUTORCH_BUILD_VGF)
133-
set(VGF_BACKEND vgf_backend)
134-
endif()
135-
136-
add_executable(vulkan_executor_runner ${VULKAN_RUNNER_SRCS})
137-
target_link_libraries(
138-
vulkan_executor_runner ${_executor_runner_libs} vulkan_schema
139-
vulkan_backend
140-
${VGF_BACKEND}
141-
)
142-
143-
target_compile_options(vulkan_executor_runner PUBLIC ${VULKAN_CXX_FLAGS})
144-
endif()
145-
146125
# Test targets
147126

148127
install(

0 commit comments

Comments
 (0)