Radek Krejci | a198c96 | 2020-08-16 10:32:10 +0200 | [diff] [blame] | 1 | # format source files with uncrustify |
| 2 | # files are expected to be a list and relative paths are resolved wtih respect to CMAKE_SOURCE DIR |
| 3 | macro(SOURCE_FORMAT) |
| 4 | if(NOT ${ARGC}) |
| 5 | message(FATAL_ERROR "source_format() needs a list of files to format!") |
| 6 | endif() |
| 7 | |
| 8 | find_package(Uncrustify 0.71) |
| 9 | if(UNCRUSTIFY_FOUND) |
| 10 | add_custom_target(format |
| 11 | COMMAND ${UNCRUSTIFY} -c ${CMAKE_SOURCE_DIR}/uncrustify.cfg --no-backup --replace ${ARGN} |
| 12 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
| 13 | COMMENT "Formating sources with ${UNCRUSTIFY} ...") |
| 14 | |
| 15 | add_custom_target(format-check |
| 16 | COMMAND ${UNCRUSTIFY} -c ${CMAKE_SOURCE_DIR}/uncrustify.cfg --check ${ARGN} |
| 17 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
| 18 | COMMENT "Checking format of the sources with ${UNCRUSTIFY} ...") |
| 19 | endif() |
| 20 | endmacro() |