# How to fix: CMake Error Found relative path while evaluating include directories of

**URL:** https://discourse.vtk.org/t/how-to-fix-cmake-error-found-relative-path-while-evaluating-include-directories-of/11865
**Category:** Support
**Created:** [July 2, 2023, 9:58am UTC](https://discourse.vtk.org/t/how-to-fix-cmake-error-found-relative-path-while-evaluating-include-directories-of/11865 "2023-07-02T09:58:41Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![fghoussen](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/f/ecd19e/32.png) [@fghoussen](https://discourse.vtk.org/u/fghoussen)
#### Post date: [July 2, 2023, 9:58am UTC](https://discourse.vtk.org/t/how-to-fix-cmake-error-found-relative-path-while-evaluating-include-directories-of/11865/1 "2023-07-02T09:58:41Z")

</div>

How to fix: CMake Error Found relative path while evaluating include directories of

Starting from [https://examples.vtk.org/site/Cxx/PolyData/ColoredPoints/](https://examples.vtk.org/site/Cxx/PolyData/ColoredPoints/), I decided to compile VTK as a git-submodule which implies:

- replacing `find_package` by `git submodule add https://gitlab.kitware.com/vtk/vtk vtk; add_subdirectory(vtk)`
- replacing `${VTK_LIBRARIES}` by `VTK::CommonCore`, `VTK::CommonDataModel` …).

I get CMake error: `CMake Error Found relative path while evaluating include directories of ... "VTK::CommonDataModel"`

Googling seems to point that this may be in connection with absolute / relative path. I tried to add `set(VTK_DIR "${PROJECT_SOURCE_DIR}/vtk")` in the CMakeLists.txt but I get the same error.

Setting `set(VTK_DIR "${CMAKE_BINARY_DIR}/vtk")` doesn’t help neither.

Reducing the example with the very minimum (just vtkPoints creation): “VTK::CommonCore” is found. But adding vtkPolyData needs VTK::CommonDataModel which is not found

Basically I do this

```auto
add_subdirectory(vtk)

set(VTK_DIR "${CMAKE_BINARY_DIR}/vtk")
set(VTK_TARGETS "VTK::CommonCore" "VTK::CommonDataModel")

vtk_module_autoinit(TARGETS ColoredPoints MODULES "${VTK_TARGETS}")
target_include_directories(ColoredPoints PRIVATE "${VTK_TARGETS}")
target_link_libraries(ColoredPoints PRIVATE "${VTK_TARGETS}")

```

Any clue?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [July 2, 2023, 2:47pm UTC](https://discourse.vtk.org/t/how-to-fix-cmake-error-found-relative-path-while-evaluating-include-directories-of/11865/2 "2023-07-02T14:47:27Z")

</div>

> [@fghoussen](#):
>
> I decided to compile VTK as a git-submodule which implies:

But why though ?

---

<div class="post-metadata">

### Author: ![fghoussen](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/f/ecd19e/32.png) [@fghoussen](https://discourse.vtk.org/u/fghoussen)
#### Post date: [July 2, 2023, 5:09pm UTC](https://discourse.vtk.org/t/how-to-fix-cmake-error-found-relative-path-while-evaluating-include-directories-of/11865/3 "2023-07-02T17:09:46Z")

</div>

> [@mwestphal](#):
>
> though

Because I’ll likely need to change CMake options

Any clue on the problem?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [July 3, 2023, 5:25am UTC](https://discourse.vtk.org/t/how-to-fix-cmake-error-found-relative-path-while-evaluating-include-directories-of/11865/4 "2023-07-03T05:25:07Z")

</div>

For changing cmake options, using a cmake preset is a much more sane approach.

---

<div class="post-metadata">

### Author: ![amaclean](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amaclean/32/224_2.png) [@amaclean](https://discourse.vtk.org/u/amaclean)
#### Post date: [July 3, 2023, 5:40am UTC](https://discourse.vtk.org/t/how-to-fix-cmake-error-found-relative-path-while-evaluating-include-directories-of/11865/5 "2023-07-03T05:40:31Z")

</div>

If CMake is telling you that you have relative paths, then you need to find and fix them.

Alternatively:

1. The best approach is to check out and build VTK as in the [VTK build instructions](https://gitlab.kitware.com/vtk/vtk/-/blob/master/Documentation/dev/build.md) and make sure everything works. It should, if you adopt this approach. When this is done, then you can experiment.
2. You could also look in `unix_path.sh` (`windows_path.bat`) for path settings. It is found in the top-level build directory where you build VTK.

---

<div class="post-metadata">

### Author: ![fghoussen](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/f/ecd19e/32.png) [@fghoussen](https://discourse.vtk.org/u/fghoussen)
#### Post date: [July 6, 2023, 3:48pm UTC](https://discourse.vtk.org/t/how-to-fix-cmake-error-found-relative-path-while-evaluating-include-directories-of/11865/6 "2023-07-06T15:48:29Z")

</div>

> [@amaclean](#):
>
> If CMake is telling you that you have relative paths, then you need to find and fix them.

This finally worked:

```auto
foreach(VTK_TARGET ${VTK_TARGETS})
  vtk_module_autoinit(TARGETS xx MODULES ${VTK_TARGET}")
  target_include_directories(xx PRIVATE "${VTK_TARGET}")
  target_link_libraries(xx PRIVATE "${VTK_TARGET}")
endforeach()

```

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [July 20, 2023, 7:43pm UTC](https://discourse.vtk.org/t/how-to-fix-cmake-error-found-relative-path-while-evaluating-include-directories-of/11865/7 "2023-07-20T19:43:18Z")

</div>

`vtk_module_autoinit` doesn’t work this way. The problem here:

> [@fghoussen](#):
>
> ```auto
> vtk_module_autoinit(TARGETS ColoredPoints MODULES "${VTK_TARGETS}")
> target_include_directories(ColoredPoints PRIVATE "${VTK_TARGETS}")
> target_link_libraries(ColoredPoints PRIVATE "${VTK_TARGETS}")
> 
> ```

`${VTK_TARGETS}` is a list and should not be quoted so that it expands as distinct arguments.

---

<div class="post-metadata">

### Author: ![NewPony](https://discourse.vtk.org/user_avatar/discourse.vtk.org/newpony/32/7846_2.png) [@NewPony](https://discourse.vtk.org/u/NewPony)
#### Post date: [September 18, 2024, 7:22pm UTC](https://discourse.vtk.org/t/how-to-fix-cmake-error-found-relative-path-while-evaluating-include-directories-of/11865/8 "2024-09-18T19:22:24Z")

</div>

Why do think this is a bad idea?  
I am also think about this, where my own project is a git repo and with vtk as a submodule it would be very easy to clone it and integrate it in my project. Or am I missing something?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [September 24, 2024, 9:49am UTC](https://discourse.vtk.org/t/how-to-fix-cmake-error-found-relative-path-while-evaluating-include-directories-of/11865/9 "2024-09-24T09:49:10Z")

</div>

You should consider VTK as a dependency and use `find_package` instead.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [September 30, 2024, 9:09pm UTC](https://discourse.vtk.org/t/how-to-fix-cmake-error-found-relative-path-while-evaluating-include-directories-of/11865/10 "2024-09-30T21:09:34Z")

</div>

Note that it is _possible_ to vendor VTK (ParaView does it), but it is _not_ as easy as `add_subdirectory` (and therefore `FetchContent` is not an option). Instead, ParaView “knows” what VTK does in various situations and uses its own CMake variables to control its build (e.g., `VTK_USE_MPI` is just set to the value of `PARAVIEW_USE_MPI` and not offered independently). VTK’s top-level `CMakeLists.txt` is set up to be the top-level and not designed to integrate as a component of another project.
