Search code examples
linuxcmakeboost-pool

How to use cmake to find the boost pool library?


I've installed boost like this on Ubuntu 14.04:

sudo apt-get install libboost-all-dev libboost-dev

If I have the following in my CMakeLists.txt file:

SET ( Boost_DEBUG               1   )
SET ( Boost_USE_STATIC_LIBS     ON  )
SET ( Boost_USE_MULTITHREADED   ON  )
SET ( Boost_USE_STATIC_RUNTIME  ON  )
FIND_PACKAGE ( Boost COMPONENTS log regex pool date_time REQUIRED )

Cmake has no problem finding other boost libraries, but it cannot find pool. I get the following:

CMake Error at /usr/share/cmake-2.8/Modules/FindBoost.cmake:1131 (message):
Unable to find the requested Boost libraries.
Boost version: 1.54.0
Boost include path: /usr/include
Could not find the following static Boost libraries:
    boost_pool

I can see the files are where they should be, along with the rest of the boost includes:

> locate pool/pool.hpp
/usr/include/boost/pool/pool.hpp

Is there a bug in cmake 2.8.12 where it expects pool (a header-only library) to have a .a or .so file, or am I missing something?


Solution

  • Since Boost.Pool is header-only, you shouldn't list it in the find_package call.

    If the find_package(Boost ...) call succeeds, it will have located the path to the Boost includes, and this will mean Boost.Pool will automatically be available just by adding ${Boost_INCLUDE_DIRS} to a target_include_directories or include_directories call.