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