Disallow clang-format version 15 and newer

This commit is contained in:
Chris Thrasher 2022-11-25 13:08:15 -06:00
parent c5bd4a4063
commit 8c6b578012
2 changed files with 6 additions and 4 deletions

View File

@ -532,7 +532,7 @@ if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
return()
endif()
sfml_set_option(CLANG_FORMAT_EXECUTABLE clang-format STRING "Override clang-format executable, requires minimum version 12")
sfml_set_option(CLANG_FORMAT_EXECUTABLE clang-format STRING "Override clang-format executable, requires version 12, 13, or 14")
add_custom_target(format
COMMAND ${CMAKE_COMMAND} "-DCLANG_FORMAT_EXECUTABLE=${CLANG_FORMAT_EXECUTABLE}" -P ./cmake/Format.cmake
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" VERBATIM)

View File

@ -13,10 +13,12 @@ endif()
execute_process(COMMAND ${CLANG_FORMAT_EXECUTABLE} --version OUTPUT_VARIABLE CLANG_FORMAT_VERSION)
string(REGEX MATCH "clang-format version ([0-9]+)" CLANG_FORMAT_VERSION ${CLANG_FORMAT_VERSION})
unset(CLANG_FORMAT_VERSION)
if(CMAKE_MATCH_1 GREATER_EQUAL 12)
message(STATUS "Using clang-format version ${CMAKE_MATCH_1}")
else()
if(CMAKE_MATCH_1 LESS 12)
message(FATAL_ERROR "clang-format version ${CMAKE_MATCH_1} is too low")
elseif(CMAKE_MATCH_1 GREATER 14)
message(FATAL_ERROR "clang-format version ${CMAKE_MATCH_1} is too high")
else()
message(STATUS "Using clang-format version ${CMAKE_MATCH_1}")
endif()
# Run