[ros-users] [Discourse.ros.org] [Next Generation ROS] Adding clang thread safety analysis for ROS2 core packages

Emerson Knapp via Discourse.ros.org ros.discourse at gmail.com
Tue Feb 26 20:19:04 UTC 2019



Great! Done, thanks!

Another thought, it seems  a little unwieldy to add this block to the `CMakeLists.txt` for every package that wants to use this analysis 

```
# Enable thread safety annotations and analysis when using clang
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -std=c++14")
  add_definitions(-D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
  add_compile_options(-Wthread-safety)
endif()
```

Would there be a better way to either
1. Put that block in for all ament packages, so it's enabled globally, but only affects code that is annotated using the C++ macros
2. Add a cmake macro/function to enable it as a one-liner, like `ament_enable_thread_safety_analysis`?

@Thomas_Moulard maybe you have thoughts on this?





---
[Visit Topic](https://discourse.ros.org/t/adding-clang-thread-safety-analysis-for-ros2-core-packages/7930/12) or reply to this email to respond.




More information about the ros-users mailing list