@@ -380,6 +380,12 @@ add_library(executorch_core ${_executorch_core__srcs})
380380# Legacy name alias.
381381add_library (executorch_no_prim_ops ALIAS executorch_core)
382382
383+ # A list of all configured backends.
384+ set (_executorch_backends "" )
385+
386+ # A list of all configured extensions.
387+ set (_executorch_extensions "" )
388+
383389target_link_libraries (executorch_core PRIVATE program_schema)
384390if (ANDROID)
385391 target_link_libraries (executorch_core PUBLIC log )
@@ -524,6 +530,7 @@ install(FILES tools/cmake/executorch-config.cmake
524530
525531if (EXECUTORCH_BUILD_ARM_BAREMETAL)
526532 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /backends/arm)
533+ list (APPEND _executorch_backends executorch_delegate_ethos_u)
527534endif ()
528535
529536if (EXECUTORCH_BUILD_CADENCE)
@@ -532,30 +539,37 @@ endif()
532539
533540if (EXECUTORCH_BUILD_NXP_NEUTRON)
534541 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /backends/nxp)
542+ list (APPEND _executorch_backends executorch_delegate_neutron)
535543endif ()
536544
537545if (EXECUTORCH_BUILD_COREML)
538546 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /backends/apple /coreml)
547+ list (APPEND _executorch_backends coremldelegate)
539548endif ()
540549
541550if (EXECUTORCH_BUILD_MPS)
542551 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /backends/apple /mps)
552+ list (APPEND _executorch_backends mpsdelegate)
543553endif ()
544554
545555if (EXECUTORCH_BUILD_NEURON)
546556 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /backends/mediatek)
557+ list (APPEND _executorch_backends neuron_backend)
547558endif ()
548559
549560if (EXECUTORCH_BUILD_OPENVINO)
550561 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /backends/openvino)
562+ list (APPEND _executorch_backends openvino_backend)
551563endif ()
552564
553565if (EXECUTORCH_BUILD_QNN)
554566 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /backends/qualcomm)
567+ list (APPEND _executorch_backends qnn_executorch_backend)
555568endif ()
556569
557570if (EXECUTORCH_BUILD_XNNPACK)
558571 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /backends/xnnpack)
572+ list (APPEND _executorch_backends xnnpack_backend)
559573endif ()
560574
561575if (EXECUTORCH_BUILD_CORTEX_M)
@@ -568,6 +582,7 @@ endif()
568582
569583if (EXECUTORCH_BUILD_EXTENSION_APPLE)
570584 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /extension/apple )
585+ list (APPEND _executorch_extensions apple_extension)
571586endif ()
572587
573588if (EXECUTORCH_BUILD_EXTENSION_DATA_LOADER)
@@ -578,6 +593,7 @@ if(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER)
578593 FILES_MATCHING
579594 PATTERN "*.h"
580595 )
596+ list (APPEND _executorch_extensions extension_data_loader)
581597endif ()
582598
583599if (EXECUTORCH_BUILD_EXTENSION_EVALUE_UTIL)
@@ -592,6 +608,7 @@ endif()
592608
593609if (EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR)
594610 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /extension/flat_tensor)
611+ list (APPEND _executorch_extensions extension_flat_tensor)
595612endif ()
596613
597614if (EXECUTORCH_BUILD_EXTENSION_MODULE)
@@ -602,6 +619,7 @@ if(EXECUTORCH_BUILD_EXTENSION_MODULE)
602619 FILES_MATCHING
603620 PATTERN "*.h"
604621 )
622+ list (APPEND _executorch_extensions extension_module_static)
605623endif ()
606624
607625if (EXECUTORCH_BUILD_EXTENSION_LLM)
@@ -621,14 +639,17 @@ if(EXECUTORCH_BUILD_EXTENSION_LLM)
621639 ${ORIGINAL_CMAKE_POSITION_INDEPENDENT_CODE_FLAG}
622640 )
623641 endif ()
642+ list (APPEND _executorch_extensions tokenizers)
624643endif ()
625644
626645if (EXECUTORCH_BUILD_EXTENSION_LLM_RUNNER)
627646 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /extension/llm/runner)
647+ list (APPEND _executorch_extensions extension_llm_runner)
628648endif ()
629649
630650if (EXECUTORCH_BUILD_EXTENSION_LLM_APPLE)
631651 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /extension/llm/apple )
652+ list (APPEND _executorch_extensions extension_llm_apple)
632653endif ()
633654
634655if (EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL)
@@ -639,10 +660,12 @@ if(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL)
639660 FILES_MATCHING
640661 PATTERN "*.h"
641662 )
663+ list (APPEND _executorch_extensions extension_runner_util)
642664endif ()
643665
644666if (EXECUTORCH_BUILD_EXTENSION_TENSOR)
645667 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /extension/tensor)
668+ list (APPEND _executorch_extensions extension_tensor)
646669endif ()
647670
648671if (EXECUTORCH_BUILD_PTHREADPOOL AND EXECUTORCH_BUILD_CPUINFO)
@@ -749,6 +772,7 @@ endif()
749772
750773if (EXECUTORCH_BUILD_EXTENSION_TRAINING)
751774 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /extension/training)
775+ list (APPEND _executorch_extensions extension_training)
752776endif ()
753777
754778if (EXECUTORCH_BUILD_KERNELS_LLM)
@@ -761,10 +785,32 @@ if(EXECUTORCH_BUILD_KERNELS_QUANTIZED)
761785 executorch_target_link_options_shared_lib(quantized_ops_lib)
762786endif ()
763787
788+ if (EXECUTORCH_BUILD_VULKAN)
789+ add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /backends/vulkan)
790+ list (APPEND _executorch_backends vulkan_backend vulkan_schema)
791+ endif ()
792+
793+ if (EXECUTORCH_BUILD_VGF)
794+ add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /backends/arm)
795+ list (APPEND _executorch_backends vgf_backend)
796+ endif ()
797+
798+ # Top-level interface targets.
799+
800+ # A target containing all configured backends.
801+ add_library (executorch_backends INTERFACE )
802+ add_library (executorch::backends ALIAS executorch_backends)
803+ target_link_libraries (executorch_backends INTERFACE ${_executorch_backends} )
804+
805+ # A target containing all configured extensions.
806+ add_library (executorch_extensions INTERFACE )
807+ add_library (executorch::extensions ALIAS executorch_extensions)
808+ target_link_libraries (executorch_extensions INTERFACE ${_executorch_extensions} )
809+
764810if (EXECUTORCH_BUILD_EXECUTOR_RUNNER)
765811 # Baseline libraries that executor_runner will link against.
766812 set (_executor_runner_libs executorch extension_evalue_util
767- extension_runner_util gflags
813+ extension_runner_util gflags executorch_backends
768814 )
769815
770816 if (EXECUTORCH_BUILD_KERNELS_OPTIMIZED)
@@ -784,18 +830,10 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
784830 list (APPEND _executor_runner_libs $<LINK_LIBRARY:WHOLE_ARCHIVE,custom_ops>)
785831 endif ()
786832
787- if (EXECUTORCH_BUILD_XNNPACK)
788- list (APPEND _executor_runner_libs xnnpack_backend)
789- endif ()
790-
791833 if (EXECUTORCH_ENABLE_EVENT_TRACER)
792834 list (APPEND _executor_runner_libs etdump flatccrt)
793835 endif ()
794836
795- if (EXECUTORCH_BUILD_COREML AND APPLE )
796- list (APPEND _executor_runner_libs coremldelegate)
797- endif ()
798-
799837 add_executable (executor_runner ${_executor_runner__srcs} )
800838 if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
801839 target_link_options_gc_sections(executor_runner)
@@ -818,14 +856,6 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
818856 endif ()
819857endif ()
820858
821- if (EXECUTORCH_BUILD_VULKAN)
822- add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /backends/vulkan)
823- endif ()
824- if (EXECUTORCH_BUILD_VGF)
825- add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /backends/arm)
826- endif ()
827-
828-
829859if (EXECUTORCH_BUILD_ANDROID_JNI)
830860 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /extension/android)
831861endif ()
0 commit comments