I'm trying to use a CMake script to compile a Boost-based application on Windows.
The header-only libraries work fine, but CMake fails to find the libraries (the following Boost libraries could not be found: boost_serialization
). The relevant part of the CMake script is:
# Path where CMake can find additional libraries
SET(CMAKE_PREFIX_PATH Libs)
# Boost
SET(Boost_ADDITIONAL_VERSIONS "1.47" "1.47.0")
SET(Boost_USE_STATIC_LIBS ON)
find_package(Boost REQUIRED COMPONENTS serialization)
I have a folder called "Libs" inside my project where third-party libraries such as DevIL and Boost are stored, so I set this first. It works fine for Devil and Boost header-only stuff, so I assume I should not need the BOOST_ROOT variable.
The Boost installation is the standard source distribution from boost.org which I compiled with BJam. The libraries are stored in boost_1_47_0in.v2libs
, and I didn't change anything in the build process.
I think it is a bit odd, that the boost_1_47_0libs
folder doesn't contain any library files but BJam files and other stuff, but that shouldn't be a problem since this seems to be the normal way to build Boost on Windows from the source.
I looked at the Debug output from the FindBoost.cmake
file (I'm using the default script from CMake 2.8) and it doesn't seem to look into bin.v2
. Instead it searches boost_ROOT/lib
, but when I copied the content from bin.v2libs
to lib it still didn't find anything.
So what is an elegant way to find Boost that will also work on other platforms with common Boost distributions?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…