I've got both the static and the dynamic versions of the boost libraries in /usr/lib. Now I'd like CMake to prefer the static versions during the linkage of my executable. What can I do?
For CMake, you need to add boost_program_options to the list of libraries, and IIRC this is done via SET(liblist boost_program_options) in your CMakeLists. txt .
One of my current projects relies on Boost. Python, which requires a more recent version of Boost (1.64) than the one (1.54) provided by my Linux distribution (Ubuntu 14.04).
You can check version. hpp inside Boost include dir (normally /usr/include/boost , you can use locate /boost/version. hpp or similar to get that) for BOOST_VERSION or BOOST_LIB_VERSION .
In your CMakeLists.txt
file:
set(Boost_USE_STATIC_LIBS ON) find_package(Boost REQUIRED ...)
Where I have ...
, you optionally put the names of the libraries you want to use, and then target_link_libraries(targetname ${Boost_LIBRARIES})
later below. If you have a fairly recent distribution of CMake, it should work exactly as advertised. I do it exactly this way in my own projects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With