lint-targets.cmake (842B)
1 set( 2 FORMAT_PATTERNS 3 source/*.cpp source/*.hpp 4 include/*.hpp 5 test/*.cpp test/*.hpp 6 CACHE STRING 7 "; separated patterns relative to the project source dir to format" 8 ) 9 10 set(FORMAT_COMMAND clang-format CACHE STRING "Formatter to use") 11 12 add_custom_target( 13 format-check 14 COMMAND "${CMAKE_COMMAND}" 15 -D "FORMAT_COMMAND=${FORMAT_COMMAND}" 16 -D "PATTERNS=${FORMAT_PATTERNS}" 17 -P "${PROJECT_SOURCE_DIR}/cmake/lint.cmake" 18 WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" 19 COMMENT "Linting the code" 20 VERBATIM 21 ) 22 23 add_custom_target( 24 format-fix 25 COMMAND "${CMAKE_COMMAND}" 26 -D "FORMAT_COMMAND=${FORMAT_COMMAND}" 27 -D "PATTERNS=${FORMAT_PATTERNS}" 28 -D FIX=YES 29 -P "${PROJECT_SOURCE_DIR}/cmake/lint.cmake" 30 WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" 31 COMMENT "Fixing the code" 32 VERBATIM 33 )