> For the complete documentation index, see [llms.txt](https://www.learnros2.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.learnros2.com/ros/ide-and-cmake-setup/how-to-add-additional-include-search-path.md).

# How to add additional include search path

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:

```
-DCMAKE_CXX_FLAGS="-I <additional-include-path>"
```

For example, in Clion, we can add this in Settings > Build, Execution, Deployment > Cmake > CMake options.

<figure><img src="/files/5bAUCQdVUM3b2L5d9ZRf" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.learnros2.com/ros/ide-and-cmake-setup/how-to-add-additional-include-search-path.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
