How to fix: CMake Error Found relative path while evaluating include directories of
Starting from https://examples.vtk.org/site/Cxx/PolyData/ColoredPoints/, I decided to compile VTK as a git-submodule which implies:
- replacing
find_package
bygit submodule add https://gitlab.kitware.com/vtk/vtk vtk; add_subdirectory(vtk)
- replacing
${VTK_LIBRARIES}
byVTK::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
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?