mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-29 16:09:13 +00:00
cmake: add function to print dict list
This commit is contained in:
parent
a787b1c0b7
commit
289b024715
2 changed files with 36 additions and 11 deletions
|
@ -37,10 +37,14 @@ macro(MESSAGE_ERROR _TEXT)
|
|||
endmacro()
|
||||
|
||||
macro(MESSAGE_BOOL_OPTION _NAME _VALUE)
|
||||
set(_PAD "\t")
|
||||
if(${ARGC} EQUAL 3)
|
||||
set(_PAD ${ARGV2})
|
||||
endif()
|
||||
if(${_VALUE})
|
||||
message(STATUS " ${_NAME}:\tON")
|
||||
message(STATUS " ${_NAME}:${_PAD}ON")
|
||||
else()
|
||||
message(STATUS " ${_NAME}:\tOFF")
|
||||
message(STATUS " ${_NAME}:${_PAD}OFF")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
@ -94,6 +98,28 @@ function(LISTTOSTRREV _LIST _OUTPUT)
|
|||
set($_OUTPUT} "${res}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(find_stringlength_longest_item inList outLength)
|
||||
set(maxLength 0)
|
||||
foreach(item IN LISTS ${inList})
|
||||
string(LENGTH "${item}" slen)
|
||||
if(slen GREATER maxLength)
|
||||
set(maxLength ${slen})
|
||||
endif()
|
||||
endforeach()
|
||||
set("${outLength}" ${maxLength} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(message_dictlist inList)
|
||||
find_stringlength_longest_item(${inList} maxLength)
|
||||
foreach(name IN LISTS ${inList})
|
||||
# Get the padding
|
||||
string(LENGTH ${name} nameLength)
|
||||
math(EXPR padLength "(${maxLength} + 1) - ${nameLength}")
|
||||
string(RANDOM LENGTH ${padLength} ALPHABET " " padding)
|
||||
message_tested_option(${name} ${padding})
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
if(CMAKE_VERSION VERSION_LESS 3.16.0 OR SDL3_SUBPROJECT)
|
||||
# - CMake versions <3.16 do not support the OBJC language
|
||||
# - When SDL is built as a subproject and when the main project does not enable OBJC,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue