Skip to content

Commit

Permalink
Improve PCL 3rd-party detection
Browse files Browse the repository at this point in the history
- vp_find_pcl() is now used in main CMakeLists.txt to avoid calling this macro 3 times in modules gui, sensor and mbt
- allows also to have VTK_FOUND var that can be used in main CMakeLists.txt
  • Loading branch information
fspindle committed Nov 14, 2023
1 parent cfc26dd commit 98a443b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 49 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/ubuntu-dep-src.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,14 @@ jobs:
cmake .. -DCMAKE_INSTALL_PREFIX=$(pwd)/install
cat ViSP-third-party.txt
- name: Compile
- name: Build visp-config script
working-directory: build
run: |
make -j$(nproc) developer_scripts
./bin/visp-config --cflags
./bin/visp-config --libs
- name: Build and install ViSP
working-directory: build
run: |
make -j$(nproc) install
Expand Down
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,16 @@ endif()

# Upgrade c++ standard to 14 for pcl 1.9.1.99 that enables by default c++ 14 standard
if(USE_PCL)
# PCL is used in modules gui, sensor and mbt.
# In these modules we cannot directly use PCL_INCLUDE_DIRS and PCL_LIBRARIES using:
# list(APPEND opt_incs ${PCL_INCLUDE_DIRS})
# list(APPEND opt_libs ${PCL_LIBRARIES})
# Using PCL_LIBRARIES works to build visp libraries, embedded examples, demos, tests and tutorials thanks to the
# components. But when examples, demos, tests and tutorials are build outside ViSP workspace as independent projects
# that are using ViSP as 3rd-party we lead to build issues due to VTK headers and libraries that are not found.
# That's why here, we are using vp_find_pcl() macro that will set PCL_DEPS_INCLUDE_DIRS and PCL_DEPS_LIBRARIES
# that contains also VTK material location.
vp_find_pcl(PCL_LIBRARIES PCL_DEPS_INCLUDE_DIRS PCL_DEPS_LIBRARIES)
if(PCL_VERSION VERSION_GREATER 1.9.1)
# pcl > 1.9.1 requires c++14
# if c++14 option is OFF, force to c++14
Expand Down
12 changes: 12 additions & 0 deletions cmake/PCLTools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@
# IN: pcl_libraries
# OUT: pcl_deps_include_dirs
# OUT: pcl_deps_libraries
#
# PCL_LIBRARIES contains VTK 3rd party such as vtkalglib and not /usr/local/Cellar/vtk/6.3.0/lib/libvtkalglib-6.3.1.dylib
# full path as requested to use ViSP as 3rd party. This is the case for all VTK libraries that are PCL dependencies.
# The build of ViSP works with PCL_LIBRARIES since in that case thanks to vtkalglib properties, CMake
# is able to find the real name and location of the libraries.
# But when ViSP is used as a 3rd party where it should import PCL libraries, it doesn't work with
# PCL_LIBRARIES and especially with VTK_LIBRARIES.
# The solution here is to get the full location of VTK_LIBRARIES libraries thanks to the properties and link
# with these names.
# An other way could be to include PCLConfig.cmake, but in that case, visp-config and visp.pc
# will be not able to give the names of PCL libraries when used without CMake.
#
macro(vp_find_pcl pcl_libraries pcl_deps_include_dirs pcl_deps_libraries)
foreach(lib_ ${${pcl_libraries}})
mark_as_advanced(${lib_}_LOCATION)
Expand Down
18 changes: 2 additions & 16 deletions modules/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,8 @@ endif()

if(USE_PCL)
list(APPEND opt_incs ${PCL_INCLUDE_DIRS})

# list(APPEND opt_libs ${PCL_LIBRARIES})
# Using PCL_LIBRARIES works to build visp library, examples, demos and test thanks to the components,
# but not tutorials when they are build outside ViSP as they are stand alone CMake projects that use
# ViSP as a 3rd party.
# To be clear PCL_LIBRARIES contains VTK 3rd party such as vtkalglib and not /usr/local/Cellar/vtk/6.3.0/lib/libvtkalglib-6.3.1.dylib
# full path as requested to use ViSP as 3rd party. This is the case for all VTK libraries that are PCL dependencies.
# The build of ViSP works with PCL_LIBRARIES since in that case thanks to vtkalglib properties, CMake
# is able to find the real name and location of the libraries.
# But when ViSP is used as a 3rd party where it should import PCL libraries, it doesn't work with
# PCL_LIBRARIES and especially with VTK_LIBRARIES.
# The solution here is to get the full location of VTK_LIBRARIES libraries thanks to the properties and link
# with these names.
# An other way could be to include PCLConfig.cmake, but in that case, visp-config and visp.pc
# will be not able to give the names of PCL libraries when used without CMake.
vp_find_pcl(PCL_LIBRARIES PCL_DEPS_INCLUDE_DIRS PCL_DEPS_LIBRARIES)
# To ensure to build with VTK and other PCL 3rd parties we are not using PCL_LIBRARIES but PCL_DEPS_INCLUDE_DIRS
# and PCL_DEPS_LIBRARIES instead
list(APPEND opt_incs ${PCL_DEPS_INCLUDE_DIRS})
list(APPEND opt_libs ${PCL_DEPS_LIBRARIES})
endif()
Expand Down
18 changes: 2 additions & 16 deletions modules/sensor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,8 @@ if(USE_FTIITSDK)
endif()
if(USE_PCL)
list(APPEND opt_incs ${PCL_INCLUDE_DIRS})

# list(APPEND opt_libs ${PCL_LIBRARIES})
# Using PCL_LIBRARIES works to build visp library, examples, demos and test thanks to the components,
# but not tutorials when they are build outside ViSP as they are stand alone CMake projects that use
# ViSP as a 3rd party.
# To be clear PCL_LIBRARIES contains VTK 3rd party such as vtkalglib and not /usr/local/Cellar/vtk/6.3.0/lib/libvtkalglib-6.3.1.dylib
# full path as requested to use ViSP as 3rd party. This is the case for all VTK libraries that are PCL dependencies.
# The build of ViSP works with PCL_LIBRARIES since in that case thanks to vtkalglib properties, CMake
# is able to find the real name and location of the libraries.
# But when ViSP is used as a 3rd party where it should import PCL libraries, it doesn't work with
# PCL_LIBRARIES and especially with VTK_LIBRARIES.
# The solution here is to get the full location of VTK_LIBRARIES libraries thanks to the properties and link
# with these names.
# An other way could be to include PCLConfig.cmake, but in that case, visp-config and visp.pc
# will be not able to give the names of PCL libraries when used without CMake.
vp_find_pcl(PCL_LIBRARIES PCL_DEPS_INCLUDE_DIRS PCL_DEPS_LIBRARIES)
# To ensure to build with VTK and other PCL 3rd parties we are not using PCL_LIBRARIES but PCL_DEPS_INCLUDE_DIRS
# and PCL_DEPS_LIBRARIES instead
list(APPEND opt_incs ${PCL_DEPS_INCLUDE_DIRS})
list(APPEND opt_libs ${PCL_DEPS_LIBRARIES})
endif()
Expand Down
18 changes: 2 additions & 16 deletions modules/tracker/mbt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,8 @@ endif()

if(USE_PCL)
list(APPEND opt_incs ${PCL_INCLUDE_DIRS})

# list(APPEND opt_libs ${PCL_LIBRARIES})
# Using PCL_LIBRARIES works to build visp library, examples, demos and test thanks to the components,
# but not tutorials when they are build outside ViSP as they are stand alone CMake projects that use
# ViSP as a 3rd party.
# To be clear PCL_LIBRARIES contains VTK 3rd party such as vtkalglib and not /usr/local/Cellar/vtk/6.3.0/lib/libvtkalglib-6.3.1.dylib
# full path as requested to use ViSP as 3rd party. This is the case for all VTK libraries that are PCL dependencies.
# The build of ViSP works with PCL_LIBRARIES since in that case thanks to vtkalglib properties, CMake
# is able to find the real name and location of the libraries.
# But when ViSP is used as a 3rd party where it should import PCL libraries, it doesn't work with
# PCL_LIBRARIES and especially with VTK_LIBRARIES.
# The solution here is to get the full location of VTK_LIBRARIES libraries thanks to the properties and link
# with these names.
# An other way could be to include PCLConfig.cmake, but in that case, visp-config and visp.pc
# will be not able to give the names of PCL libraries when used without CMake.
vp_find_pcl(PCL_LIBRARIES PCL_DEPS_INCLUDE_DIRS PCL_DEPS_LIBRARIES)
# To ensure to build with VTK and other PCL 3rd parties we are not using PCL_LIBRARIES but PCL_DEPS_INCLUDE_DIRS
# and PCL_DEPS_LIBRARIES instead
list(APPEND opt_incs ${PCL_DEPS_INCLUDE_DIRS})
list(APPEND opt_libs ${PCL_DEPS_LIBRARIES})
endif()
Expand Down

0 comments on commit 98a443b

Please sign in to comment.