Skip to content

Commit ef4e5c4

Browse files
committed
announce option
1 parent bf5b99a commit ef4e5c4

File tree

3 files changed

+53
-4
lines changed

3 files changed

+53
-4
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ project(executorch)
5050
include(${PROJECT_SOURCE_DIR}/tools/cmake/common/preset.cmake)
5151
include(${PROJECT_SOURCE_DIR}/tools/cmake/preset/default.cmake)
5252

53+
# Print all the configs that were called with announce_configured_options.
54+
print_configured_options()
55+
5356
# MARK: - End EXECUTORCH_H12025_BUILD_MIGRATION ----------------------------------------------------
5457

5558
include(tools/cmake/Utils.cmake)

tools/cmake/Utils.cmake

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ 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
35-
" EXECUTORCH_ENABLE_LOGGING : ${EXECUTORCH_ENABLE_LOGGING}"
36-
)
3733
message(STATUS " EXECUTORCH_ENABLE_PROGRAM_VERIFICATION : "
3834
"${EXECUTORCH_ENABLE_PROGRAM_VERIFICATION}"
3935
)

tools/cmake/common/preset.cmake

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,54 @@
44
# This source code is licensed under the BSD-style license found in the
55
# LICENSE file in the root directory of this source tree.
66

7+
# Announce the name and value of a cmake variable in the summary of the build.
8+
function(announce_configured_options NAME)
9+
get_property(_options GLOBAL PROPERTY _announce_configured_options)
10+
if(NOT _options)
11+
set_property(GLOBAL PROPERTY _announce_configured_options)
12+
get_property(_options GLOBAL PROPERTY _announce_configured_options)
13+
endif()
14+
15+
set(option_exists FALSE)
16+
foreach(_option IN LISTS _options)
17+
if(_option STREQUAL "${NAME}")
18+
set(option_exists TRUE)
19+
break()
20+
endif()
21+
endforeach()
22+
23+
if(NOT option_exists)
24+
set(_options ${_options} "${NAME}")
25+
set_property(GLOBAL PROPERTY _announce_configured_options "${_options}")
26+
endif()
27+
endfunction()
28+
29+
# Print the configured options.
30+
function(print_configured_options)
31+
get_property(_options GLOBAL PROPERTY _announce_configured_options)
32+
33+
set(_longest_name_length 0)
34+
foreach(_option IN LISTS _options)
35+
string(LENGTH "${_option}" length)
36+
if(length GREATER _longest_name_length)
37+
set(_longest_name_length ${length})
38+
endif()
39+
endforeach()
40+
41+
message(STATUS "--- Configurated Options ---\n")
42+
foreach(_option IN LISTS _options)
43+
string(LENGTH "${_option}" _option_length)
44+
math(EXPR num_spaces "${_longest_name_length} - ${_option_length}")
45+
set(padding "")
46+
while(num_spaces GREATER 0)
47+
set(padding "${padding} ")
48+
math(EXPR num_spaces "${num_spaces} - 1")
49+
endwhile()
50+
message(STATUS "${_option}${padding} : ${${_option}}")
51+
endforeach()
52+
message(STATUS "---------------------------")
53+
endfunction()
54+
755
# Enforce option names to always start with EXECUTORCH.
856
function(enforce_executorch_option_name NAME)
957
if(NOT "${NAME}" MATCHES "^EXECUTORCH_")
@@ -26,4 +74,6 @@ macro(define_overridable_option NAME DESCRIPTION VALUE_TYPE DEFAULT_VALUE)
2674
else()
2775
set(${NAME} ${DEFAULT_VALUE} CACHE ${VALUE_TYPE} ${DESCRIPTION})
2876
endif()
77+
78+
announce_configured_options(${NAME})
2979
endmacro()

0 commit comments

Comments
 (0)