blob: 3b013e81819b790115ed652ce9c118bc00ffa434 [file] [log] [blame]
Radek Krejcia198c962020-08-16 10:32:10 +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)
Michal Vaskoeb042612020-11-25 09:51:36 +010011 execute_process(COMMAND ${UNCRUSTIFY} --version OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE VERSION)
Radek Krejcia198c962020-08-16 10:32:10 +020012 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)