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
|
cmake_minimum_required( VERSION 3.1.0 )
#Find clang-format binary
find_program(CLF_BIN clang-format DOC "Path to clang-format binary")
if(CLF_BIN)
#Obtain list of source files
file(GLOB_RECURSE SRC_LIST
*.c
*.cc
*.cpp
*.hpp
*.h
*.mm
../qcm/*.qcm
)
foreach(src_file ${SRC_LIST})
#Exclude libpsi
if("${src_file}" MATCHES ".*/libpsi/.*")
list(REMOVE_ITEM SRC_LIST ${src_file})
endif()
endforeach()
add_custom_target(fix-codestyle
COMMAND ${CLF_BIN}
--verbose
-style=file
-i ${SRC_LIST}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Fix codestyle with clang-format"
VERBATIM
)
endif()
|