How to add additional include search path
Last updated
Last updated
When working on ROS2 projects in an IDE (e.g. Clion), it is important to understand that there are two build systems involved.
IDE's Build System: The IDE uses CmakeLists.txt
file in each ROS2 project to resolve paths and variables.
ROS2's Build System: This is the build system used by ROS2 when you build the ROS2 workspace in the terminal. For instance, in ROS2 Humble, colcon
command is used to build the package and ament
commands are used in the CmakeLists.txt file.
Successfully building a ROS2 workspace in the terminal does not guarantee that the IDE will resolve all paths and variables. This issue becomes more apparent with custom message and service files, where the IDE might fail to locate certain header files.
To address this issue, we can add additional include search paths. However, it's crucial not to modify the CMakeLists.txt
file directly to avoid introducing changes that could affect the ROS2 build system and lead to confusion. Instead, we should adjust the CMake configuration within the IDE by adding the following CMake option:
For example, in Clion, we can add this in Settings > Build, Execution, Deployment > Cmake > CMake options.