blob: 3b013e81819b790115ed652ce9c118bc00ffa434 [file] [log] [blame]
Michal Vaskob0e3ec42021-05-26 09:48:31 +02001# - Find uncrustify
2# Find the uncrustify binary.
3#
4# UNCRUSTIFY - path ot the binary
5# UNCRUSTIFY_VERSION - found version
6# UNCRUSTIFY_FOUND - True if uncrustify found.
7include(FindPackageHandleStandardArgs)
8
9find_program(UNCRUSTIFY uncrustify)
10if(UNCRUSTIFY)
11 execute_process(COMMAND ${UNCRUSTIFY} --version OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE VERSION)
12 string(FIND ${VERSION} "-" START_IDX)
13 math(EXPR START_IDX "${START_IDX} + 1")
14 string(SUBSTRING "${VERSION}" ${START_IDX} -1 VERSION)
15
16 string(FIND ${VERSION} "-" LEN)
17 string(SUBSTRING "${VERSION}" 0 ${LEN} UNCRUSTIFY_VERSION)
18endif()
19
20# Handle the QUIETLY and REQUIRED arguments and set UNCRUSTIFY_FOUND to TRUE if all listed variables are TRUE.
21find_package_handle_standard_args(Uncrustify REQUIRED_VARS UNCRUSTIFY VERSION_VAR UNCRUSTIFY_VERSION)