Hi all,
I have been trying to get Boost working with CMake. What I did almost a year ago is detailed here: CMake with Boost and policy CMP0167 . And that still works, thankfully.
There is just one problem which I do not understand – it isn’t prioritising the path in ${BOOST_ROOT}. I thought it should?
My source code currently has these 3 lines:
## Set the minimum version and the required components
set (BOOST_MIN_VERSION 1.85.0)
set (BOOST_REQUIRED_COMPONENTS program_options filesystem headers)
## Locate Boost using the Boost-provided BoostConfig.cmake
find_package (Boost ${BOOST_MIN_VERSION} COMPONENTS ${BOOST_REQUIRED_COMPONENTS})
I’m currently using Ubuntu 25.10, which installs cmake/Boost-1.88.0/BoostConfig.cmake through the libboost1.88-dev package. In /usr/local/boost/, I have Boost 1.90 installed by downloading and compiling it.
I also have ${BOOST_ROOT} set to /usr/local/boost/.
If I leave the above 3 lines as-is, it uses 1.88 and fails (because I haven’t installed every Boost 1.88 packges).
If I change the first line from “1.85.0” to “1.90.0”, then it finds 1.90 and proceeds perfectly.
I guess I have misunderstood ${BOOST_ROOT}. I thought its purpose was to ensure it is searched first.
Is there an environment variable I could set or a change I can make to my CMakeLists.txt to make it look in /usr/local/boost/ before the system-level paths?
(The remainder of the Boost section of my CMakeLists.txt is probably not relevant, but just in case it is, it is here: QScores-Archiver/src/cmake/boost.cmake at master · rwanwork/QScores-Archiver · GitHub .)
Thank you!
Ray
PS: Of course, another solution is to just install all of the Ubuntu packages that it needs – but I was hoping to use what I have set up in /usr/local/boost/.