@@ -13,11 +13,8 @@ if(NOT EXECUTORCH_ROOT)
1313endif ()
1414
1515include (${EXECUTORCH_ROOT} /tools/cmake/Utils.cmake )
16-
17- if (POLICY CMP0169)
18- # Allow FetchContent_Populate to be used for source-only fetch
19- cmake_policy (SET CMP0169 OLD )
20- endif ()
16+ include (${EXECUTORCH_ROOT} /backends/arm/scripts/corstone_utils.cmake )
17+ include (${EXECUTORCH_ROOT} /backends/arm/cmake/ArmEthosUSDK.cmake )
2118
2219set (_common_include_directories
2320 ${EXECUTORCH_ROOT} /.. ${EXECUTORCH_ROOT} /runtime/core/portable_type/c10
@@ -43,7 +40,13 @@ set(ETHOS_SDK_PATH
4340 "${EXECUTORCH_ROOT} /examples/arm/arm-scratch/ethos-u"
4441 CACHE PATH "Path to Ethos-U bare metal driver/env"
4542)
46- option (FETCH_ETHOS_U_CONTENT "Fetch ethos_u dependencies" ON )
43+ # Set default value of FETCH_ETHOS_U_CONTENT depending on whether ethos sdk is
44+ # available in $ETHOS_SDK_PATH.
45+ arm_ethos_u_default_fetch ("${ETHOS_SDK_PATH} " _fetch_ethos_u_default )
46+ option (FETCH_ETHOS_U_CONTENT
47+ "Fetch ethos_u dependencies instead of relying on pre-downloads"
48+ ${_fetch_ethos_u_default}
49+ )
4750
4851if (EXECUTORCH_BUILD_ARM_BAREMETAL AND EXECUTORCH_BUILD_ARM_ETHOSU_LINUX)
4952 message (
@@ -75,10 +78,9 @@ if(EXECUTORCH_BUILD_ARM_BAREMETAL OR EXECUTORCH_BUILD_ARM_ETHOSU_LINUX)
7578 executorch_delegate_ethos_u
7679 PRIVATE ${EXECUTORCH_ROOT} /backends/arm/runtime/EthosUBackend_Cortex_M.cpp
7780 )
78- include (${EXECUTORCH_ROOT} /backends/arm/scripts/corstone_utils.cmake )
79- if (FETCH_ETHOS_U_CONTENT)
80- fetch_ethos_u_content (${ETHOS_SDK_PATH} ${EXECUTORCH_ROOT} )
81- endif ()
81+ arm_ensure_ethos_u_content (
82+ "${ETHOS_SDK_PATH} " "${EXECUTORCH_ROOT} " ${FETCH_ETHOS_U_CONTENT}
83+ )
8284 set (DRIVER_ETHOSU_INCLUDE_DIR
8385 "${ETHOS_SDK_PATH} /core_software/core_driver/include"
8486 )
@@ -108,11 +110,11 @@ if(EXECUTORCH_BUILD_ARM_BAREMETAL OR EXECUTORCH_BUILD_ARM_ETHOSU_LINUX)
108110 GIT_REPOSITORY ${ETHOSU_LINUX_DRIVER_GIT_REPO}
109111 GIT_TAG ${ETHOSU_LINUX_DRIVER_GIT_TAG}
110112 GIT_SHALLOW TRUE
113+ # Point FetchContent at a nonexistent source subdirectory, tricking it
114+ # into downloading the sources without adding the project to the build.
115+ SOURCE_SUBDIR none
111116 )
112- FetchContent_GetProperties (ethosu_linux_driver_src)
113- if (NOT ethosu_linux_driver_src_POPULATED)
114- FetchContent_Populate (ethosu_linux_driver_src)
115- endif ()
117+ FetchContent_MakeAvailable (ethosu_linux_driver_src)
116118 set (ETHOSU_LINUX_DRIVER_SOURCE_DIR ${ethosu_linux_driver_src_SOURCE_DIR } )
117119 endif ()
118120
0 commit comments