[CMake] cmake and boost

James C. Sutherland James.Sutherland at utah.edu
Fri Mar 19 15:34:27 EDT 2010


> 
> Why not just let the user decide where they'd like to get boost, and simplify your build system by just using find_package(Boost)?
> 
> For example, this is all you need for a simple boost-using app...
> 
> find_package(Boost 1.34.0 REQUIRED COMPONENTS filesystem system)
> include_directories(${Boost_INCLUDE_DIR})
> add_executable(yourapp yourapp.cpp)
> target_link_libraries(yourapp ${Boost_LIBRARIES})
> 
Indeed this is the best approach, although it isn't quite that straightforward in all cases since the FindBoost.cmake module functions a bit differently with the CMake installation than it does with the bjam installation.  For example, I do something like:

if( BOOST_CMAKE )
  set(Boost_USE_STATIC ON)
  find_package( Boost REQUIRED COMPONENTS ${boost_comps} NO_MODULE )
else()
  set(Boost_USE_STATIC_LIBS ON)
  find_package( Boost REQUIRED COMPONENTS ${boost_comps} )
endif()

where I define BOOST_CMAKE if I have a cmake-based boost installation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100319/9d6c6a7d/attachment.htm>


More information about the CMake mailing list