[CMake] Building Boost as an ExternalProject

paul pfultz2 at yahoo.com
Mon Oct 2 16:54:35 EDT 2017


For building boost with cmake you can use this cmake script:

https://github.com/pfultz2/cget/blob/master/cget/cmake/boost.cmake

You can drop it in at the top of the boost tree and it will build Boost.Build
and then build boost with b2. This will map the cmake toolchain to the boost
toolchain so the builds are consistent.

On Mon, 2017-10-02 at 14:34 -0400, Michael Powell wrote:
> Hello,
> 
> This question has been raised from time to time I think. I am trying
> to build Boost as an ExternalProject, but I am ending up with an
> error: 'cmd.exe' returned with exit code 1. Along these lines.
> 
> Perhaps I have involved one too many variables, but I doubt it. Ignore
> the cross-plat stuff, this is building on Windows for the purposes of
> this conversation.
> 
> I tried to configure ExternalProject_Add with as much verbosity as
> possible, but unfortunately the process is not especially talkative as
> it turns out. But for the EC 1.
> 
> set (BOOST_VERSION  1.65.1)
> 
> message (STATUS "Adding Boost ${BOOST_VERSION} as an external project.")
> 
> set (BOOST_BOOTSTRAP_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/boostbuild)
> set (BOOST_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/boostbuild)
> set (BOOST_BUILD_PREFIX ${BOOST_BOOTSTRAP_PREFIX}/boost)
> set (BOOST_GIT_REPO_DIR ${CMAKE_CURRENT_SOURCE_DIR}/repos/boost)
> 
> if (WIN32)
>     set (BOOST_BOOTSTRAP_CMD ${BOOST_GIT_REPO_DIR}/bootstrap.bat)
>     # It was bjam at one point; it is now b2
>     set (BOOST_BUILD_CMD ${BOOST_GIT_REPO_DIR}/b2.exe)
> elseif (UNIX)
>     set (BOOST_BOOTSTRAP_CMD ./${BOOST_GIT_REPO_DIR}/bootstrap.sh)
>     set (BOOST_BUILD_CMD ./${BOOST_GIT_REPO_DIR}/b2)
> endif ()
> 
> #  TODO: TBD: For now, assuming only 64-bit address models.
> set (BOOST_ADDR_MODEL 64)
> 
> # TODO: TBD: align with the toolchain that we want to build through
> the CMake here... For now assuming:
> if (MSVC_VERSION EQUAL 1900)
>     set (BOOST_TOOLSET msvc-14.0)
> endif ()
> 
> ExternalProject_Add (boost
>     # PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/repos/boost
>     GIT_REPOSITORY git at github.com:boostorg/boost.git
>     GIT_TAG boost-${BOOST_VERSION}
>     GIT_PROGRESS ON
>     CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:STRING=${BOOST_INSTALL_PREFIX}
>     SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/repos/boost
>     CONFIGURE_COMMAND ${BOOST_BOOTSTRAP_CMD} --
> prefix=${BOOST_BOOTSTRAP_PREFIX}
>     # I do not necessarily care about any other Boost build options;
> but that could change the further I get into unit testing, at least so
> long as I will be adopting the test library for usage.
>     BUILD_COMMAND ${BOOST_BUILD_CMD} --with-test
> toolset=${BOOST_TOOLSET} variant=debug link=static stage
> --prefix=${BOOST_BUILD_PREFIX}
>     LOG_DOWNLOAD ON
>     LOG_UPDATE ON
>     LOG_CONFIGURE ON
>     LOG_BUILD ON
>     LOG_INSTALL ON
> )
> 
> Cheers,
> 
> Michael Powell

.


More information about the CMake mailing list