File: FindClangFormat.cmake

package info (click to toggle)
lammps 20220106.git7586adbb6a%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 348,064 kB
  • sloc: cpp: 831,421; python: 24,896; xml: 14,949; f90: 10,845; ansic: 7,967; sh: 4,226; perl: 4,064; fortran: 2,424; makefile: 1,501; objc: 238; lisp: 163; csh: 16; awk: 14; tcl: 6
file content (46 lines) | stat: -rw-r--r-- 1,782 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Find clang-format
find_program(ClangFormat_EXECUTABLE NAMES clang-format
                                          clang-format-10.0
                                          clang-format-9.0
                                          clang-format-8.0
                                          clang-format-7.0
                                          clang-format-6.0
                                     DOC "clang-format executable")
mark_as_advanced(ClangFormat_EXECUTABLE)

if(ClangFormat_EXECUTABLE)
  # find version
  execute_process(COMMAND ${ClangFormat_EXECUTABLE} --version
                  OUTPUT_VARIABLE clang_format_version
                  ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)


  if(clang_format_version MATCHES "^clang-format version .*")
    # Arch Linux
    # clang-format version 10.0.0

    # Ubuntu 18.04 LTS Output
    # clang-format version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
    string(REGEX REPLACE "clang-format version ([0-9.]+).*"
                         "\\1"
                         ClangFormat_VERSION
                         "${clang_format_version}")
  elseif(clang_format_version MATCHES ".*LLVM version .*")
    # CentOS 7 Output
    # LLVM (http://llvm.org/):
    #   LLVM version 3.4.2
    #   Optimized build.
    #   Built Nov  1 2018 (15:06:24).
    #   Default target: x86_64-redhat-linux-gnu
    #   Host CPU: x86-64
    string(REGEX REPLACE ".*LLVM version ([0-9.]+).*"
                         "\\1"
                         ClangFormat_VERSION
                         "${clang_format_version}")
  else()
    set(ClangFormat_VERSION "0.0")
  endif()
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ClangFormat REQUIRED_VARS ClangFormat_EXECUTABLE VERSION_VAR ClangFormat_VERSION)