cmake: Commands for clang-[tidy|format]

This commit is contained in:
Michael Carlberg 2016-10-19 01:29:30 +02:00
parent 68f72d69cc
commit 86d2186f89

View File

@ -2,14 +2,15 @@
# Additional targets to perform clang-format/clang-tidy # Additional targets to perform clang-format/clang-tidy
# #
file(GLOB_RECURSE SOURCE_FILES *.[chi]pp) file(GLOB_RECURSE header_files ${PROJECT_SOURCE_DIR}/include/*.hpp)
file(GLOB_RECURSE source_files ${PROJECT_SOURCE_DIR}/src/*.cpp)
# Add clang-format target if executable is found # Add clang-format target if executable is found
# -------------------------------------------------- # --------------------------------------------------
find_program(CLANG_FORMAT "clang-format") find_program(CLANG_FORMAT "clang-format")
if(CLANG_FORMAT) if(CLANG_FORMAT)
add_custom_target(clang-format COMMAND add_custom_target(clang-format COMMAND ${CLANG_FORMAT}
${CLANG_FORMAT} -i -style=file ${SOURCE_FILES}) -i -style=file ${header_files} ${source_files})
endif() endif()
# Add clang-tidy target if executable is found # Add clang-tidy target if executable is found
@ -17,6 +18,5 @@ endif()
find_program(CLANG_TIDY "clang-tidy") find_program(CLANG_TIDY "clang-tidy")
if(CLANG_TIDY) if(CLANG_TIDY)
add_custom_target(clang-tidy COMMAND ${CLANG_TIDY} add_custom_target(clang-tidy COMMAND ${CLANG_TIDY}
${SOURCE_FILES} -config='' -- -std=c++11 -p ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/src/main.cpp)
${INCLUDE_DIRECTORIES})
endif() endif()