I am trying to build gnucash on ubuntu with some updated boost libs. I am using cmake-3.21.1 but have also tried with 3.16.3.
I want to link/include against boost 1.75. In order to do that i built boost as (all the gory details):
- sudo mkdir -p /opt/software/boost/boost_1_75
- sudo chmod -R 755 /opt/software
- cd /opt/software/boost/boost_1_75
- wget -O boost_1_75_0.tar.gz https://sourceforge.net/projects/boost/files/boost/1.75.0/boost_1_75_0.tar.gz/download
- tar -xzvf boost_1_75_0.tar.gz
- cd boost_1_75
- ./bootstrap.sh --prefix=/opt/software
- ./b2
- ./b2 install
which will give me (as expected) directories
- /opt/software/include/boost
- /opt/software/lib/libboost*
So far, so good.
Now i try to configure gnucash as follows (extracted gnucash code resides in $SRCROOT/gnucash):
- cd $SRCROOT
- mkdir gnucash-build
- cd gnucash-build
- export BOOST_ROOT=/opt/software; export CC=/usr/bin/clang; export CXX=/usr/bin/clang++; /opt/software/cmake/cmake-3.21.1/bin/cmake -DBOOST_ROOT=$BOOST_ROOT $SRCROOT/gnucash-build
The relevant section in the CMakeLists.txt is
if (NOT DEFINED ${BOOST_ROOT})
set(BOOST_ROOT $ENV{BOOST_ROOT})
find_package (Boost COMPONENTS date_time regex locale filesystem system program_options)
message(STATUS "1.1: ${BOOST_ROOT}")
else()
find_package (Boost 1.67.0 COMPONENTS date_time regex locale filesystem system program_options)
message(STATUS "1.2: ${BOOST_ROOT}")
endif()
message(STATUS "2: Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
Running
export BOOST_ROOT=/opt/software; export CC=/usr/bin/clang; export CXX=/usr/bin/clang++; /opt/software/cmake/cmake-3.21.1/bin/cmake -DBOOST_ROOT=$BOOST_ROOT $SRCROOT/gnucash-build
gives me:
1.1: /opt/software
2: Boost_INCLUDE_DIRS: /usr/include
so i know it enters the correct case.
However, Boost_INCLUDE_DIRS should be /opt/software/include/boost and not '/usr/include'
I also tried without (default) and with (which i added):
cmake_policy(SET CMP0074 NEW)
Neither appears to work.
I am not sure on how to about debugging this issue. Likely i am doing something wrong here. Any pointers are greatly appreciated.
EDIT 1
Doing find_package (Boost 1.75.0 COMPONENTS date_time regex locale filesystem system program_options)
instead of
find_package (Boost COMPONENTS date_time regex locale filesystem system program_options)
will actually do what i want.
However, i would have expected that, without specifying the exact version, by specifying BOOST_ROOT, the cmake compiler will first look into the specified directory and take whatever version it finds there and use it.
From the docs (https://cmake.org/cmake/help/latest/module/FindBoost.html):
BOOST_ROOT, BOOSTROOT
Preferred installation prefix.