cmakebjamboost-build

boost bjam fails as a cmake external project


I am trying to add boost bjam build as an external cmake project.

This is my cmake code to build boost

include(ExternalProject)
ExternalProject_Add(
        libboost
        PREFIX ${BOOST_BUILD_DIRECTORY}
        SOURCE_DIR ${BOOST_SOURCE_DIRECTORY}
        BINARY_DIR ${BOOST_SOURCE_DIRECTORY}
        CONFIGURE_COMMAND ""
        BUILD_COMMAND ${b2Path}
                --build-dir=${BOOST_BUILD_DIRECTORY}
                --link=static
                --variant=debug
                --build-type=complete
        INSTALL_COMMAND ${b2Path}
                --prefix=${BOOST_BUILD_DIRECTORY}/${BoostFolderName}
                --link=static
                --variant=debug
                --build-type=complete
        INSTALL_DIR ${BOOST_BUILD_DIRECTORY}/${BoostFolderName}
        LOG_BUILD ON
        LOG_INSTALL ON
        )
message("boostbuild done")

The problem here is, once in a while it fails. the same step for bjam doesn't fail if invoked through command line.

The error is

 type "C:\Users\adhal\AppData\Local\Temp\jam6818c95b4.000" > "C:\build-sdk-Desktop_Qt_5_11_3_MSVC2017_64bit-Debug\external\boost\boost\bin.v2\libs\program_options\build\msvc-14.1\debug\address-model-64\link-static\runtime-link-static\threading-multi\libboost_program_options-variant-vc141-mt-sgd-x64-1_73-static.cmake"

...failed text-action C:\build-sdk-Desktop_Qt_5_11_3_MSVC2017_64bit-Debug\external\boost\boost\bin.v2\libs\program_options\build\msvc-14.1\debug\address-model-64\link-static\runtime-link-static\threading-multi\libboost_program_options-variant-vc141-mt-sgd-x64-1_73-static.cmake...
...skipped <pC:\proj\sdk\external\boost-program-options\stage\lib\cmake\boost_program_options-1.73.0>libboost_program_options-variant-vc141-mt-sgd-x64-1_73-static.cmake for lack of <pC:\build-sdk-Desktop_Qt_5_11_3_MSVC2017_64bit-Debug\external\boost\boost\bin.v2\libs\program_options\build\msvc-14.1\debug\address-model-64\link-static\runtime-link-static\threading-multi>libboost_program_options-variant-vc141-mt-sgd-x64-1_73-static.cmake...
compile-c-c++ C:\build-sdk-Desktop_Qt_5_11_3_MSVC2017_64bit-Debug\external\boost\boost\bin.v2\libs\regex\build\msvc-14.1\debug\address-model-64\link-static\runtime-link-static\threading-multi\regex.obj

When I run the exact same step, it doesn't fild the file(C:\Users\adhal\AppData\Local\Temp\jam6818c95b4.000). Since it's a temporary file, it's deleted.

Can someone tell me, if I am doing anything wrong ? Is it possible to specify a separate temporary directory for bjam ?


Solution

  • Got same issue. In my case moving build folder up helped.

    Issue check story - tmp .bat file contains

    type "C:\Users\amorozov\AppData\Local\Temp\jam43e8891f.000" > "bin.v2\libs\program_options\build\msvc-14.1\debug\address-model-64\link-static\runtime-link-static\threading-multi\libboost_program_options-variant-vc141-mt-sgd-x64-1_73-static.cmake"

    Running it from cmake binary dir where build happens fails too. Splitting command to type and dir for target directory succeeds. Writing to file with shorter name succeeds. Checked total filepath length for .cmake file and it's over 256 bytes. It seems as cmd doesn't allow redirecting to really long pathnames. Moving whole project few directories up solved my issue.

    If that doesn't help, check your tmp .bat file by running b2 under windbg with breakpoint on kernel32!DeleteFileW. Filename is du poi(@esp+4). Hope that helps.