Skip to content

Commit 3b31b31

Browse files
committed
Add top-level CMake backends target
ghstack-source-id: 99dabf2 ghstack-comment-id: 3099241838 Pull-Request: #12689
1 parent 37e3003 commit 3b31b31

File tree

2 files changed

+37
-37
lines changed

2 files changed

+37
-37
lines changed

CMakeLists.txt

Lines changed: 37 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,36 @@ 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+
endif()
781+
782+
783+
# Top-level interface targets.
784+
add_library(executorch_backends INTERFACE)
785+
add_library(executorch::backends ALIAS executorch_backends)
786+
787+
# A target containing all configured backends.
788+
target_link_libraries(executorch_backends INTERFACE ${_executorch_backends})
789+
790+
install(
791+
TARGETS executorch_backends
792+
INCLUDES
793+
DESTINATION ${_common_include_directories}
794+
)
795+
760796
if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
761797
# Baseline libraries that executor_runner will link against.
762798
set(_executor_runner_libs executorch extension_evalue_util
763799
extension_runner_util gflags
800+
executorch_backends
764801
)
765802

766803
if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED)
@@ -780,18 +817,10 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
780817
list(APPEND _executor_runner_libs $<LINK_LIBRARY:WHOLE_ARCHIVE,custom_ops>)
781818
endif()
782819

783-
if(EXECUTORCH_BUILD_XNNPACK)
784-
list(APPEND _executor_runner_libs xnnpack_backend)
785-
endif()
786-
787820
if(EXECUTORCH_ENABLE_EVENT_TRACER)
788821
list(APPEND _executor_runner_libs etdump flatccrt)
789822
endif()
790823

791-
if(EXECUTORCH_BUILD_COREML AND APPLE)
792-
list(APPEND _executor_runner_libs coremldelegate)
793-
endif()
794-
795824
add_executable(executor_runner ${_executor_runner__srcs})
796825
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
797826
target_link_options_gc_sections(executor_runner)
@@ -814,14 +843,6 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
814843
endif()
815844
endif()
816845

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-
825846
if(EXECUTORCH_BUILD_ANDROID_JNI)
826847
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/android)
827848
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)