Skip to content

Commit 0013de9

Browse files
shoumikhinfacebook-github-bot
authored andcommitted
Consolidate build options. (#2614)
Summary: bypass-github-export-checks Reviewed By: kirklandsign Differential Revision: D55263460
1 parent 5919212 commit 0013de9

File tree

1 file changed

+67
-71
lines changed

1 file changed

+67
-71
lines changed

CMakeLists.txt

Lines changed: 67 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ if(NOT EXECUTORCH_ENABLE_LOGGING)
7878
endif()
7979

8080
# Configure log level. Must be one of debug, info, error, fatal.
81-
set(EXECUTORCH_LOG_LEVEL "Info" CACHE STRING
82-
"Build with the given ET_MIN_LOG_LEVEL value")
81+
set(EXECUTORCH_LOG_LEVEL
82+
"Info"
83+
CACHE STRING "Build with the given ET_MIN_LOG_LEVEL value")
8384
string(TOLOWER "${EXECUTORCH_LOG_LEVEL}" LOG_LEVEL_LOWER)
8485
if(LOG_LEVEL_LOWER STREQUAL "debug")
8586
add_definitions(-DET_MIN_LOG_LEVEL=Debug)
@@ -90,9 +91,10 @@ elseif(LOG_LEVEL_LOWER STREQUAL "error")
9091
elseif(LOG_LEVEL_LOWER STREQUAL "fatal")
9192
add_definitions(-DET_MIN_LOG_LEVEL=Fatal)
9293
else()
93-
message(SEND_ERROR
94-
"Unknown log level \"${EXECUTORCH_LOG_LEVEL}\". Expected one of Debug, " +
95-
"Info, Error, or Fatal.")
94+
message(
95+
SEND_ERROR
96+
"Unknown log level \"${EXECUTORCH_LOG_LEVEL}\". Expected one of Debug, "
97+
+ "Info, Error, or Fatal.")
9698
endif()
9799

98100
option(EXECUTORCH_ENABLE_PROGRAM_VERIFICATION
@@ -105,16 +107,15 @@ if(NOT EXECUTORCH_ENABLE_PROGRAM_VERIFICATION)
105107
add_definitions(-DET_ENABLE_PROGRAM_VERIFICATION=0)
106108
endif()
107109

108-
option(EXECUTORCH_ENABLE_EVENT_TRACER
109-
"Build with ET_EVENT_TRACER_ENABLED=ON"
110+
option(EXECUTORCH_ENABLE_EVENT_TRACER "Build with ET_EVENT_TRACER_ENABLED=ON"
110111
OFF)
111112
if(EXECUTORCH_ENABLE_EVENT_TRACER)
112113
add_definitions(-DET_EVENT_TRACER_ENABLED)
113114
endif()
114115

115-
# -ffunction-sections -fdata-sections: breaks function and
116-
# data into sections so they can be properly gc'd. -s: strip symbol.
117-
# -fno-exceptions -fno-rtti: disables exceptions and runtime type.
116+
# -ffunction-sections -fdata-sections: breaks function and data into sections so
117+
# they can be properly gc'd. -s: strip symbol. -fno-exceptions -fno-rtti:
118+
# disables exceptions and runtime type.
118119
set(CMAKE_CXX_FLAGS_RELEASE
119120
"-ffunction-sections -fdata-sections -fno-exceptions -fno-rtti")
120121
if(NOT APPLE)
@@ -132,47 +133,40 @@ endif()
132133

133134
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
134135

135-
# Option to register quantized ops with quantized kernels. See
136-
# kernels/quantized/CMakeLists.txt
137-
option(REGISTER_QUANTIZED_OPS
138-
"Register quantized ops defined in kernels/quantized/" OFF)
136+
option(EXECUTORCH_BUILD_ANDROID_JNI "Build Android JNI" OFF)
137+
138+
option(EXECUTORCH_BUILD_ARM_BAREMETAL
139+
"Build the Arm Baremetal flow for Cortex-M and Ethos-U" OFF)
139140

140-
option(EXECUTORCH_BUILD_SIZE_TEST "Whether to build size test" OFF)
141+
option(EXECUTORCH_BUILD_COREML "Build the Core ML backend" OFF)
141142

142-
# Build xnn_executor_runner which depends on XNNPACK
143-
option(EXECUTORCH_BUILD_XNNPACK
144-
"Build xnn_executor_runner which depends on XNNPACK" OFF)
143+
option(EXECUTORCH_BUILD_EXTENSION_AOT_UTIL "Build the AOT Util extension" OFF)
145144

146-
# Build the vulkan delegate along with the vulkan executor_runner
147-
option(EXECUTORCH_BUILD_VULKAN
148-
"Build the Vulkan delegate and the Vulkan executor_runner" OFF)
145+
option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER "Build the Data Loader extension"
146+
OFF)
149147

150-
option(EXECUTORCH_BUILD_SDK
151-
"Build the ExecuTorch SDK library and the SDK example runner.")
148+
option(EXECUTORCH_BUILD_EXTENSION_MODULE "Build the Module extension" OFF)
152149

153-
# Build mps_executor_runner which depends on MPSGraph framework
154-
option(EXECUTORCH_BUILD_MPS "Build mps_executor_runner which depends on MPS"
150+
option(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL "Build the Runner Util extension"
155151
OFF)
156152

157-
# Build dataloader extension library
158-
option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER
159-
"Build the extension/data_loader directory" OFF)
153+
option(EXECUTORCH_BUILD_GTESTS "Build googletest based test binaries" OFF)
154+
155+
option(EXECUTORCH_BUILD_MPS "Build the MPS backend" OFF)
156+
157+
option(EXECUTORCH_BUILD_PYBIND "Build the Python Bindings" OFF)
158+
159+
option(EXECUTORCH_BUILD_QNN "Build the Qualcomm backend" OFF)
160160

161-
# Build module extension library
162-
option(EXECUTORCH_BUILD_EXTENSION_MODULE
163-
"Build the extension/module directory" OFF)
161+
option(REGISTER_QUANTIZED_OPS "Build the quantized kernels" OFF)
164162

165-
# Build the runner_util extension library
166-
option(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL
167-
"Build the extension/runner_util directory" OFF)
163+
option(EXECUTORCH_BUILD_SDK "Build the ExecuTorch SDK")
168164

169-
# Build test binaries that rely on googletest
170-
option(EXECUTORCH_BUILD_GTESTS
171-
"Build googletest based test binaries" OFF)
165+
option(EXECUTORCH_BUILD_SIZE_TEST "Build the size test" OFF)
172166

173-
# Build the AOT util extension library
174-
option(EXECUTORCH_BUILD_EXTENSION_AOT_UTIL
175-
"Build the extension/aot_util directory" OFF)
167+
option(EXECUTORCH_BUILD_XNNPACK "Build the XNNPACK backend" OFF)
168+
169+
option(EXECUTORCH_BUILD_VULKAN "Build the Vulkan backend" OFF)
176170

177171
if(NOT BUCK2)
178172
set(BUCK2 buck2)
@@ -258,11 +252,21 @@ if(EXECUTORCH_BUILD_FLATC)
258252
)
259253
endif()
260254
set(FLATC_EXECUTABLE flatc)
261-
set(FLATBUFFERS_BUILD_FLATC ON CACHE BOOL "")
262-
set(FLATBUFFERS_BUILD_FLATHASH OFF CACHE BOOL "")
263-
set(FLATBUFFERS_BUILD_FLATLIB OFF CACHE BOOL "")
264-
set(FLATBUFFERS_BUILD_TESTS OFF CACHE BOOL "")
265-
set(FLATBUFFERS_INSTALL OFF CACHE BOOL "")
255+
set(FLATBUFFERS_BUILD_FLATC
256+
ON
257+
CACHE BOOL "")
258+
set(FLATBUFFERS_BUILD_FLATHASH
259+
OFF
260+
CACHE BOOL "")
261+
set(FLATBUFFERS_BUILD_FLATLIB
262+
OFF
263+
CACHE BOOL "")
264+
set(FLATBUFFERS_BUILD_TESTS
265+
OFF
266+
CACHE BOOL "")
267+
set(FLATBUFFERS_INSTALL
268+
OFF
269+
CACHE BOOL "")
266270
add_subdirectory(third-party/flatbuffers)
267271
endif()
268272
if(NOT FLATC_EXECUTABLE)
@@ -313,6 +317,10 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/kernels/optimized)
313317

314318
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/configurations)
315319

320+
if(REGISTER_QUANTIZED_OPS)
321+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/kernels/quantized)
322+
endif()
323+
316324
#
317325
# gflags: Commandline flag host library.
318326
#
@@ -343,7 +351,6 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
343351

344352
# Generate lib to register quantized ops
345353
if(REGISTER_QUANTIZED_OPS)
346-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/kernels/quantized)
347354
list(APPEND _executor_runner_libs quantized_ops_lib)
348355
endif()
349356

@@ -387,7 +394,6 @@ if(EXECUTORCH_BUILD_EXTENSION_AOT_UTIL)
387394
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/aot_util)
388395
endif()
389396

390-
option(EXECUTORCH_BUILD_XNNPACK "Build the backends/xnnpack directory" OFF)
391397
if(EXECUTORCH_BUILD_XNNPACK)
392398
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/xnnpack)
393399
endif()
@@ -396,36 +402,28 @@ if(EXECUTORCH_BUILD_VULKAN)
396402
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/vulkan)
397403
endif()
398404

399-
option(EXECUTORCH_BUILD_ANDROID_JNI "Build Android JNI" OFF)
400405
if(EXECUTORCH_BUILD_ANDROID_JNI)
401406
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/examples/models/llama2/runner)
402407
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/android)
403408
endif()
404409

405-
option(EXECUTORCH_BUILD_QNN "Build the backends/qualcomm directory" OFF)
406410
if(EXECUTORCH_BUILD_QNN)
407411
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/qualcomm)
408412
endif()
409413

410-
option(EXECUTORCH_BUILD_ARM_BAREMETAL
411-
"Build the Arm Baremetal flow for Cortex-M and Ethos-U" OFF)
412414
if(EXECUTORCH_BUILD_ARM_BAREMETAL)
413415
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/arm)
414416
endif()
415417

416-
option(EXECUTORCH_BUILD_MPS "Build the MPS Backend" OFF)
417418
if(EXECUTORCH_BUILD_MPS)
418419
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/apple/mps)
419420
endif()
420421

421-
option(EXECUTORCH_BUILD_COREML "Build the Core ML Backend" OFF)
422422
if(EXECUTORCH_BUILD_COREML)
423423
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/apple/coreml)
424424
endif()
425425

426-
option(EXECUTORCH_BUILD_PYBIND "Build the Python Bindings" OFF)
427426
if(EXECUTORCH_BUILD_PYBIND)
428-
429427
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third-party/pybind11)
430428

431429
if(NOT EXECUTORCH_BUILD_EXTENSION_DATA_LOADER)
@@ -462,8 +460,7 @@ if(EXECUTORCH_BUILD_PYBIND)
462460
util
463461
${CMAKE_CURRENT_SOURCE_DIR}/extension/evalue_util/print_evalue.cpp
464462
${CMAKE_CURRENT_SOURCE_DIR}/extension/aten_util/aten_bridge.cpp
465-
${CMAKE_CURRENT_SOURCE_DIR}/util/read_file.cpp
466-
)
463+
${CMAKE_CURRENT_SOURCE_DIR}/util/read_file.cpp)
467464
target_include_directories(util PUBLIC ${_common_include_directories}
468465
${TORCH_INCLUDE_DIRS})
469466
target_compile_options(util PUBLIC ${_pybind_compile_options})
@@ -475,20 +472,19 @@ if(EXECUTORCH_BUILD_PYBIND)
475472
PUBLIC EXECUTORCH_PYTHON_MODULE_NAME=portable_lib)
476473
target_include_directories(portable_lib PRIVATE ${TORCH_INCLUDE_DIRS})
477474
target_compile_options(portable_lib PUBLIC ${_pybind_compile_options})
478-
target_link_libraries(portable_lib
479-
PUBLIC
480-
${TORCH_PYTHON_LIBRARY}
481-
bundled_program
482-
etdump
483-
executorch
484-
extension_data_loader
485-
portable_ops_lib
486-
util
487-
torch
488-
${PYBIND_LINK_COREML}
489-
${PYBIND_LINK_MPS}
490-
${PYBIND_LINK_XNNPACK}
491-
)
475+
target_link_libraries(
476+
portable_lib
477+
PUBLIC ${TORCH_PYTHON_LIBRARY}
478+
bundled_program
479+
etdump
480+
executorch
481+
extension_data_loader
482+
portable_ops_lib
483+
util
484+
torch
485+
${PYBIND_LINK_COREML}
486+
${PYBIND_LINK_MPS}
487+
${PYBIND_LINK_XNNPACK})
492488

493489
install(TARGETS portable_lib
494490
LIBRARY DESTINATION executorch/extension/pybindings)

0 commit comments

Comments
 (0)