Skip to content

Commit

Permalink
Fix vtk interface include directories detection
Browse files Browse the repository at this point in the history
- occurs since vtk (ver 9.3.20231115) with cmake 3.27.7 on Ubuntu 22.04
- seems not occuring with cmake 3.22.1 that comes with Ubuntu 22.04
- Retrieving interface include directories on any VTK component with

  get_target_property(imported_incs_ VTK::ChartsCore INTERFACE_INCLUDE_DIRECTORIES)

  lead to retrieve

  $<BUILD_INTERFACE:/home/VTK/install/include/vtk-9.3>

  instead of /home/VTK/install/include/vtk-9.3
- Here the fix consists in removing "$<BUILD_INTERFACE" and ">" strings
  • Loading branch information
fspindle committed Nov 15, 2023
1 parent 09c9004 commit d6aebe3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/ubuntu-dep-src.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@ jobs:
echo "VTK_DIR=$(pwd)/install" >> $GITHUB_ENV
echo $VTK_DIR
- name: DEBUG VTK
run: |
cd $VTK_DIR
ls lib/cmake/vtk-9.3
grep -R INCLUDE_DIRECTORIES lib/cmake/vtk-9.3/VTK-targets.cmake
- name: Build OpenCV from source
run: |
pwd
Expand Down
30 changes: 26 additions & 4 deletions cmake/PCLTools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@
#
#############################################################################

# Remove BUILD_INTERFACE from __include_dirs
# IN/OUT: __include_dirs
#
# If __include_dirs contains "$<BUILD_INTERFACE:/home/VTK/install/include/vtk-9.3>" as input,
# it will be filtered as output to /home/VTK/install/include/vtk-9.3
macro(vp_filter_build_interface __include_dirs)
if(${__include_dirs})
set(__include_dirs_filtered)
foreach(inc_ ${${__include_dirs}})
string(REGEX REPLACE "\\$<BUILD_INTERFACE:" "" inc_ ${inc_})
string(REGEX REPLACE ">" "" inc_ ${inc_})
list(APPEND __include_dirs_filtered ${inc_})
endforeach()

set(${__include_dirs} ${__include_dirs_filtered})
endif()
endmacro()

# Find pcl libraries and dependencies
# IN: pcl_libraries
# OUT: pcl_deps_include_dirs
Expand Down Expand Up @@ -93,7 +111,6 @@ macro(vp_find_pcl pcl_libraries pcl_deps_include_dirs pcl_deps_libraries)
# Get pcl link libraries like opengl
vp_list_unique(PCL_VTK_LIBRARIES)
if(NOT VTK_ENABLE_KITS)
message("--- DEBUG VTK: case 1: NOT VTK_ENABLE_KITS")
foreach(lib_ ${PCL_VTK_LIBRARIES})
get_target_property(imported_libs_ ${lib_} INTERFACE_LINK_LIBRARIES)
if(imported_libs_)
Expand All @@ -104,13 +121,16 @@ macro(vp_find_pcl pcl_libraries pcl_deps_include_dirs pcl_deps_libraries)
endif()

get_target_property(imported_incs_ ${lib_} INTERFACE_INCLUDE_DIRECTORIES)
message("--- DEBUG VTK: ${lib_} imported_incs_: ${imported_incs_}")
if(imported_incs_)
list(APPEND PCL_VTK_IMPORTED_INCS ${imported_incs_})
endif()
endforeach()
vp_list_unique(PCL_VTK_IMPORTED_LIBS)
vp_list_unique(PCL_VTK_IMPORTED_INCS)

# Filter "$<BUILD_INTERFACE:/home/VTK/install/include/vtk-9.3>" into /home/VTK/install/include/vtk-9.3
vp_filter_build_interface(PCL_VTK_IMPORTED_INCS)

list(APPEND ${pcl_deps_include_dirs} ${PCL_VTK_IMPORTED_INCS})

# Filter "\$<LINK_ONLY:vtkCommonMath>;\$<LINK_ONLY:opengl32>;\$<LINK_ONLY:glu32>" into "vtkCommonMath;opengl32;glu32"
Expand Down Expand Up @@ -155,7 +175,6 @@ macro(vp_find_pcl pcl_libraries pcl_deps_include_dirs pcl_deps_libraries)
endwhile()
vp_list_unique(PCL_VTK_LIBS)
else()
message("--- DEBUG VTK: case 2: VTK_ENABLE_KITS")
foreach(lib_ ${PCL_VTK_LIBRARIES})
get_target_property(imported_libs_ ${lib_} INTERFACE_LINK_LIBRARIES)
if(imported_libs_)
Expand All @@ -168,13 +187,16 @@ macro(vp_find_pcl pcl_libraries pcl_deps_include_dirs pcl_deps_libraries)
endif()

get_target_property(imported_incs_ ${lib_} INTERFACE_INCLUDE_DIRECTORIES)
message("--- DEBUG VTK: ${lib_} imported_incs_: ${imported_incs_}")
if(imported_incs_)
list(APPEND PCL_VTK_IMPORTED_INCS ${imported_incs_})
endif()
endforeach()
vp_list_unique(PCL_VTK_IMPORTED_LIBS)
vp_list_unique(PCL_VTK_IMPORTED_INCS)

# Filter "$<BUILD_INTERFACE:/home/VTK/install/include/vtk-9.3>" into /home/VTK/install/include/vtk-9.3
vp_filter_build_interface(PCL_VTK_IMPORTED_INCS)

list(APPEND ${pcl_deps_include_dirs} ${PCL_VTK_IMPORTED_INCS})

while(PCL_VTK_IMPORTED_LIBS)
Expand Down

0 comments on commit d6aebe3

Please sign in to comment.