Skip to content

Commit e113c00

Browse files
authored
Move EXECUTORCH_PAL_DEFAULT to default preset (#10798)
### Summary TSIA ### Test plan CI + ``` $ cmake --preset macos-arm64 && cmake --build cmake-out --parallel ``` ``` $ cmake -DEXECUTORCH_PAL_DEFAULT=fake --preset macos-arm64 CMake Error at tools/cmake/preset/default.cmake:48 (message): PAL default implementation (fake) file not found: /Users/jathu/executorch/runtime/platform/default/fake.cpp Call Stack (most recent call first): CMakeLists.txt:53 (include) ``` cc @larryliu0820
1 parent b11807c commit e113c00

File tree

2 files changed

+29
-22
lines changed

2 files changed

+29
-22
lines changed

CMakeLists.txt

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,6 @@ else()
100100
set(_default_release_disabled_options ON)
101101
endif()
102102

103-
# Let users override which PAL defaults to use.
104-
#
105-
# TODO(dbort): Add another option that lets users point to a specific source
106-
# file; if set, would override the default option.
107-
set(EXECUTORCH_PAL_DEFAULT
108-
"posix"
109-
CACHE STRING
110-
"Which PAL default implementation to use: one of {posix, minimal}"
111-
)
112103

113104
if(NOT EXECUTORCH_ENABLE_LOGGING)
114105
# Avoid pulling in the logging strings, which can be large. Note that this
@@ -477,17 +468,7 @@ list(FILTER _executorch_core__srcs EXCLUDE REGEX
477468
)
478469

479470
# Add the source file that maps to the requested default PAL implementation.
480-
if(EXECUTORCH_PAL_DEFAULT MATCHES "^(posix|minimal)$")
481-
message(STATUS "executorch: Using PAL default '${EXECUTORCH_PAL_DEFAULT}'")
482-
list(APPEND _executorch_core__srcs
483-
"runtime/platform/default/${EXECUTORCH_PAL_DEFAULT}.cpp"
484-
)
485-
else()
486-
message(
487-
FATAL_ERROR "Unknown EXECUTORCH_PAL_DEFAULT \"${EXECUTORCH_PAL_DEFAULT}\". "
488-
"Expected one of {posix, minimal}."
489-
)
490-
endif()
471+
list(APPEND _executorch_core__srcs ${EXECUTORCH_PAL_DEFAULT_FILE_PATH})
491472

492473
add_library(executorch_core ${_executorch_core__srcs})
493474

tools/cmake/preset/default.cmake

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,36 @@ endif()
1414

1515
# MARK: - Overridable Options
1616

17-
define_overridable_option(EXECUTORCH_ENABLE_LOGGING "Build with ET_LOG_ENABLED" BOOL ${_is_build_type_debug})
18-
define_overridable_option(EXECUTORCH_BUILD_COREML "Build the Core ML backend" BOOL OFF)
17+
define_overridable_option(
18+
EXECUTORCH_ENABLE_LOGGING
19+
"Build with ET_LOG_ENABLED"
20+
BOOL ${_is_build_type_debug}
21+
)
22+
define_overridable_option(
23+
EXECUTORCH_BUILD_COREML
24+
"Build the Core ML backend"
25+
BOOL OFF
26+
)
1927
define_overridable_option(
2028
EXECUTORCH_FLATBUFFERS_MAX_ALIGNMENT
2129
"Exir lets users set the alignment of tensor data embedded in the flatbuffer, and some users need an alignment larger than the default, which is typically 32."
2230
STRING 1024
2331
)
32+
define_overridable_option(
33+
EXECUTORCH_PAL_DEFAULT
34+
"Which PAL default implementation to use. Choices: posix, minimal"
35+
STRING "posix"
36+
)
37+
define_overridable_option(
38+
EXECUTORCH_PAL_DEFAULT_FILE_PATH
39+
"PAL implementation file path"
40+
STRING "${PROJECT_SOURCE_DIR}/runtime/platform/default/${EXECUTORCH_PAL_DEFAULT}.cpp"
41+
)
42+
43+
44+
# MARK: - Validations
45+
# At this point all the options should be configured with their final value.
46+
47+
if(NOT EXISTS ${EXECUTORCH_PAL_DEFAULT_FILE_PATH})
48+
message(FATAL_ERROR "PAL default implementation (EXECUTORCH_PAL_DEFAULT=${EXECUTORCH_PAL_DEFAULT}) file not found: ${EXECUTORCH_PAL_DEFAULT_FILE_PATH}. Choices: posix, minimal")
49+
endif()

0 commit comments

Comments
 (0)