Created
February 10, 2020 00:29
-
-
Save loopunit/b655e97f8f9b0a8243f2a9fea8899ef3 to your computer and use it in GitHub Desktop.
Boost ExternalProject_Add reference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set(boost_BOOTSTRAP_COMMAND) | |
if(UNIX) | |
set(boost_BOOTSTRAP_COMMAND ./bootstrap.sh) | |
set(boost_B2_COMMAND ./b2) | |
elseif(WIN32) | |
set(boost_BOOTSTRAP_COMMAND bootstrap.bat) | |
set(boost_B2_COMMAND b2.exe) | |
endif() | |
# cmake default is mulththreaded<debug>dll | |
set(boost_THREADING multi) | |
set(boost_RUNTIME shared) | |
if (EXISTS ${CMAKE_MSVC_RUNTIME_LIBRARY}) | |
string(TOUPPER ${CMAKE_MSVC_RUNTIME_LIBRARY} CMAKE_MSVC_RUNTIME_LIBRARY_UPPER) | |
if(${CMAKE_MSVC_RUNTIME_LIBRARY_UPPER} STREQUAL "MULTITHREADED") | |
set(boost_RUNTIME static) | |
elseif(${CMAKE_MSVC_RUNTIME_LIBRARY_UPPER} STREQUAL "MULTITHREADEDDEBUG") | |
set(boost_RUNTIME static) | |
elseif(${CMAKE_MSVC_RUNTIME_LIBRARY_UPPER} STREQUAL "MULTITHREADEDDLL") | |
set(boost_RUNTIME shared) | |
elseif(${CMAKE_MSVC_RUNTIME_LIBRARY_UPPER} STREQUAL "MULTITHREADEDDEBUGDLL") | |
set(boost_RUNTIME shared) | |
endif() | |
endif() | |
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPER) | |
if (${CMAKE_BUILD_TYPE_UPPER} STREQUAL "DEBUG") | |
set(boost_VARIANT debug) | |
else() | |
set(boost_VARIANT release) | |
endif() | |
set(boost_BUILD ${CMAKE_CURRENT_BINARY_DIR}/boost) | |
set(boost_INSTALL ${CMAKE_INSTALL_PREFIX}) | |
set(boost_CMAKE_INSTALL ${boost_INSTALL}/cmake) | |
set(boost_INCLUDE_DIR ${boost_INSTALL}/include) | |
set(boost_LIB_DIR ${boost_INSTALL}/lib) | |
set(boost_MSVC_TOOLSET vc142) | |
ExternalProject_Add(external_boost | |
PREFIX boost | |
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/boost" | |
BUILD_IN_SOURCE 1 | |
CONFIGURE_COMMAND ${boost_BOOTSTRAP_COMMAND} ${boost_MSVC_TOOLSET} | |
BUILD_COMMAND | |
${boost_B2_COMMAND} --prefix=${boost_INSTALL} --cmakedir=${boost_CMAKE_INSTALL} --build-type=minimal --build-dir=${boost_BUILD} --layout=system --without-python --without-mpi --disable-icu toolset=msvc variant=${boost_VARIANT} link=static threading=${boost_THREADING} runtime-link=${boost_RUNTIME} architecture=x86 address-model=64 install | |
INSTALL_COMMAND "" | |
INSTALL_DIR ${boost_INSTALL} | |
) | |
macro(find_boost) | |
set(BOOST_ROOT ${CMAKE_INSTALL_PREFIX}) | |
set(Boost_USE_STATIC_LIBS ON) | |
set(Boost_USE_MULTITHREADED ON) | |
find_package(Boost | |
COMPONENTS | |
atomic chrono container context contract coroutine date_time exception fiber filesystem graph iostreams locale log log_setup math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l nowide prg_exec_monitor program_options random regex serialization stacktrace_noop stacktrace_windbg stacktrace_windbg_cached system test_exec_monitor thread timer type_erasure unit_test_framework wave wserialization | |
) | |
if(Boost_FOUND) | |
message("Boost found! ${Boost_VERSION_STRING}") | |
else() | |
message("Boost not found!") | |
endif() | |
endmacro() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment