[CMake] Building Boost as an ExternalProject

Michael Powell mwpowellhtx at gmail.com
Mon Oct 2 16:17:55 EDT 2017


On Mon, Oct 2, 2017 at 3:58 PM, Jacob Barrett <jbarrett at pivotal.io> wrote:
> The Apache Geode Native project is building Boost as an external project.
> You may want to look at our setup for inspiration. It builds correction on
> Windows with VS, Solaris x86 and SPARC with Solaris Studio, Linux with GCC
> and OS X with Xcode.Right now we are purely header only so if you need some
> libs you will have to tweak a little.
>
> https://github.com/apache/geode-native/blob/develop/dependencies/boost/CMakeLists.txt

Thank you for the heads up Jacob.

I could not find anything appreciably different that would make a
difference. It seems like EP_Add is ignoring the Working Directory. It
also does not seem to matter if I specify the full path for either
bootstrap and/or b2.

It seems to be making a little more progress, only sort of...

I get the following two messages:

output: Building Boost.Build engine

Failed to build Boost.Build engine.
Please consult bootstrap.log for further diagnostics.

You can try to obtain a prebuilt binary from

   http://sf.net/project/showfiles.php?group_id=7586&package_id=72941

Also, you can file an issue at http://svn.boost.org
Please attach bootstrap.log in that case.


error: The system cannot find the path specified.
'.\build.bat' is not recognized as an internal or external command,
operable program or batch file.


With the output from the build in Visual Studio:

2>  Performing build step for 'boost'
2>  CMake Error at
G:/Source/Spikes/nanomsg/cppnngswig-working/build/boost-prefix/src/boost-stamp/boost-build-Debug.cmake:16
(message):
2>    Command failed: The system cannot find the file specified
2>
2>     'b2.exe' '--with-test' 'toolset=msvc-14.0' 'variant=debug'
'link=static' 'stage'
'--prefix=G:/Source/Spikes/nanomsg/cppnngswig-working/boostbuild'

> In our project the depends on boost we just add have:
> target_link_libraries(... boost)
>
> -Jake
>
>
>
> On Mon, Oct 2, 2017 at 12:38 PM Michael Powell <mwpowellhtx at gmail.com>
> wrote:
>>
>> On Mon, Oct 2, 2017 at 3:06 PM, Michael Powell <mwpowellhtx at gmail.com>
>> wrote:
>> > On Mon, Oct 2, 2017 at 2:34 PM, Michael Powell <mwpowellhtx at gmail.com>
>> > 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.
>>
>> This is the line from the Microsoft.CppCommon.targets that was failing.
>>
>>     <CustomBuild
>>       Sources                     ="@(CustomBuild)"
>>       BuildSuffix                 ="$(_BuildSuffix)"
>>
>>       TrackerLogDirectory         ="%(CustomBuild.TrackerLogDirectory)"
>>       MinimalRebuildFromTracking
>> ="%(CustomBuild.MinimalRebuildFromTracking)"
>>
>>       TLogReadFiles               ="@(CustomBuildTLogReadFiles)"
>>       TLogWriteFiles              ="@(CustomBuildTLogWriteFiles)"
>>       TrackFileAccess             ="$(TrackFileAccess)"
>>       ToolArchitecture            ="$(CustomBuildToolArchitecture)"
>>       TrackerFrameworkPath        ="$(CustomBuildTrackerFrameworkPath)"
>>       TrackerSdkPath              ="$(CustomBuildTrackerSdkPath)"
>>
>>       AcceptableNonZeroExitCodes
>> ="%(CustomBuild.AcceptableNonZeroExitCodes)"
>>       >
>>
>> And the output message is this:
>>
>> 2>  CMake Error at
>>
>> G:/Source/Spikes/nanomsg/cppnngswig-working/build/boost-prefix/src/boost-stamp/boost-configure-Debug.cmake:16
>> (message):
>> 2>    Command failed: The system cannot find the file specified
>> 2>
>> 2>     'bootstrap.bat'
>> '--prefix=G:/Source/Spikes/nanomsg/cppnngswig-working/boostbuild'
>> 2>
>> 2>    See also
>> 2>
>> 2>
>> G:/Source/Spikes/nanomsg/cppnngswig-working/build/boost-prefix/src/boost-stamp/boost-configure-*.log
>>
>> However, I've set the Working Directory to the bootstrap.bat location,
>> so I do not know how that could be missed.
>>
>> > From the Boost VC project file:
>> >
>> >       <Command
>> > Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">setlocal
>> > C:\Dev\CMake\bin\cmake.exe -E make_directory
>> > G:/Source/Spikes/nanomsg/cppnngswig-working/repos/boost
>> > if %errorlevel% neq 0 goto :cmEnd
>> > C:\Dev\CMake\bin\cmake.exe -E make_directory
>> >
>> > G:/Source/Spikes/nanomsg/cppnngswig-working/build/boost-prefix/src/boost-build
>> > if %errorlevel% neq 0 goto :cmEnd
>> > C:\Dev\CMake\bin\cmake.exe -E make_directory
>> > G:/Source/Spikes/nanomsg/cppnngswig-working/build/boost-prefix
>> > if %errorlevel% neq 0 goto :cmEnd
>> > C:\Dev\CMake\bin\cmake.exe -E make_directory
>> > G:/Source/Spikes/nanomsg/cppnngswig-working/build/boost-prefix/tmp
>> > if %errorlevel% neq 0 goto :cmEnd
>> > ** C:\Dev\CMake\bin\cmake.exe -E make_directory
>> >
>> > G:/Source/Spikes/nanomsg/cppnngswig-working/build/boost-prefix/src/boost-stamp/$(Configuration)
>> > ** if %errorlevel% neq 0 goto :cmEnd
>> > C:\Dev\CMake\bin\cmake.exe -E make_directory
>> > G:/Source/Spikes/nanomsg/cppnngswig-working/build/boost-prefix/src
>> > if %errorlevel% neq 0 goto :cmEnd
>> > C:\Dev\CMake\bin\cmake.exe -E touch
>> >
>> > G:/Source/Spikes/nanomsg/cppnngswig-working/build/boost-prefix/src/boost-stamp/$(Configuration)/boost-mkdir
>> > if %errorlevel% neq 0 goto :cmEnd
>> > :cmEnd
>> > ** endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
>> > :cmErrorLevel
>> > exit /b %1
>> > :cmDone
>> > if %errorlevel% neq 0 goto :VCEnd</Command>
>> >
>> > ** which line number was the error
>> >
>> > Honestly, that does not make much sense since the directories do in fact
>> > exist.
>> >
>> > The boost-configure-err.log shows this result:
>> >
>> > The system cannot find the path specified.
>> > '.\build.bat' is not recognized as an internal or external command,
>> > operable program or batch file.
>> >
>> > Which leads me to believe that possibly I need to tell the target to
>> > operate in a more appropriate working directory?
>> >
>> >> 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
>> --
>>
>> Powered by www.kitware.com
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Kitware offers various services to support the CMake community. For more
>> information on each offering, please visit:
>>
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/cmake


More information about the CMake mailing list