[CMake] cmake and boost

Michael Jackson mike.jackson at bluequartz.net
Fri Mar 19 15:43:53 EDT 2010


On Mar 19, 2010, at 3:34 PM, James C. Sutherland wrote:

>>
>> 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.

Hmm, I don't have to do any of that for my Boost-Cmake installation.  
There is a "trick" to configuring the Boost_CMake build so that it has  
the same layout as a bjam built boost.

___________________________________________________________
Mike Jackson                      www.bluequartz.net
Principal Software Engineer       mike.jackson at bluequartz.net
BlueQuartz Software               Dayton, Ohio




More information about the CMake mailing list