@@ -48,12 +48,18 @@ project(executorch)
4848# MARK: - Start EXECUTORCH_H12025_BUILD_MIGRATION --------------------------------------------------
4949
5050include (${PROJECT_SOURCE_DIR} /tools/cmake/common/preset.cmake)
51+
52+ load_build_preset()
5153include (${PROJECT_SOURCE_DIR} /tools/cmake/preset/default.cmake)
5254
55+ # Print all the configs that were called with announce_configured_options.
56+ print_configured_options()
57+
5358# MARK: - End EXECUTORCH_H12025_BUILD_MIGRATION ----------------------------------------------------
5459
5560include (tools/cmake/Utils.cmake)
5661include (CMakeDependentOption)
62+ include (ExternalProject)
5763
5864set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
5965
@@ -175,8 +181,6 @@ option(EXECUTORCH_BUILD_ARM_BAREMETAL
175181 "Build the Arm Baremetal flow for Cortex-M and Ethos-U" OFF
176182)
177183
178- option (EXECUTORCH_BUILD_COREML "Build the Core ML backend" OFF )
179-
180184option (EXECUTORCH_BUILD_KERNELS_CUSTOM "Build the custom kernels" OFF )
181185
182186option (EXECUTORCH_BUILD_KERNELS_CUSTOM_AOT "Build the custom ops lib for AOT"
@@ -239,6 +243,8 @@ option(EXECUTORCH_USE_DL "Use libdl library" ON)
239243
240244option (EXECUTORCH_BUILD_CADENCE "Build the Cadence DSP backend" OFF )
241245
246+ option (EXECUTORCH_BUILD_CORTEX_M "Build the Cortex-M backend" OFF )
247+
242248#
243249# pthreadpool: build pthreadpool library. Disable on unsupported platforms
244250#
@@ -255,6 +261,8 @@ cmake_dependent_option(
255261 "NOT EXECUTORCH_BUILD_ARM_BAREMETAL" OFF
256262)
257263
264+ add_subdirectory (third-party)
265+
258266if (EXECUTORCH_BUILD_EXTENSION_TRAINING)
259267 set (EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON )
260268 set (EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON )
@@ -449,81 +457,6 @@ if(EXECUTORCH_USE_CPP_CODE_COVERAGE)
449457 endif ()
450458endif ()
451459
452- #
453- # flatc: Flatbuffer commandline tool to generate .h files from .fbs files
454- #
455- cmake_dependent_option(
456- EXECUTORCH_BUILD_FLATC "Build the flatc executable." ON
457- "NOT FLATC_EXECUTABLE" OFF
458- )
459-
460- set (FLATBUFFERS_BUILD_FLATC OFF CACHE BOOL "" )
461- set (FLATBUFFERS_BUILD_FLATHASH OFF CACHE BOOL "" )
462- set (FLATBUFFERS_BUILD_FLATLIB OFF CACHE BOOL "" )
463- set (FLATBUFFERS_BUILD_TESTS OFF CACHE BOOL "" )
464- set (FLATBUFFERS_INSTALL OFF CACHE BOOL "" )
465- # exir lets users set the alignment of tensor data embedded in the flatbuffer,
466- # and some users need an alignment larger than the default, which is typically
467- # 32.
468- set (FLATBUFFERS_MAX_ALIGNMENT 1024)
469-
470- if (EXECUTORCH_BUILD_FLATC)
471- if (FLATC_EXECUTABLE)
472- # We could ignore this, but it could lead to confusion about which `flatc`
473- # is actually being used.
474- message (
475- FATAL_ERROR "May not set both EXECUTORCH_BUILD_FLATC and FLATC_EXECUTABLE"
476- )
477- endif ()
478-
479- # Build flatc for the *host* to generate files as part of the build step.
480- include (ExternalProject)
481- ExternalProject_Add(
482- flatbuffers
483- PREFIX ${CMAKE_CURRENT_BINARY_DIR} /third-party/flatbuffers
484- BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} /third-party/flatbuffers
485- SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} /third-party/flatbuffers
486- CMAKE_ARGS -DFLATBUFFERS_BUILD_FLATC=ON
487- -DFLATBUFFERS_BUILD_FLATHASH=${FLATBUFFERS_BUILD_FLATHASH}
488- -DFLATBUFFERS_BUILD_FLATLIB=${FLATBUFFERS_BUILD_FLATLIB}
489- -DFLATBUFFERS_BUILD_TESTS=${FLATBUFFERS_BUILD_TESTS}
490- -DFLATBUFFERS_INSTALL=${FLATBUFFERS_INSTALL}
491- -DCMAKE_CXX_FLAGS="-DFLATBUFFERS_MAX_ALIGNMENT=${FLATBUFFERS_MAX_ALIGNMENT} "
492- # If building for iOS, "unset" these variables to rely on the host (macOS) defaults.
493- $<$<AND :$<BOOL :${CMAKE_TOOLCHAIN_IOS} >,$<BOOL :$<FILTER :${PLATFORM} ,EXCLUDE ,^MAC>>>:-DCMAKE_OSX_SYSROOT=>
494- INSTALL_COMMAND ""
495- BUILD_BYPRODUCTS <BINARY_DIR>/flatc
496- )
497- ExternalProject_Get_Property(flatbuffers BINARY_DIR)
498- if (WIN32 )
499- # flatbuffers does not use CMAKE_BUILD_TYPE. Internally, the build forces Release
500- # config, but from CMake's perspective the build type is always Debug.
501- set (FLATC_EXECUTABLE ${BINARY_DIR} /$<CONFIG>/flatc.exe)
502- elseif (CMAKE_GENERATOR STREQUAL "Xcode" )
503- set (FLATC_EXECUTABLE ${BINARY_DIR} /$<CONFIG>/flatc)
504- else ()
505- set (FLATC_EXECUTABLE ${BINARY_DIR} /flatc)
506- endif ()
507- set (FLATC_EXECUTABLE_BUILT_FROM_SOURCE YES )
508- endif ()
509-
510- if (NOT FLATC_EXECUTABLE)
511- message (
512- WARNING "FLATC_EXECUTABLE not specified, looking for flatc"
513- )
514- find_program (FLATC_EXECUTABLE flatc)
515-
516- if (NOT FLATC_EXECUTABLE)
517- message (FATAL_ERROR "FLATC_EXECUTABLE must be set when EXECUTORCH_BUILD_FLATC is disabled." )
518- endif ()
519- endif ()
520-
521- add_executable (flatc IMPORTED GLOBAL )
522- set_target_properties (flatc PROPERTIES IMPORTED_LOCATION ${FLATC_EXECUTABLE} )
523-
524- if (FLATC_EXECUTABLE_BUILT_FROM_SOURCE)
525- add_dependencies (flatc flatbuffers)
526- endif ()
527460
528461#
529462# program_schema: Generated .h files from schema/*.fbs inputs
@@ -712,6 +645,10 @@ if(EXECUTORCH_BUILD_XNNPACK)
712645 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /backends/xnnpack)
713646endif ()
714647
648+ if (EXECUTORCH_BUILD_CORTEX_M)
649+ add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /backends/cortex_m)
650+ endif ()
651+
715652if (EXECUTORCH_BUILD_DEVTOOLS)
716653 if (NOT EXECUTORCH_BUILD_ARM_BAREMETAL)
717654 set (EXECUTORCH_BUILD_EXTENSION_DATA_LOADER
0 commit comments