Opened 5 months ago
Last modified 5 months ago
#71871 assigned defect
pg boost: for cmake projects, add boost to module path
Reported by: | dershow | Owned by: | mascguy (Christopher Nielsen) |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 2.10.5 |
Keywords: | portgroup | Cc: | michaelld (Michael Dickens) |
Port: | pg-boost |
Description (last modified by mascguy (Christopher Nielsen))
When the CMake pgs are in use, add Boost to the module path. Something like this, which was recently added to port cadabra2
:
# Ensure CMake can find the selected boost port # TODO: Do this automatically via Boost portgroup cmake.module_path-append \ [boost::lib_dir]/cmake
Original description:
I'm not really sure if this is a cmake issue or a boost issue. I'm trying to build a non-macports app (OpenModelica) using cmake, and worked fine until recently. When I run cmake I now get these errors:
CMake Error at /opt/local/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake:233 (message): Could NOT find Boost (missing: Boost_INCLUDE_DIR program_options filesystem) Call Stack (most recent call first): /opt/local/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake:603 (_FPHSA_FAILURE_MESSAGE) /opt/local/share/cmake-3.31/Modules/FindBoost.cmake:2409 (find_package_handle_standard_args)
I see this ticket that is having the same problem: #71642 Which suggests that it's a boost issue, but then has a fix of the cadabra2 port, where the problem was showing up.
I do have boost176 and boost181 ports installed. I hadn't installed either directly, so they are dependents of other ports. I'm not familiar enough with Boost to understand how to make cmake "find" it.
Change History (7)
comment:1 Changed 5 months ago by dershow
comment:2 Changed 5 months ago by ryandesign (Ryan Carsten Schmidt)
Description: | modified (diff) |
---|
MacPorts offers multiple versions of boost, installed to nonstandard locations so that they do not conflict with one another, so it's not unexpected that you would need to tell your build system which one you want it to use.
Perhaps you used to (also?) have the old boost port installed which installs to the standard location and which cmake would probably find automatically. The old boost port will be removed eventually so you shouldn't rely on it.
comment:3 Changed 5 months ago by mascguy (Christopher Nielsen)
As of this writing, boost176 and later include cmake files. However, as Ryan mentioned, they're all segregated to avoid conflicts.
If you were having this issue with a particular port, the fix would depend on the project. For cmake-based builds, the following would usually suffice:
# Ensure CMake can find the selected boost port # TODO: Do this automatically via Boost portgroup cmake.module_path-append \ [boost::lib_dir]/cmake
For your case, you should be able to add this arg to cmake
:
-DCMAKE_PREFIX_PATH="/opt/local/share/cmake/Modules;/opt/local/libexec/boost/1.76/lib/cmake"
comment:4 Changed 5 months ago by mascguy (Christopher Nielsen)
Cc: | mascguy removed |
---|---|
Owner: | set to mascguy |
Status: | new → assigned |
comment:5 Changed 5 months ago by mascguy (Christopher Nielsen)
Port: | boost176 added; boost181 removed |
---|
comment:6 Changed 5 months ago by mascguy (Christopher Nielsen)
Description: | modified (diff) |
---|---|
Keywords: | portgroup added |
Port: | pg-boost added; boost176 removed |
Summary: | cmake can't find boost → pg boost: for cmake projects, add boost to module path |
Version: | → 2.10.5 |
comment:7 Changed 5 months ago by mvieth (Markus Vieth)
I think it is very important to have the BoostConfig.cmake (and BoostConfigVersion.cmake) installed at a location where CMake can easily find it, without having to set CMAKE_PREFIX_PATH or Boost_DIR manually. This is especially important for user projects (that are not macports themselves). Some macports seem to create redirection files in locations where CMake searches by default, for example Qt6 creates /opt/local/lib/cmake/Qt6/Qt6Config.cmake which "redirects" to the actual CMake config file at /opt/local/libexec/qt6/lib/cmake/Qt6/Qt6Config.cmake , see https://github.com/macports/macports-ports/blob/c03064414e44f263230e5ad7ceb4d39d8e40faae/aqua/qt6/Portfile#L1204
For reference, CMake searches in these locations: https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-search-procedure . Note that the paths have wildcards (<name>*) to allow for multiple versions of the same package.
So perhaps it could be a solution to copy the behaviour of Qt6 and create a BoostConfig.cmake "redirection file" in a location such as /opt/local/lib/cmake/Boost176/BoostConfig.cmake (alternatively, /opt/local/lib/Boost176/BoostConfig.cmake or /opt/local/lib/Boost176/cmake/BoostConfig.cmake should work as well). Same for BoostConfigVersion.cmake. This would also work if multiple Boost versions are installed, for example the BoostConfig.cmake from Boost187 would then be installed in /opt/local/lib/cmake/Boost187/BoostConfig.cmake. Since CMake (in newer versions) removed the FindBoost module in favour of BoostConfig.cmake (see https://cmake.org/cmake/help/latest/module/FindBoost.html and https://cmake.org/cmake/help/latest/policy/CMP0167.html ) more and more project will depend on BoostConfig.cmake being easily findable by CMake.
I did get it to compile by explicitly adding the path to my cmake command:
But, this did not used to be necessary, so I'm not sure what's changed, and if there is a standard way to include boost, from cmake without needing to find the version and the path?