Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
26 changes: 23 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# Copyright 2024-2025 Arm Limited and/or its affiliates.
# Copyright 2024-2026 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -614,8 +614,14 @@ install(FILES tools/cmake/executorch-config.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ExecuTorch
)

if(EXECUTORCH_BUILD_ARM_BAREMETAL)
if(EXECUTORCH_BUILD_ARM_BAREMETAL
OR EXECUTORCH_BUILD_ARM_ETHOSU_LINUX
OR EXECUTORCH_BUILD_VGF
)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/arm)
endif()

if(EXECUTORCH_BUILD_ARM_BAREMETAL OR EXECUTORCH_BUILD_ARM_ETHOSU_LINUX)
list(APPEND _executorch_backends executorch_delegate_ethos_u)
endif()

Expand Down Expand Up @@ -1063,7 +1069,6 @@ if(EXECUTORCH_BUILD_VULKAN)
endif()

if(EXECUTORCH_BUILD_VGF)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/arm)
list(APPEND _executorch_backends vgf_backend)
endif()

Expand Down Expand Up @@ -1197,6 +1202,21 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
endif()
target_link_libraries(executor_runner ${_executor_runner_libs})
target_compile_options(executor_runner PUBLIC ${_common_compile_options})
if(EXECUTORCH_BUILD_ARM_ETHOSU_LINUX)
target_sources(
executor_runner
PRIVATE
${CMAKE_SOURCE_DIR}/examples/arm/executor_runner/ethosu_link_helper.cpp
)
target_compile_definitions(
executor_runner PRIVATE EXECUTORCH_BUILD_ARM_ETHOSU_LINUX=1
)
# Wrap static linking like the delegate_runner to keep images
# self-contained.
target_link_options(
executor_runner PRIVATE -static-libstdc++ -static-libgcc
)
endif()

# Automatically set when using `emcmake cmake` for Wasm build.
if(EMSCRIPTEN)
Expand Down
96 changes: 81 additions & 15 deletions backends/arm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,102 @@ endif()

include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)

if(POLICY CMP0169)
# Allow FetchContent_Populate to be used for source-only fetch
cmake_policy(SET CMP0169 OLD)
endif()

Comment on lines +17 to +21
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

Forcing CMP0169 to OLD opts into deprecated FetchContent_Populate behavior and can cause policy warnings or future breakage. Prefer updating the FetchContent usage to the NEW behavior (e.g., FetchContent_MakeAvailable / modern pattern) so you don’t need to change the policy globally for this directory.

Suggested change
if(POLICY CMP0169)
# Allow FetchContent_Populate to be used for source-only fetch
cmake_policy(SET CMP0169 OLD)
endif()

Copilot uses AI. Check for mistakes.
set(_common_include_directories
${EXECUTORCH_ROOT}/.. ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
)
add_compile_definitions(C10_USING_CUSTOM_GENERATED_MACROS)

# bare metal backend builds
if(EXECUTORCH_BUILD_ARM_BAREMETAL)
set(ETHOSU_LINUX_DRIVER_GIT_REPO
"https://gitlab.arm.com/artificial-intelligence/ethos-u/ethos-u-linux-driver-stack.git"
CACHE STRING "Git repository that hosts the Ethos-U Linux driver stack"
)
set(ETHOSU_LINUX_DRIVER_GIT_TAG
"25.11"
CACHE STRING
"Git tag/branch/commit used to fetch the Ethos-U Linux driver stack"
)
set(ETHOSU_LINUX_DRIVER_SOURCE_DIR
""
CACHE
PATH
"Optional local path to an existing ethos-u-linux-driver stack checkout"
)

if(EXECUTORCH_BUILD_ARM_BAREMETAL AND EXECUTORCH_BUILD_ARM_ETHOSU_LINUX)
message(
FATAL_ERROR
"EXECUTORCH_BUILD_ARM_BAREMETAL and EXECUTORCH_BUILD_ARM_ETHOSU_LINUX cannot be enabled at the same time."
)
endif()

# Ethos-U backend builds (bare metal or Linux driver stack)
if(EXECUTORCH_BUILD_ARM_BAREMETAL OR EXECUTORCH_BUILD_ARM_ETHOSU_LINUX)

add_compile_options("-Wall" "-Werror")

# Third-party folder and Ethos-U driver inclued
set(THIRD_PARTY_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/third-party")
set(DRIVER_ETHOSU_INCLUDE_DIR
"${THIRD_PARTY_ROOT}/ethos-u-core-driver/include"
)
include_directories(${DRIVER_ETHOSU_INCLUDE_DIR})

set(_arm_baremetal_sources backends/arm/runtime/EthosUBackend.cpp
backends/arm/runtime/VelaBinStream.cpp
set(_arm_backend_sources backends/arm/runtime/EthosUBackend.cpp
backends/arm/runtime/VelaBinStream.cpp
)
list(TRANSFORM _arm_baremetal_sources PREPEND "${EXECUTORCH_ROOT}/")
list(TRANSFORM _arm_backend_sources PREPEND "${EXECUTORCH_ROOT}/")

add_library(executorch_delegate_ethos_u STATIC ${_arm_baremetal_sources})
target_link_libraries(
executorch_delegate_ethos_u PUBLIC executorch_core ethosu_core_driver
)
add_library(executorch_delegate_ethos_u STATIC ${_arm_backend_sources})
target_link_libraries(executorch_delegate_ethos_u PUBLIC executorch_core)

if(EXECUTORCH_BUILD_ARM_BAREMETAL)
target_sources(
executorch_delegate_ethos_u
PRIVATE ${EXECUTORCH_ROOT}/backends/arm/runtime/EthosUBackend_Cortex_M.cpp
)
set(DRIVER_ETHOSU_INCLUDE_DIR
"${THIRD_PARTY_ROOT}/ethos-u-core-driver/include"
)
target_include_directories(
executorch_delegate_ethos_u PRIVATE ${DRIVER_ETHOSU_INCLUDE_DIR}
)
target_link_libraries(executorch_delegate_ethos_u PUBLIC ethosu_core_driver)
elseif(EXECUTORCH_BUILD_ARM_ETHOSU_LINUX)
target_sources(
executorch_delegate_ethos_u
PRIVATE ${EXECUTORCH_ROOT}/backends/arm/runtime/EthosUBackend_Cortex_A.cpp
)
if(NOT ETHOSU_LINUX_DRIVER_SOURCE_DIR
OR NOT EXISTS
"${ETHOSU_LINUX_DRIVER_SOURCE_DIR}/driver_library/src/ethosu.cpp"
)
include(FetchContent)
FetchContent_Declare(
ethosu_linux_driver_src
GIT_REPOSITORY ${ETHOSU_LINUX_DRIVER_GIT_REPO}
GIT_TAG ${ETHOSU_LINUX_DRIVER_GIT_TAG}
GIT_SHALLOW TRUE
)
FetchContent_GetProperties(ethosu_linux_driver_src)
if(NOT ethosu_linux_driver_src_POPULATED)
FetchContent_Populate(ethosu_linux_driver_src)
endif()
set(ETHOSU_LINUX_DRIVER_SOURCE_DIR ${ethosu_linux_driver_src_SOURCE_DIR})
endif()

target_include_directories(
executorch_delegate_ethos_u
PRIVATE ${ETHOSU_LINUX_DRIVER_SOURCE_DIR}/driver_library/include
${ETHOSU_LINUX_DRIVER_SOURCE_DIR}/kernel/include
)
target_sources(
executorch_delegate_ethos_u
PRIVATE ${ETHOSU_LINUX_DRIVER_SOURCE_DIR}/driver_library/src/ethosu.cpp
)
endif()

install(TARGETS executorch_delegate_ethos_u EXPORT ExecuTorchTargets)

# end config for bare metal builds
endif()

# VGF backend builds
Expand Down
Loading
Loading