PointCloudLibrary / pcl

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

[cmake] pcl_options.cmake modified CMAKE_FIND_LIBRARY_SUFFIXES, resulting in failure to find dependencies #4997

Open JackBoosY opened 2 years ago

JackBoosY commented 2 years ago

Hi guys, I'm vcpkg maintainer. Recently we are updating pcl in vcpkg (https://github.com/microsoft/vcpkg/pull/18855), but met some problems: When vtk, a dependency of pcl, finds qt, an error occurs:

CMake Error at /mnt/vcpkg-ci/installed/x64-linux/share/cmake/Qt5Gui/Qt5GuiConfig.cmake:95 (message):
  Library not found: GL
Call Stack (most recent call first):
  /mnt/vcpkg-ci/installed/x64-linux/share/cmake/Qt5Gui/Qt5GuiConfig.cmake:277 (_qt5_Gui_process_prl_file)
  /agent/_work/1/s/scripts/buildsystems/vcpkg.cmake:792 (_find_package)
  /mnt/vcpkg-ci/installed/x64-linux/share/cmake/Qt5Widgets/Qt5WidgetsConfig.cmake:231 (find_package)
  /agent/_work/1/s/scripts/buildsystems/vcpkg.cmake:792 (_find_package)
  /mnt/vcpkg-ci/installed/x64-linux/share/cmake/Qt5/Qt5Config.cmake:28 (find_package)
  /agent/_work/1/s/scripts/buildsystems/vcpkg.cmake:792 (_find_package)
  /mnt/vcpkg-ci/installed/x64-linux/share/vtk/VTK-vtk-module-find-packages.cmake:115 (find_package)
  /mnt/vcpkg-ci/installed/x64-linux/share/vtk/vtk-config.cmake:129 (include)
  /agent/_work/1/s/scripts/buildsystems/vcpkg.cmake:792 (_find_package)
  cmake/pcl_find_vtk.cmake:25 (find_package)
  CMakeLists.txt:380 (include)

After a long period of searching, we found that pcl modified the value of CMAKE_FIND_LIBRARY_SUFFIXES in _pcloptions.cmake, which caused its downstream dependencies to fail to find their dependencies through find_library. For example, qt needs libGL.so, and CMAKE_FIND_LIBRARY_SUFFIXES is modified to .a when statically building PCL, which results in find_library expecting to find libGL.a. See code: https://github.com/PointCloudLibrary/pcl/blob/cd99687bd1f332d77aee06a8e9fbad4fb08c0a44/cmake/pcl_options.cmake#L5-L18

So, please DO NOT do that, any modification of the cmake macro value that has not been backed up and restored will cause errors when using the downstream configuration.

Thanks, Jack

JackBoosY commented 2 years ago

Maybe related PR: https://github.com/PointCloudLibrary/pcl/pull/4390