@@ -59,6 +59,7 @@ print_configured_options()
5959
6060include (tools/cmake/Utils.cmake )
6161include (CMakeDependentOption )
62+ include (ExternalProject )
6263
6364set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
6465
@@ -99,15 +100,6 @@ else()
99100 set (_default_release_disabled_options ON )
100101endif ()
101102
102- # Let users override which PAL defaults to use.
103- #
104- # TODO(dbort): Add another option that lets users point to a specific source
105- # file; if set, would override the default option.
106- set (EXECUTORCH_PAL_DEFAULT
107- "posix"
108- CACHE STRING
109- "Which PAL default implementation to use: one of {posix, minimal}"
110- )
111103
112104if (NOT EXECUTORCH_ENABLE_LOGGING)
113105 # Avoid pulling in the logging strings, which can be large. Note that this
@@ -116,27 +108,7 @@ if(NOT EXECUTORCH_ENABLE_LOGGING)
116108 add_definitions (-DET_LOG_ENABLED=0 )
117109endif ()
118110
119- # Configure log level. Must be one of debug, info, error, fatal.
120- set (EXECUTORCH_LOG_LEVEL
121- "Info"
122- CACHE STRING "Build with the given ET_MIN_LOG_LEVEL value"
123- )
124- string (TOLOWER "${EXECUTORCH_LOG_LEVEL} " LOG_LEVEL_LOWER)
125- if (LOG_LEVEL_LOWER STREQUAL "debug" )
126- add_definitions (-DET_MIN_LOG_LEVEL=Debug )
127- elseif (LOG_LEVEL_LOWER STREQUAL "info" )
128- add_definitions (-DET_MIN_LOG_LEVEL=Info )
129- elseif (LOG_LEVEL_LOWER STREQUAL "error" )
130- add_definitions (-DET_MIN_LOG_LEVEL=Error )
131- elseif (LOG_LEVEL_LOWER STREQUAL "fatal" )
132- add_definitions (-DET_MIN_LOG_LEVEL=Fatal )
133- else ()
134- message (
135- SEND_ERROR
136- "Unknown log level \" ${EXECUTORCH_LOG_LEVEL} \" . Expected one of Debug, "
137- + "Info, Error, or Fatal."
138- )
139- endif ()
111+ add_definitions (-DET_MIN_LOG_LEVEL=${ET_MIN_LOG_LEVEL} )
140112
141113option (EXECUTORCH_ENABLE_PROGRAM_VERIFICATION
142114 "Build with ET_ENABLE_PROGRAM_VERIFICATION"
@@ -260,6 +232,8 @@ cmake_dependent_option(
260232 "NOT EXECUTORCH_BUILD_ARM_BAREMETAL" OFF
261233)
262234
235+ add_subdirectory (third-party )
236+
263237if (EXECUTORCH_BUILD_EXTENSION_TRAINING)
264238 set (EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON )
265239 set (EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON )
@@ -454,81 +428,6 @@ if(EXECUTORCH_USE_CPP_CODE_COVERAGE)
454428 endif ()
455429endif ()
456430
457- #
458- # flatc: Flatbuffer commandline tool to generate .h files from .fbs files
459- #
460- cmake_dependent_option (
461- EXECUTORCH_BUILD_FLATC "Build the flatc executable." ON
462- "NOT FLATC_EXECUTABLE" OFF
463- )
464-
465- set (FLATBUFFERS_BUILD_FLATC OFF CACHE BOOL "" )
466- set (FLATBUFFERS_BUILD_FLATHASH OFF CACHE BOOL "" )
467- set (FLATBUFFERS_BUILD_FLATLIB OFF CACHE BOOL "" )
468- set (FLATBUFFERS_BUILD_TESTS OFF CACHE BOOL "" )
469- set (FLATBUFFERS_INSTALL OFF CACHE BOOL "" )
470- # exir lets users set the alignment of tensor data embedded in the flatbuffer,
471- # and some users need an alignment larger than the default, which is typically
472- # 32.
473- set (FLATBUFFERS_MAX_ALIGNMENT 1024)
474-
475- if (EXECUTORCH_BUILD_FLATC)
476- if (FLATC_EXECUTABLE)
477- # We could ignore this, but it could lead to confusion about which `flatc`
478- # is actually being used.
479- message (
480- FATAL_ERROR "May not set both EXECUTORCH_BUILD_FLATC and FLATC_EXECUTABLE"
481- )
482- endif ()
483-
484- # Build flatc for the *host* to generate files as part of the build step.
485- include (ExternalProject )
486- ExternalProject_Add (
487- flatbuffers
488- PREFIX ${CMAKE_CURRENT_BINARY_DIR } /third-party/flatbuffers
489- BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR } /third-party/flatbuffers
490- SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR } /third-party/flatbuffers
491- CMAKE_ARGS -DFLATBUFFERS_BUILD_FLATC=ON
492- -DFLATBUFFERS_BUILD_FLATHASH=${FLATBUFFERS_BUILD_FLATHASH}
493- -DFLATBUFFERS_BUILD_FLATLIB=${FLATBUFFERS_BUILD_FLATLIB}
494- -DFLATBUFFERS_BUILD_TESTS=${FLATBUFFERS_BUILD_TESTS}
495- -DFLATBUFFERS_INSTALL=${FLATBUFFERS_INSTALL}
496- -DCMAKE_CXX_FLAGS="-DFLATBUFFERS_MAX_ALIGNMENT=${FLATBUFFERS_MAX_ALIGNMENT} "
497- # If building for iOS, "unset" these variables to rely on the host (macOS) defaults.
498- $<$<AND :$<BOOL :${CMAKE_TOOLCHAIN_IOS} >,$<BOOL :$<FILTER :${PLATFORM} ,EXCLUDE ,^MAC >>>:-DCMAKE_OSX_SYSROOT =>
499- INSTALL_COMMAND ""
500- BUILD_BYPRODUCTS <BINARY_DIR >/flatc
501- )
502- ExternalProject_Get_Property (flatbuffers BINARY_DIR )
503- if (WIN32 )
504- # flatbuffers does not use CMAKE_BUILD_TYPE. Internally, the build forces Release
505- # config, but from CMake's perspective the build type is always Debug.
506- set (FLATC_EXECUTABLE ${BINARY_DIR} /$<CONFIG >/flatc.exe)
507- elseif (CMAKE_GENERATOR STREQUAL "Xcode" )
508- set (FLATC_EXECUTABLE ${BINARY_DIR} /$<CONFIG >/flatc)
509- else ()
510- set (FLATC_EXECUTABLE ${BINARY_DIR} /flatc)
511- endif ()
512- set (FLATC_EXECUTABLE_BUILT_FROM_SOURCE YES )
513- endif ()
514-
515- if (NOT FLATC_EXECUTABLE)
516- message (
517- WARNING "FLATC_EXECUTABLE not specified, looking for flatc"
518- )
519- find_program (FLATC_EXECUTABLE flatc )
520-
521- if (NOT FLATC_EXECUTABLE)
522- message (FATAL_ERROR "FLATC_EXECUTABLE must be set when EXECUTORCH_BUILD_FLATC is disabled." )
523- endif ()
524- endif ()
525-
526- add_executable (flatc IMPORTED GLOBAL )
527- set_target_properties (flatc PROPERTIES IMPORTED_LOCATION ${FLATC_EXECUTABLE} )
528-
529- if (FLATC_EXECUTABLE_BUILT_FROM_SOURCE)
530- add_dependencies (flatc flatbuffers )
531- endif ()
532431
533432#
534433# program_schema: Generated .h files from schema/*.fbs inputs
@@ -549,17 +448,7 @@ list(FILTER _executorch_core__srcs EXCLUDE REGEX
549448)
550449
551450# Add the source file that maps to the requested default PAL implementation.
552- if (EXECUTORCH_PAL_DEFAULT MATCHES "^(posix|minimal)$" )
553- message (STATUS "executorch: Using PAL default '${EXECUTORCH_PAL_DEFAULT} '" )
554- list (APPEND _executorch_core__srcs
555- "runtime/platform/default/${EXECUTORCH_PAL_DEFAULT} .cpp"
556- )
557- else ()
558- message (
559- FATAL_ERROR "Unknown EXECUTORCH_PAL_DEFAULT \" ${EXECUTORCH_PAL_DEFAULT} \" . "
560- "Expected one of {posix, minimal}."
561- )
562- endif ()
451+ list (APPEND _executorch_core__srcs ${EXECUTORCH_PAL_DEFAULT_FILE_PATH} )
563452
564453add_library (executorch_core ${_executorch_core__srcs} )
565454
@@ -638,6 +527,8 @@ if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED)
638527 find_package_torch_headers ()
639528endif ()
640529
530+ add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR } /kernels/portable/cpu/util )
531+
641532if (BUILD_EXECUTORCH_PORTABLE_OPS)
642533 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR } /kernels/portable )
643534endif ()
0 commit comments