diff options
author | Rechi <Rechi@users.noreply.github.com> | 2022-10-13 23:45:49 +0200 |
---|---|---|
committer | Rechi <Rechi@users.noreply.github.com> | 2022-10-13 23:45:49 +0200 |
commit | d7b251ffdaa77283c95e42c1b0655a672db93dc5 (patch) | |
tree | fc8c532e8e874d9b82615815ef57c8200c5a6781 /cmake/modules | |
parent | 7149b66ebd61a7537a7585dadf3a925011fa54b3 (diff) |
[cmake] add version parsing to clang-format
Diffstat (limited to 'cmake/modules')
-rw-r--r-- | cmake/modules/buildtools/FindClangFormat.cmake | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/cmake/modules/buildtools/FindClangFormat.cmake b/cmake/modules/buildtools/FindClangFormat.cmake index 7220d31623..ff052a17ea 100644 --- a/cmake/modules/buildtools/FindClangFormat.cmake +++ b/cmake/modules/buildtools/FindClangFormat.cmake @@ -5,7 +5,15 @@ find_program(CLANG_FORMAT_EXECUTABLE clang-format) +if(CLANG_FORMAT_EXECUTABLE) + execute_process(COMMAND "${CLANG_FORMAT_EXECUTABLE}" --version + OUTPUT_VARIABLE CLANG_FORMAT_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REGEX REPLACE ".* version (.*)" "\\1" CLANG_FORMAT_VERSION "${CLANG_FORMAT_VERSION}") +endif() + include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(ClangFormat REQUIRED_VARS CLANG_FORMAT_EXECUTABLE) +find_package_handle_standard_args(ClangFormat REQUIRED_VARS CLANG_FORMAT_EXECUTABLE + VERSION_VAR CLANG_FORMAT_VERSION) mark_as_advanced(CLANG_FORMAT_EXECUTABLE) |