Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ project(executorch)
include(${PROJECT_SOURCE_DIR}/tools/cmake/common/preset.cmake)
include(${PROJECT_SOURCE_DIR}/tools/cmake/preset/default.cmake)

# Print all the configs that were called with announce_configured_options.
print_configured_options()

# MARK: - End EXECUTORCH_H12025_BUILD_MIGRATION ----------------------------------------------------

include(tools/cmake/Utils.cmake)
Expand Down
4 changes: 0 additions & 4 deletions tools/cmake/Utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ function(executorch_print_configuration_summary)
message(STATUS " BUCK2 : ${BUCK2}")
message(STATUS " PYTHON_EXECUTABLE : ${PYTHON_EXECUTABLE}")
message(STATUS " FLATC_EXECUTABLE : ${FLATC_EXECUTABLE}")
message(
STATUS
" EXECUTORCH_ENABLE_LOGGING : ${EXECUTORCH_ENABLE_LOGGING}"
)
message(STATUS " EXECUTORCH_ENABLE_PROGRAM_VERIFICATION : "
"${EXECUTORCH_ENABLE_PROGRAM_VERIFICATION}"
)
Expand Down
50 changes: 50 additions & 0 deletions tools/cmake/common/preset.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,54 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# Announce the name and value of a cmake variable in the summary of the build.
function(announce_configured_options NAME)
get_property(_options GLOBAL PROPERTY _announce_configured_options)
if(NOT _options)
set_property(GLOBAL PROPERTY _announce_configured_options)
get_property(_options GLOBAL PROPERTY _announce_configured_options)
endif()

set(option_exists FALSE)
foreach(_option IN LISTS _options)
if(_option STREQUAL "${NAME}")
set(option_exists TRUE)
break()
endif()
endforeach()

if(NOT option_exists)
set(_options ${_options} "${NAME}")
set_property(GLOBAL PROPERTY _announce_configured_options "${_options}")
endif()
endfunction()

# Print the configured options.
function(print_configured_options)
get_property(_options GLOBAL PROPERTY _announce_configured_options)

set(_longest_name_length 0)
foreach(_option IN LISTS _options)
string(LENGTH "${_option}" length)
if(length GREATER _longest_name_length)
set(_longest_name_length ${length})
endif()
endforeach()

message(STATUS "--- Configurated Options ---\n")
foreach(_option IN LISTS _options)
string(LENGTH "${_option}" _option_length)
math(EXPR num_spaces "${_longest_name_length} - ${_option_length}")
set(padding "")
while(num_spaces GREATER 0)
set(padding "${padding} ")
math(EXPR num_spaces "${num_spaces} - 1")
endwhile()
Comment on lines +46 to +49
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spent 5 mins reading this and just realized it's printing empty spaces lol

message(STATUS "${_option}${padding} : ${${_option}}")
endforeach()
message(STATUS "---------------------------")
endfunction()

# Enforce option names to always start with EXECUTORCH.
function(enforce_executorch_option_name NAME)
if(NOT "${NAME}" MATCHES "^EXECUTORCH_")
Expand All @@ -26,4 +74,6 @@ macro(define_overridable_option NAME DESCRIPTION VALUE_TYPE DEFAULT_VALUE)
else()
set(${NAME} ${DEFAULT_VALUE} CACHE ${VALUE_TYPE} ${DESCRIPTION})
endif()

announce_configured_options(${NAME})
endmacro()
Loading