From 682fe643c624736d5186727cab05a211aec9bb4b Mon Sep 17 00:00:00 2001 From: Abrar Rahman Protyasha Date: Tue, 24 May 2022 14:27:36 -0400 Subject: [PATCH] [ament_cmake_uncrustify] Add ament_cmake_uncrustify_LANGUAGE variable This standardizes the interface to manually specify the language for linters such as cppcheck and uncrustify, such that the necessary CMake code can look like: ```diff diff --git a/CMakeLists.txt b/CMakeLists.txt index f6a8bb3..f71e803 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ if(BUILD_TESTING) set(ament_cmake_cppcheck_LANGUAGE c++) - set(ament_cmake_uncrustify_ADDITIONAL_ARGS "--language c++") + set(ament_cmake_uncrustify_LANGUAGE c++) endif() ``` Signed-off-by: Abrar Rahman Protyasha --- .../cmake/ament_cmake_uncrustify_lint_hook.cmake | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ament_cmake_uncrustify/cmake/ament_cmake_uncrustify_lint_hook.cmake b/ament_cmake_uncrustify/cmake/ament_cmake_uncrustify_lint_hook.cmake index 9fcdc89c..fd06953c 100644 --- a/ament_cmake_uncrustify/cmake/ament_cmake_uncrustify_lint_hook.cmake +++ b/ament_cmake_uncrustify/cmake/ament_cmake_uncrustify_lint_hook.cmake @@ -25,11 +25,20 @@ file(GLOB_RECURSE _source_files FOLLOW_SYMLINKS if(_source_files) message(STATUS "Added test 'uncrustify' to check C / C++ code style") + # Forces uncrustify to consider ament_cmake_uncrustify_LANGUAGE as the given language if defined + set(_language "") + if(DEFINED ament_cmake_uncrustify_LANGUAGE) + set(_language LANGUAGE ${ament_cmake_uncrustify_LANGUAGE}) + message(STATUS "Configured uncrustify language: ${ament_cmake_uncrustify_LANGUAGE}") + endif() + set(_args "") if(DEFINED ament_cmake_uncrustify_ADDITIONAL_ARGS) list(APPEND _args ${ament_cmake_uncrustify_ADDITIONAL_ARGS}) endif() message(STATUS "Configured uncrustify additional arguments: ${_args}") - ament_uncrustify(${_args}) + ament_uncrustify( + ${_language} ${_args} + ) endif()