PointCloudLibrary / pcl

Point Cloud Library (PCL)
https://pointclouds.org/
Other
9.87k stars 4.61k forks source link

[CMake] question about transitives external dependencies #3740

Open schweitzer opened 4 years ago

schweitzer commented 4 years ago

Your Environment

Context

Hello, I've got a issue/question about how PCL handles external dependencies. I know that you recently change some piece of CMake code but in my opinion there is still a lack of "export" of external libraries (FLANN, VTK, ...) when using PCL COMPONENTS .

Expected Behavior

When I use PCL in a project I would like to do something like:


find_package(PCL 1.10 REQUIRED COMPONENTS common filters features registration search kdtree io)

#Other cmake stuff
... 

target_link_libraries(myProject
    PUBLIC
    pcl_common
    pcl_filters 
    pcl_features 
    pcl_registration 
    pcl_search 
    pcl_kdtree
    pcl_io
    )

Current Behavior

But currently if I do what I explain in Expected Behavior there are plenty of external libraries that are missing.

We don't want to explicitly link myProject against FLANN, VTK or whatever since they are only needed by PCL.

So I take a look in the PCLConfig.cmake.in file and it seems like there is all the needed information when parsing the PCL components here in the ${PCL_${COMPONENT}_LIBRARIES} , but this variable is reset later in the script but never used.

Possible Solution

What I suggest is to add ${PCL_${COMPONENT}_LIBRARIES} in the INTERFACE_LINK_LIBRARIES. That's what we have done here, this way PCL can be find using CMake target and external libraries such as FLANN seems to be transitive and hidden to final user.

What do you think ? Did I miss a point ?

SergioRAgostinho commented 4 years ago

A reasonable request and solution. :+1:

schweitzer commented 4 years ago

If needed the PR is available.

Some corner cases needs to be tested (old CMake version, build on exotic OS, ...).

Let me know if something is wrong :smiley:

stale[bot] commented 4 years ago

Marking this as stale due to 30 days of inactivity. It will be closed in 7 days if no further activity occurs.