Skip to content
Merged
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 45 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,12 @@ add_library(executorch_core ${_executorch_core__srcs})
# Legacy name alias.
add_library(executorch_no_prim_ops ALIAS executorch_core)

# A list of all configured backends.
set(_executorch_backends "")

# A list of all configured extensions.
set(_executorch_extensions "")

target_link_libraries(executorch_core PRIVATE program_schema)
if(ANDROID)
target_link_libraries(executorch_core PUBLIC log)
Expand Down Expand Up @@ -494,6 +500,7 @@ install(FILES tools/cmake/Utils.cmake tools/cmake/executorch-config.cmake

if(EXECUTORCH_BUILD_ARM_BAREMETAL)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/arm)
list(APPEND _executorch_backends executorch_delegate_ethos_u)
endif()

if(EXECUTORCH_BUILD_CADENCE)
Expand All @@ -502,30 +509,37 @@ endif()

if(EXECUTORCH_BUILD_NXP_NEUTRON)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/nxp)
list(APPEND _executorch_backends executorch_delegate_neutron)
endif()

if(EXECUTORCH_BUILD_COREML)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/apple/coreml)
list(APPEND _executorch_backends coremldelegate)
endif()

if(EXECUTORCH_BUILD_MPS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/apple/mps)
list(APPEND _executorch_backends mpsdelegate)
endif()

if(EXECUTORCH_BUILD_NEURON)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/mediatek)
list(APPEND _executorch_backends neuron_backend)
endif()

if(EXECUTORCH_BUILD_OPENVINO)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/openvino)
list(APPEND _executorch_backends openvino_backend)
endif()

if(EXECUTORCH_BUILD_QNN)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/qualcomm)
list(APPEND _executorch_backends qnn_executorch_backend)
endif()

if(EXECUTORCH_BUILD_XNNPACK)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/xnnpack)
list(APPEND _executorch_backends xnnpack_backend)
endif()

if(EXECUTORCH_BUILD_CORTEX_M)
Expand All @@ -538,14 +552,17 @@ endif()

if(EXECUTORCH_BUILD_EXTENSION_APPLE)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/apple)
list(APPEND _executorch_extensions apple_extension)
endif()

if(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/data_loader)
list(APPEND _executorch_extensions extension_data_loader)
endif()

if(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/flat_tensor)
list(APPEND _executorch_extensions extension_flat_tensor)
endif()

if(EXECUTORCH_BUILD_EXTENSION_MODULE)
Expand All @@ -556,26 +573,32 @@ if(EXECUTORCH_BUILD_EXTENSION_MODULE)
FILES_MATCHING
PATTERN "*.h"
)
list(APPEND _executorch_extensions extension_module_static)
endif()

if(EXECUTORCH_BUILD_EXTENSION_LLM)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/llm/tokenizers)
list(APPEND _executorch_extensions tokenizers)
endif()

if(EXECUTORCH_BUILD_EXTENSION_LLM_APPLE)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/llm/apple)
list(APPEND _executorch_extensions extension_llm_apple)
endif()

if(EXECUTORCH_BUILD_EXTENSION_LLM_RUNNER)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/llm/runner)
list(APPEND _executorch_extensions extension_llm_runner)
endif()

if(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/runner_util)
list(APPEND _executorch_extensions extension_runner_util)
endif()

if(EXECUTORCH_BUILD_EXTENSION_TENSOR)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/tensor)
list(APPEND _executorch_extensions extension_tensor)
endif()

if(EXECUTORCH_BUILD_PTHREADPOOL AND EXECUTORCH_BUILD_CPUINFO)
Expand Down Expand Up @@ -677,6 +700,7 @@ endif()

if(EXECUTORCH_BUILD_EXTENSION_TRAINING)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/training)
list(APPEND _executorch_extensions extension_training)
endif()

if(EXECUTORCH_BUILD_KERNELS_LLM)
Expand All @@ -689,6 +713,27 @@ if(EXECUTORCH_BUILD_KERNELS_QUANTIZED)
target_link_options_shared_lib(quantized_ops_lib)
endif()

if(EXECUTORCH_BUILD_VULKAN)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/vulkan)
list(APPEND _executorch_backends vulkan_backend)
endif()

# Top-level interface targets.

# A target containing all configured backends.
add_library(executorch_backends INTERFACE)
target_link_libraries(executorch_backends INTERFACE ${_executorch_backends})

# A target containing all configured extensions.
add_library(executorch_extensions INTERFACE)
Copy link
Contributor

@swolchok swolchok Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please include executorch_backends and executorch_extensions in the install() call alongside executorch and executorch_core so that we don't have to coordinate with the EXPORT PR? that should be enough to get it to work no matter which one lands first

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated to install these targets. Because of the order of declarations in the file, I can't directly add to the existing executorch / executorch_core install, as it is above many of the backend declarations. To avoid causing a bunch of merge conflicts by rearranging it, I've added an install for these new targets alone. I can add the export directive once #8954 is merged.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you change an example to use these targets, CI will prevent us from messing it up in the future and give this diff coverage

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated executor_runner to use the top-level backends and extensions targets. I'll update examples with the export changes, as well.

target_link_libraries(executorch_extensions INTERFACE ${_executorch_extensions})

install(
TARGETS executorch_backends executorch_extensions
INCLUDES
DESTINATION ${_common_include_directories}
)

if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
# Baseline libraries that executor_runner will link against.
set(_executor_runner_libs executorch gflags)
Expand Down Expand Up @@ -741,10 +786,6 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
endif()
endif()

if(EXECUTORCH_BUILD_VULKAN)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/vulkan)
endif()

if(EXECUTORCH_BUILD_ANDROID_JNI)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/android)
endif()
Expand Down
Loading