I'm trying to compile Boost as shared libraries and make them a dependency of my cross platform CMake project.
For that, I compiled boost for win32, x64 and linux where my boost folder structure looks like:
- boost_1_69_0/
- boost/
- stage/
- win32
- lib
- x64
- lib
- linux
- lib
Then I'm doing:
set(BOOST_INCLUDEDIR ${CMAKE_CURRENT_SOURCE_DIR}/../external/boost_1_69_0)
set(BOOST_LIBRARYDIR ${CMAKE_CURRENT_SOURCE_DIR}/../external/boost_1_69_0/stage/win32)
find_package(Boost REQUIRED COMPONENTS filesystem)
And getting:
CMake Error at C:/Program Files/CMake/share/cmake-3.13/Modules/FindBoost.cmake:2100 (message):
Unable to find the requested Boost libraries.
Boost version: 1.69.0
Boost include path: C:/bla/SW/cmake-template/external/boost_1_69_0
Could not find the following Boost libraries:
boost_filesystem
Is that a bug?
If I move the lib
folder from inside win32
to it's parent directory, i.e:
- boost_1_69_0/
- boost/
- stage/
- lib
which is the default way boost's b2 build stuff, then it's all working. But then I can't hold different boost binaries for different platforms.
EDIT:
using set(Boost_DEBUG ON)
I found out my boost is compiled with Visual Studio v141 toolset while my project is using v140, and so FindBoost
is looking for boost_filesystem-vc140-mt-x64-1_69
and not boost_filesystem-vc140-mt-x64-1_69
.
I guess the problem has shifted to either find a way to force searching for v141 or (better) use --layout=system
and find a way to force it to always look for boost_filesystem
. Is there a way of doing that?