diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:55:11 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:55:11 +0000 |
commit | cd07912073c951b4bbb871ed2653af1be2cfc714 (patch) | |
tree | 1073c2308492e6aea4c66cb7436ee92db2abfd42 /CMakeModules/FindUncrustify.cmake | |
parent | Initial commit. (diff) | |
download | libyang2-upstream/2.1.30.tar.xz libyang2-upstream/2.1.30.zip |
Adding upstream version 2.1.30.upstream/2.1.30upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'CMakeModules/FindUncrustify.cmake')
-rw-r--r-- | CMakeModules/FindUncrustify.cmake | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/CMakeModules/FindUncrustify.cmake b/CMakeModules/FindUncrustify.cmake new file mode 100644 index 0000000..3b013e8 --- /dev/null +++ b/CMakeModules/FindUncrustify.cmake @@ -0,0 +1,21 @@ +# - Find uncrustify +# Find the uncrustify binary. +# +# UNCRUSTIFY - path ot the binary +# UNCRUSTIFY_VERSION - found version +# UNCRUSTIFY_FOUND - True if uncrustify found. +include(FindPackageHandleStandardArgs) + +find_program(UNCRUSTIFY uncrustify) +if(UNCRUSTIFY) + execute_process(COMMAND ${UNCRUSTIFY} --version OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE VERSION) + string(FIND ${VERSION} "-" START_IDX) + math(EXPR START_IDX "${START_IDX} + 1") + string(SUBSTRING "${VERSION}" ${START_IDX} -1 VERSION) + + string(FIND ${VERSION} "-" LEN) + string(SUBSTRING "${VERSION}" 0 ${LEN} UNCRUSTIFY_VERSION) +endif() + +# Handle the QUIETLY and REQUIRED arguments and set UNCRUSTIFY_FOUND to TRUE if all listed variables are TRUE. +find_package_handle_standard_args(Uncrustify REQUIRED_VARS UNCRUSTIFY VERSION_VAR UNCRUSTIFY_VERSION) |