Skip to content

Commit e3fba22

Browse files
committed
✨ Simplify CMake build configuration and validation logic.
1 parent 28bcb5d commit e3fba22

File tree

2 files changed

+65
-35
lines changed

2 files changed

+65
-35
lines changed

CMakeLists.txt

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -152,37 +152,11 @@ else()
152152
endif()
153153

154154
if(EXECUTORCH_BUILD_TESTS)
155-
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
156155
include(CTest)
157156
endif()
158157

159158
add_subdirectory(third-party)
160159

161-
if(EXECUTORCH_BUILD_EXTENSION_TRAINING)
162-
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
163-
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
164-
set(EXECUTORCH_BUILD_EXTENSION_MODULE ON)
165-
set(EXECUTORCH_BUILD_EXTENSION_TENSOR ON)
166-
endif()
167-
168-
if(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR)
169-
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
170-
endif()
171-
172-
if(EXECUTORCH_BUILD_EXTENSION_MODULE)
173-
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
174-
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
175-
endif()
176-
177-
if(EXECUTORCH_BUILD_KERNELS_CUSTOM_AOT)
178-
set(EXECUTORCH_BUILD_EXTENSION_TENSOR ON)
179-
set(EXECUTORCH_BUILD_KERNELS_CUSTOM ON)
180-
endif()
181-
182-
if(EXECUTORCH_BUILD_KERNELS_CUSTOM)
183-
set(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON)
184-
endif()
185-
186160
if(NOT DEFINED FXDIV_SOURCE_DIR)
187161
set(ORIGINAL_CMAKE_POSITION_INDEPENDENT_CODE_FLAG
188162
${CMAKE_POSITION_INDEPENDENT_CODE}
@@ -336,7 +310,7 @@ if(EXECUTORCH_USE_CPP_CODE_COVERAGE)
336310
" -fprofile-instr-generate -fcoverage-mapping"
337311
)
338312
else()
339-
message(ERROR
313+
message(FATAL_ERROR
340314
"Code coverage for compiler ${CMAKE_CXX_COMPILER_ID} is unsupported"
341315
)
342316
endif()

tools/cmake/preset/default.cmake

Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,72 @@ define_overridable_option(
276276
"Enable weights cache to cache and manage all packed weights"
277277
BOOL OFF
278278
)
279+
define_overridable_option(
280+
EXECUTORCH_USE_CPP_CODE_COVERAGE
281+
"Build with code coverage enabled"
282+
BOOL OFF
283+
)
279284

280-
# MARK: - Validations
285+
# ------------------------------------------------------------------------------
286+
# Validations!
287+
#
281288
# At this point all the options should be configured with their final value.
289+
# ------------------------------------------------------------------------------
290+
291+
check_required_options_on(
292+
IF_ON
293+
EXECUTORCH_ENABLE_EVENT_TRACER
294+
REQUIRES
295+
EXECUTORCH_BUILD_DEVTOOLS
296+
)
297+
298+
check_required_options_on(
299+
IF_ON
300+
EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR
301+
REQUIRES
302+
EXECUTORCH_BUILD_EXTENSION_DATA_LOADER
303+
)
304+
305+
check_required_options_on(
306+
IF_ON
307+
EXECUTORCH_BUILD_EXTENSION_MODULE
308+
REQUIRES
309+
EXECUTORCH_BUILD_EXTENSION_DATA_LOADER
310+
EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR
311+
)
312+
313+
check_required_options_on(
314+
IF_ON
315+
EXECUTORCH_BUILD_KERNELS_CUSTOM
316+
REQUIRES
317+
EXECUTORCH_BUILD_KERNELS_OPTIMIZED
318+
)
319+
320+
check_required_options_on(
321+
IF_ON
322+
EXECUTORCH_BUILD_KERNELS_CUSTOM_AOT
323+
REQUIRES
324+
EXECUTORCH_BUILD_EXTENSION_TENSOR
325+
EXECUTORCH_BUILD_KERNELS_CUSTOM
326+
)
327+
328+
check_required_options_on(
329+
IF_ON
330+
EXECUTORCH_BUILD_EXTENSION_TRAINING
331+
REQUIRES
332+
EXECUTORCH_BUILD_EXTENSION_DATA_LOADER
333+
EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR
334+
EXECUTORCH_BUILD_EXTENSION_MODULE
335+
EXECUTORCH_BUILD_EXTENSION_TENSOR
336+
)
337+
338+
check_required_options_on(
339+
IF_ON
340+
EXECUTORCH_BUILD_TESTS
341+
REQUIRES
342+
EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR
343+
)
344+
282345

283346
if(NOT EXISTS ${EXECUTORCH_PAL_DEFAULT_FILE_PATH})
284347
message(FATAL_ERROR "PAL default implementation (EXECUTORCH_PAL_DEFAULT=${EXECUTORCH_PAL_DEFAULT}) file not found: ${EXECUTORCH_PAL_DEFAULT_FILE_PATH}. Choices: posix, minimal, android")
@@ -299,13 +362,6 @@ else()
299362
endif()
300363

301364

302-
if(EXECUTORCH_ENABLE_EVENT_TRACER)
303-
if(NOT EXECUTORCH_BUILD_DEVTOOLS)
304-
message(FATAL_ERROR "Use of 'EXECUTORCH_ENABLE_EVENT_TRACER' requires 'EXECUTORCH_BUILD_DEVTOOLS' to be enabled.")
305-
endif()
306-
endif()
307-
308-
309365
if(EXECUTORCH_BUILD_ARM_BAREMETAL)
310366
if(EXECUTORCH_BUILD_PTHREADPOOL)
311367
message(FATAL_ERROR "Cannot enable both EXECUTORCH_BUILD_PTHREADPOOL and EXECUTORCH_BUILD_ARM_BAREMETAL")

0 commit comments

Comments
 (0)