From 8c6b57801218dd7adea59fce0a72a41c8f2d1b28 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Fri, 25 Nov 2022 13:08:15 -0600 Subject: [PATCH] Disallow clang-format version 15 and newer --- CMakeLists.txt | 2 +- cmake/Format.cmake | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e58fe51b..fabb1c60e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/cmake/Format.cmake b/cmake/Format.cmake index 92d84533a..eb8c14d60 100644 --- a/cmake/Format.cmake +++ b/cmake/Format.cmake @@ -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