Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boost cmake configuration issue on macOS Monterey (PCL Installation) #6225

Closed
bonomip opened this issue Jan 22, 2025 · 4 comments
Closed

Boost cmake configuration issue on macOS Monterey (PCL Installation) #6225

bonomip opened this issue Jan 22, 2025 · 4 comments
Labels

Comments

@bonomip
Copy link

bonomip commented Jan 22, 2025

Description

I encountered an issue while installing and configuring PCL on macOS Monterey (M1) using the procedure described in the official documentation "Compiling PCL and its dependencies from MacPorts and source on Mac OS X". The problem arose due to a failure to locate Boost despite it being installed via MacPorts. The issue seems related to the BoostConfig.cmake file and the paths not being correctly set.

Environment

OS: macOS Monterey (12.6.5)
Boost Version: 1.71.0 (installed via MacPorts)
PCL Version: [6b93e78 master]
CMake Version: [3.31.3]

Steps to Reproduce

Just follow the installation steps provided in the PCL documentation.

Error message

CMake Error at cmake/pcl_find_boost.cmake:29 (find_package):
  Could not find a package configuration file provided by "Boost" (requested
  version 1.71.0) with any of the following names:

    BoostConfig.cmake
    boost-config.cmake

  Add the installation prefix of "Boost" to CMAKE_PREFIX_PATH or set
  "Boost_DIR" to a directory containing one of the above files.  If "Boost"
  provides a separate development package or SDK, be sure it has been
  installed.

Call Stack (most recent call first):
  CMakeLists.txt:428 (include)

Actual Behavior

CMake fails to locate the BoostConfig.cmake file because the default search paths do not include the MacPorts Boost directory (/opt/local/libexec/boost/1.71/lib/cmake/Boost-1.71.0).

Resolution

I resolved the issue by explicitly setting Boost_DIR and other Boost-related paths in the CMakeLists.txt. Here's what I added:

if(APPLE)
  set(Boost_DIR /opt/local/libexec/boost/1.71/lib/cmake/Boost-1.71.0)
endif()
@bonomip bonomip added kind: bug Type of issue status: triage Labels incomplete labels Jan 22, 2025
@mvieth
Copy link
Member

mvieth commented Jan 23, 2025

Hi, just to be sure: Does the file BoostConfig.cmake exist on your computer?
This issue seems related to #6118 , so you could try sudo port install boost +cmake_scripts. Although that seems to install an older boost version, so I would recommend installing boost187 instead (latest version), which should not even require the +cmake_scripts option. CMake actually tries to find Boost 1.71.0 or higher.

@mvieth mvieth added module: cmake and removed status: triage Labels incomplete labels Jan 23, 2025
@bonomip
Copy link
Author

bonomip commented Jan 25, 2025

Thank you for your response!

If you run sudo port install boost, it defaults to installing Boost 1.76, not Boost 1.87 as you mentioned. Here's an example of what you might see:

$ sudo port install boost
--->  Computing dependencies for boost
The following dependencies will be installed:  boost176
Continue? [Y/n]:

But even if i install specifically boost187 the error still persist:

 -- Qt is not found.
CMake Error at cmake/pcl_find_boost.cmake:29 (find_package):
  Could not find a package configuration file provided by "Boost" (requested
  version 1.71.0) with any of the following names:

    BoostConfig.cmake
    boost-config.cmake

  Add the installation prefix of "Boost" to CMAKE_PREFIX_PATH or set
  "Boost_DIR" to a directory containing one of the above files.  If "Boost"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  CMakeLists.txt:428 (include)


-- Configuring incomplete, errors occurred!
paolobonomi @ ~/Develop/pcl/build [master]
$ port installed boost
None of the specified ports are installed.
paolobonomi @ ~/Develop/pcl/build [master]
$ port installed boost187
The following ports are currently installed:
  boost187 @1.87.0_0+no_single+no_static+python312 (active)
paolobonomi @ ~/Develop/pcl/build [master]  

The BoostConfig.cmake is present for boost187 but not for the default 176.

@mvieth
Copy link
Member

mvieth commented Jan 25, 2025

The BoostConfig.cmake is present for boost187

Okay, that is good. BoostConfig.cmake is definitely required.
I would tend to blame MacPorts for this problem. Apparently, BoostConfig.cmake is present in /opt/local/libexec/boost/1.87/lib/cmake/Boost-1.87.0/BoostConfig.cmake, but that is not a path where CMake will search (see https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-search-procedure ). Usually, it it the responsibility of a package manager to put files such as BoostConfig.cmake in a place where they can be found. Other ports such as Qt6 seems to make sure that CMake can find them: https://github.com/macports/macports-ports/blob/master/aqua/qt6/Portfile#L1200
I also found https://trac.macports.org/ticket/71642 : It seems like boost171, boost176, and boost178 now also install BoostConfig.cmake, but it is still in a directory where CMake will not look by default. In macports/macports-ports@c0f4706 , they added a fix for cadabra2 (when that is installed via MacPorts).
I think the MacPorts maintainers should be notified of this behaviour. Basically, find_package(Boost REQUIRED CONFIG) should work without setting Boost_DIR or CMAKE_PREFIX_PATH. I can open a ticket in their system (https://trac.macports.org/wiki/Tickets) in a few days when I have the time. Or, if you like, you could open the ticket.
As a temporary workaround, you can set -DBoost_DIR=/opt/local/libexec/boost/1.87/lib/cmake/Boost-1.87.0/ to let CMake find BoostConfig.cmake. Which is, of course, the solution that you already mentioned above. Although you said you had to set other Boost-related paths? I think setting Boost_DIR to the location of BoostConfig.cmake should be enough.

@mvieth
Copy link
Member

mvieth commented Feb 4, 2025

I just commented on this macports ticket and proposed a solution: https://trac.macports.org/ticket/71871
I think that is all I can do. On the PCL side, there should be no further action necessary.

@mvieth mvieth closed this as completed Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants