blob: ec353b883cdffd70f3b846c339e195912a941c1e [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)
11 execute_process(COMMAND ${UNCRUSTIFY} --version 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)