Skip to content

Commit 63654a5

Browse files
committed
[executorch][cmake] Add EXECUTORCH_ENABLE_LOGGING and EXECUTORCH_ENABLE_PROGRAM_VERIFICATION
These flags should be off by default in Release mode, but some users may want to enable them. This sets a convention for future options like this, which should also use `${_default_release_disabled_targets}`. Differential Revision: [D49925195](https://our.internmc.facebook.com/intern/diff/D49925195/) ghstack-source-id: 202924824 Pull Request resolved: #617
1 parent 17fee78 commit 63654a5

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

CMakeLists.txt

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,31 @@ if(NOT CMAKE_BUILD_TYPE)
5454
set(CMAKE_BUILD_TYPE Debug)
5555
endif()
5656

57-
# https://cmake.org/cmake/help/latest/command/add_definitions.html Adds
58-
# definitions to the compiler command line for - targets in the current
59-
# directory, before and after this command is invoked - targets in
60-
# sub-directories added after this command is invoked
57+
# _default_release_disabled_targets: default value for options that should be
58+
# disabled in Release mode by default. Users can still manually enable them,
59+
# though.
6160
if(CMAKE_BUILD_TYPE STREQUAL "Release")
62-
# Avoid pulling in the logging strings, which can be large.
61+
set(_default_release_disabled_targets OFF)
62+
else()
63+
set(_default_release_disabled_targets ON)
64+
endif()
65+
66+
option(EXECUTORCH_ENABLE_LOGGING "Build with ET_LOG_ENABLED"
67+
${_default_release_disabled_targets})
68+
if(NOT EXECUTORCH_ENABLE_LOGGING)
69+
# Avoid pulling in the logging strings, which can be large. Note that this
70+
# will set the compiler flag for all targets in this directory, and for all
71+
# subdirectories included after this point.
6372
add_definitions(-DET_LOG_ENABLED=0)
73+
endif()
74+
75+
option(EXECUTORCH_ENABLE_PROGRAM_VERIFICATION
76+
"Build with ET_ENABLE_PROGRAM_VERIFICATION"
77+
${_default_release_disabled_targets})
78+
if(NOT EXECUTORCH_ENABLE_PROGRAM_VERIFICATION)
6479
# Avoid pulling in the flatbuffer data verification logic, which can add about
65-
# 20kB.
80+
# 20kB. Note that this will set the compiler flag for all targets in this
81+
# directory, and for all subdirectories included after this point.
6682
add_definitions(-DET_ENABLE_PROGRAM_VERIFICATION=0)
6783
endif()
6884

build/Utils.cmake

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ function(executorch_print_configuration_summary)
3030
message(STATUS " BUCK2 : ${BUCK2}")
3131
message(STATUS " PYTHON_EXECUTABLE : ${PYTHON_EXECUTABLE}")
3232
message(STATUS " FLATC_EXECUTABLE : ${FLATC_EXECUTABLE}")
33+
message(
34+
STATUS " EXECUTORCH_ENABLE_LOGGING : ${EXECUTORCH_ENABLE_LOGGING}")
35+
message(STATUS " EXECUTORCH_ENABLE_PROGRAM_VERIFICATION : "
36+
"${EXECUTORCH_ENABLE_PROGRAM_VERIFICATION}")
3337
message(
3438
STATUS " EXECUTORCH_BUILD_HOST_TARGETS : ${EXECUTORCH_BUILD_HOST_TARGETS}")
3539
message(STATUS " EXECUTORCH_BUILD_FLATC : ${EXECUTORCH_BUILD_FLATC}")
@@ -40,11 +44,8 @@ function(executorch_print_configuration_summary)
4044
)
4145
message(
4246
STATUS " REGISTER_EXAMPLE_CUSTOM_OPS : ${REGISTER_EXAMPLE_CUSTOM_OPS}")
43-
message(
44-
STATUS
45-
" EXECUTORCH_BUILD_EXTENSION_DATA_LOADER : "
46-
"${EXECUTORCH_BUILD_EXTENSION_DATA_LOADER}"
47-
)
47+
message(STATUS " EXECUTORCH_BUILD_EXTENSION_DATA_LOADER : "
48+
"${EXECUTORCH_BUILD_EXTENSION_DATA_LOADER}")
4849
message(STATUS " EXECUTORCH_BUILD_XNNPACK : ${EXECUTORCH_BUILD_XNNPACK}")
4950
endfunction()
5051

0 commit comments

Comments
 (0)