forked from lijiext/lammps
Add format-tests target
This commit is contained in:
parent
d5d28bcbd2
commit
e840fa23f1
|
@ -0,0 +1,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)
|
|
@ -5,3 +5,13 @@ add_subdirectory(force-styles)
|
|||
add_subdirectory(utils)
|
||||
|
||||
add_subdirectory(formats)
|
||||
|
||||
find_package(ClangFormat)
|
||||
|
||||
if(ClangFormat_FOUND)
|
||||
set(UNITTEST_SOURCES)
|
||||
file(GLOB_RECURSE UNITTEST_SOURCES *.cpp *.h)
|
||||
add_custom_target(format-tests
|
||||
COMMAND ${ClangFormat_EXECUTABLE} --verbose -i -style=file ${UNITTEST_SOURCES}
|
||||
DEPENDS ${UNITTEST_SOURCES})
|
||||
endif()
|
||||
|
|
Loading…
Reference in New Issue