Installation/configure/build problems with CMake and PCL

46 Views Asked by At

How does vcpkg install packages, that is, where would the "right" path to the includes and libs point to? I installed PCL as recommended via vcpkg but the experience now is anything but seamless or smooth. Notice that I do use find_package(PCL COMPONENTS common REQUIRED) as visible in the CMakeLists.txt below - but I can make little sense of what it finds, so this question is mainly about thoroughly understanding what happens.

Searching manually for one of the base includes, point_types.h, yields three different versions - two of them appear in three(!) different directories. The CUDA version however is only present in the buildtrees/.

Notice: I used the posix shell only for find, the system is of course Windows.

@DESKTOP-KC7P627:/mnt/c/vcpkg$ find -name "point_types.h" -exec ls -l {} \;
-rwxrwxrwx 1 8700 Jan  3 17:25 ./buildtrees/pcl/src/pcl-1.14.0-f965f4228c.clean/common/include/pcl/point_types.h
-rwxrwxrwx 1 5643 Jan  3 17:25 ./buildtrees/pcl/src/pcl-1.14.0-f965f4228c.clean/cuda/common/include/pcl/cuda/point_types.h
-rwxrwxrwx 1 2541 Jan  3 17:25 ./buildtrees/pcl/src/pcl-1.14.0-f965f4228c.clean/recognition/include/pcl/recognition/point_types.h
-rwxrwxrwx 2 8700 Jan  3 17:25 ./installed/x64-windows/include/pcl/point_types.h
-rwxrwxrwx 2 2541 Jan  3 17:25 ./installed/x64-windows/include/pcl/recognition/point_types.h
-rwxrwxrwx 2 8700 Jan  3 17:25 ./packages/pcl_x64-windows/include/pcl/point_types.h
-rwxrwxrwx 2 2541 Jan  3 17:25 ./packages/pcl_x64-windows/include/pcl/recognition/point_types.h

Worse yet, the file that I originally wanted to include (following a toy example) was cloud_viewer.h, and that one is only found in the buildtrees/:

@DESKTOP-KC7P627:/mnt/c/vcpkg$ find -name "cloud_viewer.h" -exec ls -l {} \;
-rwxrwxrwx 1 2714 Jan  3 17:25 ./buildtrees/pcl/src/pcl-1.14.0-f965f4228c.clean/apps/cloud_composer/include/pcl/apps/cloud_composer/cloud_viewer.h
-rwxrwxrwx 1 10819 Jan  3 17:25 ./buildtrees/pcl/src/pcl-1.14.0-f965f4228c.clean/visualization/include/pcl/visualization/cloud_viewer.h

The CMake PCL directories that I could identify, point to completely different directories:

[cmake] -- PCL_INCLUDE_DIRS:/vcpkg/installed/x64-windows/include/vcpkg/installed/x64-windows/include/eigen3
[cmake] -- PCL_DIR:/vcpkg/installed/x64-windows/share/pcl

Visual Studio Code finds both <pcl/point_cloud.h> and <pcl/point_types.h> but red-squiggles <pcl/visualization/cloud_viewer.h>.

All in all trying PCL to get to compile in CMake is the usual frustrating mess that it always seems to be as soon as I try to lay my hands on such a library.

CMakeLists.txt:

project(pcltest)

add_executable(${PROJECT_NAME})
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/pcl_test/pcl_startup.cpp)
# Use the following to link against all the PCL libraries
# Remove REQUIRED if PCL is not compulsory
# Note: might be heavy, not the best practice
# find_package(PCL REQUIRED)
# Prefer to use the correct component libraries instead
find_package(PCL COMPONENTS common REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
message(STATUS PCL_INCLUDE_DIRS:${PCL_INCLUDE_DIRS})
message(STATUS PCL_DIR:${PCL_DIR})
# All header directories not under your control go here
# ${PCL_INCLUDE_DIRS} not required to be manually added since PCL 1.9
# include_directories(SYSTEM)
# Headers for this project go here
# include_directories(include)

# Add a target to compile for cmake
# CMake automatically chooses the correct flags for executable or library
# add_library(pcl_demo main.cpp)

# Add the required libraries
target_link_libraries(${PROJECT_NAME} ${PCL_LIBRARIES})

Pointers for a terse, very basic how-to on CMake and its inner workings (the part that you need to understand to counter such problems like above) are dearly appreciated. The CMake homepage docs are a byzantine puzzle.

0

There are 0 best solutions below