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.
856function (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} )
2979endmacro ()
0 commit comments