Skip to content

Commit

Permalink
[ament_cmake_uncrustify] Add ament_cmake_uncrustify_LANGUAGE variable
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
aprotyas committed May 24, 2022
1 parent bafa3ff commit 682fe64
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 682fe64

Please sign in to comment.