I’m trying to get some software built on CentOS 7 with modules. The boost module is loaded and BOOST_DIR is set as an environment variable to the appropriate path.
I’m trying to get FindBoost to pick up the module installation rather than the (older) system installation.
I have:
message( STATUS "BOOST_DIR: $ENV{BOOST_DIR}" )
if( NOT $ENV{BOOST_DIR} STREQUAL "" )
message( STATUS "searching for boost in environment path: $ENV{BOOST_DIR}" )
set( BOOST_ROOT $ENV{BOOST_DIR} )
set( ENV{BOOST_ROOT} $ENV{BOOST_DIR} )
endif()
if( DEFINED BOOST_ROOT )
message( STATUS "Setting boost installation location as: " ${BOOST_ROOT} )
set( Boost_NO_SYSTEM_PATHS ON ) # only look in the user-specified location - nowhere else!
endif()
set( BOOST_MIN_VERSION "1.54.0" )
find_package( Boost ${BOOST_MIN_VERSION} MODULE REQUIRED COMPONENTS ${boost_comps} )
The message statements all output as expected, but then boost is not found. I’ve tried this with and without the MODULE keyword and it doesn’t make a difference.
Version information:
cmake version: 3.18.2
Boost version: 1.69.0
Is there some trick to make FindBoost.cmake actually respect the hints I’m passing it?
Things I’ve tried:
Invoke cmake with -DBOOST_LIBRARYDIR=$BOOST_DIR/lib -DBOOST_INCLUDEDIR=$BOOST_DIR/include
Invoke cmake with -DBOOST_ROOT=$BOOST_DIR
Note that I’m also setting Boost_NO_SYSTEM_PATHS=ON, but boost still reports that it found an “unsuitable” system install in /usr that wasn’t compatible with my specified minimum version.
So it seems that FindBoost is ignoring everything I’m telling it about where to look.
BOOST_ROOT is picked up correctly within FindBoost: BOOST_ROOT = "/uufs/chpc.utah.edu/sys/installdir/boost/1.69.0i19-impi"
This is the location where boost is installed (the only subdirs there are include and lib).
FindBoost apparently ignores the fact that I’m setting Boost_NO_SYSTEM_PATHS. For example:
location of version.hpp: /usr/include/boost/version.hpp
I’m specifically trying to avoid the installation in /usr and find the one loaded by the module in the /uufs path.
This seemingly confirms my suspicion that FindBoost is ignoring all of the path information I’m trying to provide it.
Observations when running with the --debug-find flag:
I was able to confirm that no Config module was found (although it indicated that it looked in a large number of places for it, including system libraries). This is despite the fact that I had the MODULE keyword in the call to find_package (see original post).
The variable CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH contains the desired boost path, but also others including system level ones in /usr. My guess is that this is expected.
Hmm - after all of this churn, wiping out my whole build directory and starting over made it work. So something must have been cached that broke things.
I probably have a different problem, but I’m trying to build the same project with boost 1.69 on both Debian 9 and CentOS 7, and FindBoost works without any environment variables on Debian 9 but not CentOS 7.
I’ve noticed that on Debian 9, the headers/libs are installed in:
/usr/include/boost
and on CentOS 7, these are in:
/usr/include/boost169/
I’m wondering if this differently named subdirectory is causing CMake to fail. It’s not obvious to me how to patch the module to get it to find this subdirectory.