clion配置ros2

要生成compile_commands.json文件,那生成该文件的命令是

colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
set(ament_cmake_DIR /opt/ros/humble/share/ament_cmake/cmake)
set(ament_cmake_libraries_DIR /opt/ros/humble/share/ament_cmake_libraries/cmake)

找到clion.sh这个脚本,加入下面内容

source /opt/ros/humble/setup.zsh

When we run colcon build with the following cmake-args option, we can got compile_commands.json for each package.
colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
It’s very useful to use auto complete of programming ROS / ROS 2 by the language server protocol of clangd.
It’ll be even more useful to develop multiple packages at a time if the multiple compile_commands.json to unify one compile_commands.json.

I’m thinking about adding a --cmake-concat-compile-commands option. How do you think about it? I try to implement it soon.
Thanks to the colcon extensibility, my development experience is better than before!

参考链接:https://github.com/colcon/colcon-cmake/issues/61

猜你喜欢

转载自blog.csdn.net/CCCrunner/article/details/131659417