Allow older version of clang-format.

This commit is contained in:
asuessenbach
2021-03-23 10:52:56 +01:00
parent 6b478d567c
commit ae49faf6b8
7 changed files with 1679 additions and 1535 deletions

View File

@@ -37,14 +37,23 @@ if(CLANG_FORMAT_EXECUTABLE)
execute_process(COMMAND ${CLANG_FORMAT_EXECUTABLE} "--version" OUTPUT_VARIABLE clangFormatVersion)
# filter out the actual version
string(REGEX MATCH [0123456789.]+ clangFormatVersion "${clangFormatVersion}")
# we need at least version 10.0.0 !
if (clangFormatVersion VERSION_LESS 10.0.0)
message(WARNING " Found too old clang-format version <" ${clangFormatVersion} ">, we need version 10 and up to nicely format vulkan.hpp")
else()
# we need at least version 7.0.0 !
if (clangFormatVersion VERSION_LESS 7.0.0)
message(WARNING " Found too old clang-format version <" ${clangFormatVersion} ">, we need version 7 and up to nicely format vulkan.hpp and vulkan_raii.hpp")
else ()
message(STATUS " Found clang-format version <" ${clangFormatVersion} ">.")
add_definitions(-DCLANG_FORMAT_EXECUTABLE="${CLANG_FORMAT_EXECUTABLE}")
if (clangFormatVersion VERSION_LESS 10.0.0)
message(STATUS " Using .clang-format version 7." )
file(READ ".clang-format_7" clangFormat)
else ()
message(STATUS " Using .clang-format version 10." )
file(READ ".clang-format_10" clangFormat)
endif ()
file(WRITE ".clang-format" ${clangFormat})
endif()
else()
message(WARNING " Could not find clang-format version 10 and up. Generated vulkan.hpp will not be nicely formatted.")
message(WARNING " Could not find clang-format. Generated vulkan.hpp and vulkan_raii.hpp will not be nicely formatted.")
endif()
if (NOT DEFINED CMAKE_CXX_STANDARD)