PointCloudLibrary / PointCloudLibrary/pcl

io & 2d CMake configs fail to ignore VTK even when WITH_VTK set to OFF

Open
#2,649 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

module: cmake needs: code review
Dominant language
C++
Stars
11.1k
Forks
4.7k
Avg merge
4d 10h
Merged PRs (30d)
6

Description

Environment

  • Operating System and version: Ubuntu 16.04
  • Compiler: clang8
  • PCL Version: 1.8.1

Context

PCL built with WITH_VTK=OFF
OS has VTK libraries installed, but with no intention of using them here.
Linking against PCL_IO with ${PCL_IO_LIBRARIES} after a find_package(PCL NO_MODULE REQUIRED COMPONENTS io)

Expected Behavior

PCL compiled with WITH_VTK=OFF should not attempt to link against VTK, nor cause dependants to try to link against VTK

Current Behavior

When compiling a system against a custom build of PCL with WITH_VTK=OFF, linking to PCL_IO using

target_link_libraries(mytarget ${PCL_IO_LIBRARIES})
Causes the mytarget to link against VTK despite my intentions to prevent this.

Possible Solution

I'm not a CMake expert so I hesitate to suggest a solution or to submit a pull request, but If my diagnosis is correct, then:

PCLConfig.cmake.in uses @PCLCONFIG_EXTERNAL_DEPENDENCIES@ To dump in

set(pcl_io_opt_dep openni openni2 ensenso davidSDK dssdk pcap png vtk libusb-1.0 )
set(pcl_2d_opt_dep vtk )

into PCLConfig.cmake causing anyone linking against anything dependant on pcl_io or pcl_2d to try to link against VTK.

This appears to happe because of io/CMakeLists.txt line 10 where we see:
PCL_SUBSYS_DEPEND(build "${SUBSYS_NAME}" DEPS ${SUBSYS_DEPS} OPT_DEPS openni openni2 ensenso davidSDK dssdk pcap png vtk libusb-1.0)

And 2d/CMakeLists.txt line '7' where we see:
PCL_SUBSYS_DEPEND(build "${SUBSYS_NAME}" DEPS ${SUBSYS_DEPS} OPT_DEPS vtk)

regardless of whether WITH_VTK is OFF or ON

Adding a check for WITH_VTK around that PCL_SUBSYS_DEPEND line might do the trick.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read io/CMakeLists.txt, 2d/CMakeLists.txt, and PCLConfig.cmake.in, then inspect how PCL_SUBSYS_DEPEND records optional dependencies when WITH_VTK is OFF. Configure PCL with WITH_VTK=OFF and link a dependent target using PCL_IO_LIBRARIES. Done means that dependent target no longer attempts to link against VTK.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.