Skip to content

Modernize cmake config template#6235

Merged
mvieth merged 2 commits intoPointCloudLibrary:masterfrom
lesc-hexagon:patch-1
Mar 4, 2025
Merged

Modernize cmake config template#6235
mvieth merged 2 commits intoPointCloudLibrary:masterfrom
lesc-hexagon:patch-1

Conversation

@lesc-hexagon
Copy link
Copy Markdown
Contributor

The helper strings was not updated for 14 year and the mentioned Targets do not seem to exist.

Update to use modern style.

@larshg
Copy link
Copy Markdown
Contributor

larshg commented Feb 18, 2025

With my current test, PCL_INCLUDE_DIRS and PCL_LIBRARY_DIRS are populated with:

[CMake] PCL_INCLUDE_DIRS are C:/dev/pcl/out/install/x64-Release/include/pcl-1.14;C:/dev/vcpkg/installed/x64-windows/include/eigen3
[CMake] PCL_LIBRARY_DIRS are C:/dev/pcl/out/install/x64-Release/lib

So maybe we can keep them as optional and indeed add the modern way as the primary approach.

The values should be populated from the CONFIG script, at least with the root directory of PCL?

# check whether PCLConfig.cmake is found into a PCL installation or in a build tree
if(EXISTS "${PCL_ROOT}/include/pcl-${PCL_VERSION_MAJOR}.${PCL_VERSION_MINOR}/pcl/pcl_config.h")
  # Found a PCL installation
  # pcl_message("Found a PCL installation")
  set(PCL_CONF_INCLUDE_DIR "${PCL_ROOT}/include/pcl-${PCL_VERSION_MAJOR}.${PCL_VERSION_MINOR}")
  set(PCL_LIBRARY_DIRS "${PCL_ROOT}/lib")
elseif(EXISTS "${PCL_ROOT}/include/pcl/pcl_config.h")
  # Found a non-standard (likely ANDROID) PCL installation
  # pcl_message("Found a PCL installation")
  set(PCL_CONF_INCLUDE_DIR "${PCL_ROOT}/include")
  set(PCL_LIBRARY_DIRS "${PCL_ROOT}/lib")
elseif(EXISTS "${PCL_DIR}/include/pcl/pcl_config.h")
  # Found PCLConfig.cmake in a build tree of PCL
  # pcl_message("PCL found into a build tree.")
  set(PCL_CONF_INCLUDE_DIR "${PCL_DIR}/include") # for pcl_config.h
  set(PCL_LIBRARY_DIRS "${PCL_DIR}/lib")
else()
  pcl_report_not_found("PCL can not be found on this machine")
endif()

set(PCL_INCLUDE_DIRS "${PCL_CONF_INCLUDE_DIR}")

@lesc-hexagon
Copy link
Copy Markdown
Contributor Author

With my current test, PCL_INCLUDE_DIRS and PCL_LIBRARY_DIRS are populated with:

You are probably right, my description is probably false. I think we tried to link against the Components specific Variables. Which do not exist for all Components or something.
We probably got confused as the doc said to search for components specifically and then link to a global target.
None the less I think the new way linking against the target would be preferable. But I just thought I propose the update we found working for us. I have not invested much time to understand you full cmake.

The helper strings was not updated for 14 year and the mentioned Targets do not seem to exist.

Update to use modern style.
@mvieth
Copy link
Copy Markdown
Member

mvieth commented Mar 3, 2025

How about the following description? I focuses on the new linking approach but still mentions PCL_INCLUDE_DIRS and PCL_LIBRARY_DIRS:

# ------------------------------------------------------------------------------------
# Helper to use PCL from outside project
#
# Search for PCL:
# Request all PCL modules:
#   find_package(PCL CONFIG REQUIRED)
# Or request only specific PCL modules:
#   find_package(PCL CONFIG REQUIRED COMPONENTS xxx yyy)
#
# Link to PCL:
# Link to all found PCL modules:
#   target_link_libraries(my_fabulous_target ${PCL_LIBRARIES})
# Or link only to specific modules:
#   target_link_libraries(my_fabulous_target pcl_xxx pcl_yyy)
# 
# Where xxx and yyy are module names from the following list:
# @PCLCONFIG_AVAILABLE_COMPONENTS_LIST@
#
# Some additional variables are set by PCLConfig.cmake, which are not needed when
# using the (modern) linking approach described above:
# PCL_INCLUDE_DIRS is filled with PCL and available 3rdparty headers
# PCL_LIBRARY_DIRS is filled with PCL components libraries install directory and
# 3rdparty libraries paths
#
#                                   www.pointclouds.org
#------------------------------------------------------------------------------------

@lesc-hexagon
Copy link
Copy Markdown
Contributor Author

How about the following description?

How about the following description? Looks like a good improvment? Shall I update the PR or are you already having this change somwhere?

@mvieth
Copy link
Copy Markdown
Member

mvieth commented Mar 3, 2025

Looks like a good improvment? Shall I update the PR or are you already having this change somwhere?

No, I just wrote it. It would be great if you could update this PR with that description.

@lesc-hexagon lesc-hexagon requested a review from larshg March 3, 2025 17:12
@mvieth mvieth added the changelog: enhancement Meta-information for changelog generation label Mar 4, 2025
@mvieth mvieth merged commit 130508f into PointCloudLibrary:master Mar 4, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: enhancement Meta-information for changelog generation module: docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants