Skip to content

Instantly share code, notes, and snippets.

@bingmann
Last active January 30, 2020 15:08
Show Gist options
  • Save bingmann/a7fa6276012bd416fa81c580c9eedd36 to your computer and use it in GitHub Desktop.
Save bingmann/a7fa6276012bd416fa81c580c9eedd36 to your computer and use it in GitHub Desktop.
Build a "mini-boost" library directly from cmake including only some of the library-needing boost parts.
### use Boost libraries ###
include(FetchContent)
FetchContent_Populate(
boost-src
URL https://dl.bintray.com/boostorg/release/1.71.0/source/boost_1_71_0.tar.bz2
URL_HASH MD5=4cdf9b5c2dc01fb2b7b733d5af30e558
SOURCE_DIR extlib/boost
)
include_directories(SYSTEM ${CMAKE_CURRENT_BINARY_DIR}/extlib/boost/)
# glob boost sources
file(GLOB TBT_MINI_BOOST_SOURCES
${CMAKE_CURRENT_BINARY_DIR}/extlib/boost/libs/system/src/*.cpp
${CMAKE_CURRENT_BINARY_DIR}/extlib/boost/libs/regex/src/*.cpp
)
add_library(tbt_mini_boost STATIC "${TBT_MINI_BOOST_SOURCES}")
set_target_properties(tbt_mini_boost PROPERTIES LINKER_LANGUAGE CXX)
set(Boost_LIBRARIES tbt_mini_boost)
@bingmann
Copy link
Author

It auto-downloads the source as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment