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

system boost found even when building our own and other boost problems #627

Closed
KrisThielemans opened this issue Nov 18, 2021 · 0 comments · Fixed by #628
Closed

system boost found even when building our own and other boost problems #627

KrisThielemans opened this issue Nov 18, 2021 · 0 comments · Fixed by #628
Assignees
Labels
Milestone

Comments

@KrisThielemans
Copy link
Member

USE_SYSTEM_BOOST=OFF

On Ubuntu 20.04, if boost is installed via apt, but we set USE_SYSTEM_BOOST=OFF, CMake (in dependent projects such as ISMRMD) finds the system boost anyway. This is despite us passing BOOST_ROOT etc

set(Boost_CMAKE_ARGS
-DBOOST_INCLUDEDIR:PATH=${BOOST_ROOT}/include/
-DBOOST_LIBRARYDIR:PATH=${BOOST_LIBRARY_DIR}
-DBOOST_ROOT:PATH=${BOOST_ROOT}
)

I think what's going on is that Ubuntu 20.04 uses Boost 1.71.0 which comes with BoostConfig.cmake. (We currently build Boost 1.65.0 which doesn't install BoostConfig.cmake). Presumably FindBoost.cmake tries to find a "config" version first before even looking at BOOST_ROOT.

The result is that some compilations could use our installed boost include files, while the linking will happen against the system version. This leads to linking problems like this

/usr/bin/ld: CMakeFiles/test_ismrmrd.dir/test_acquisitions.cpp.o: in function `__static_initialization_and_destruction_0(int, int) [clone .constprop.141]':
test_acquisitions.cpp:(.text.startup+0xa1): undefined reference to `boost::unit_test::ut_detail::auto_test_unit_registrar::auto_test_unit_registrar(boost::unit_test::basic_cstring<char const>, boost::unit_test::basic_cstring<char const>, unsigned long, boost::unit_test::decorator::collector&)'

or run-time crashes.

This was first observed by @NicoleJurjew.

USE_SYSTEM_BOOST=ON

In this case we want to pass the location on, and do

if (BOOST_ROOT)
set(Boost_CMAKE_ARGS ${Boost_CMAKE_ARGS} -DBOOST_ROOT:PATH=${BOOST_ROOT})
endif()

however, CMake allows another variable BOOSTROOT for the same purpose, as well as Boost_DIR to find a "config" version. We should therefore set those as well.

@KrisThielemans KrisThielemans added this to the v3.1.x milestone Nov 18, 2021
@KrisThielemans KrisThielemans self-assigned this Nov 18, 2021
KrisThielemans added a commit to KrisThielemans/SIRF-SuperBuild that referenced this issue Nov 18, 2021
- when USE_SYSTEM_BOOST=OFF, set Boost_NO_SYSTEM_PATHS=ON to increase our chances
of finding our own version
- when USE_SYSTEM_BOOST=OFF, pass BOOSTROOT and Boost_DIR to projects (when set)

Fixes SyneRBI#627
KrisThielemans added a commit to KrisThielemans/SIRF-SuperBuild that referenced this issue Nov 18, 2021
- when USE_SYSTEM_BOOST=OFF, set Boost_NO_SYSTEM_PATHS=ON to increase our chances
of finding our own version
- when USE_SYSTEM_BOOST=OFF, pass BOOSTROOT and Boost_DIR to projects (when set)

Fixes SyneRBI#627
@KrisThielemans KrisThielemans modified the milestones: v3.1.x, v3.2 Nov 18, 2021
KrisThielemans added a commit that referenced this issue Nov 19, 2021
- when USE_SYSTEM_BOOST=OFF, set Boost_NO_SYSTEM_PATHS=ON to increase our chances
of finding our own version
- when USE_SYSTEM_BOOST=OFF, pass BOOSTROOT and Boost_DIR to projects (when set)

Fixes #627
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant