2019-07-19 07:55:17 +00:00
|
|
|
function(add_uncrustify_format)
|
|
|
|
list(GET ARGN 0 _target)
|
|
|
|
set(_sources ${ARGN})
|
|
|
|
list(REMOVE_AT _sources 0)
|
|
|
|
|
|
|
|
find_program(UNCRUSTIFY_EXE NAMES uncrustify)
|
|
|
|
if(UNCRUSTIFY_EXE)
|
|
|
|
if(NOT TARGET uncrustify-format)
|
|
|
|
add_custom_target(uncrustify-format)
|
|
|
|
endif()
|
2019-10-07 10:52:50 +00:00
|
|
|
list(APPEND OPTS
|
|
|
|
-lCPP
|
|
|
|
--replace
|
|
|
|
--no-backup)
|
2019-07-20 08:39:42 +00:00
|
|
|
if(EXISTS ${CMAKE_SOURCE_DIR}/cmake/etc/uncrustify/default.cfg)
|
|
|
|
list(APPEND OPTS -c ${CMAKE_SOURCE_DIR}/cmake/etc/uncrustify/default.cfg)
|
|
|
|
endif()
|
2019-10-07 10:52:50 +00:00
|
|
|
add_custom_target(uncrustify-format-${_target} COMMAND ${UNCRUSTIFY_EXE} ${OPTS} ${_sources})
|
2019-07-19 07:55:17 +00:00
|
|
|
add_dependencies(uncrustify-format uncrustify-format-${_target})
|
|
|
|
else()
|
2019-08-10 07:30:01 +00:00
|
|
|
message(STATUS "CMLIB warning:")
|
|
|
|
message(STATUS " Uncrustify is not found")
|
2019-07-19 07:55:17 +00:00
|
|
|
endif()
|
|
|
|
endfunction()
|