Open catskul opened 5 years ago
this is very unfortunate as I cannot figure out how NOT to load the IO
module. It is defined as an optional dependency of kdtree
here
https://github.com/PointCloudLibrary/pcl/blob/214bb392559b229964c043b400f9590d09ef9e5e/test/kdtree/CMakeLists.txt#L4
Environment
Context
PCL
built withWITH_VTK=OFF
OS hasVTK
libraries installed, but with no intention of using them here. Linking againstPCL_IO
with${PCL_IO_LIBRARIES}
after afind_package(PCL NO_MODULE REQUIRED COMPONENTS io)
Expected Behavior
PCL
compiled withWITH_VTK=OFF
should not attempt to link againstVTK
, nor cause dependants to try to link againstVTK
Current Behavior
When compiling a system against a custom build of
PCL
withWITH_VTK=OFF
, linking toPCL_IO
usingtarget_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 ininto PCLConfig.cmake causing anyone linking against anything dependant on
pcl_io
orpcl_2d
to try to link againstVTK
.This appears to happe because of
io/CMakeLists.txt
line10
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
isOFF
orON
Adding a check for
WITH_VTK
around thatPCL_SUBSYS_DEPEND
line might do the trick.