如何使用(CMake Superbuild Boost Windows)正确下载Boost?
我正在尝试通过 externalProject_add 安装Boost,但我会遇到错误。
问题错误是什么意思,我该如何解决?
这是我拥有的错误消息:
Performing update step for 'boost-external'
No patch step for 'boost-external'
Performing configure step for 'boost-external'
'cp' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Msbuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241,5): e
rror MSB8066: Custom build for 'C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\Example_02_Boost\build\CMakeFiles\7a303cde471
9f69085ebded4413f3304\boost-external-mkdir.rule;C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\Example_02_Boost\build\CMakeF
iles\7a303cde4719f69085ebded4413f3304\boost-external-download.rule;C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\Example_02
_Boost\build\CMakeFiles\7a303cde4719f69085ebded4413f3304\boost-external-update.rule;C:\IBOIS57\_Code\Software\CPP\CMAKE\super
_build\Example_02_Boost\build\CMakeFiles\7a303cde4719f69085ebded4413f3304\boost-external-patch.rule;C:\IBOIS57\_Code\Software
\CPP\CMAKE\super_build\Example_02_Boost\build\CMakeFiles\7a303cde4719f69085ebded4413f3304\boost-external-configure.rule;C:\IB
OIS57\_Code\Software\CPP\CMAKE\super_build\Example_02_Boost\build\CMakeFiles\7a303cde4719f69085ebded4413f3304\boost-external-
build.rule;C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\Example_02_Boost\build\CMakeFiles\7a303cde4719f69085ebded4413f3304
\boost-external-install.rule;C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\Example_02_Boost\build\CMakeFiles\1a2a6d9ea64ba5
92f97cd191c1d5acb1\boost-external-complete.rule;C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\Example_02_Boost\build\CMakeF
iles\a70b522e33d20f4a0fb02fd1b3fdb173\boost-external.rule;C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\Example_02_Boost\CM
akeLists.txt' exited with code 9009. [C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\Example_02_Boost\build\boost-external.v
cxproj]
这是屏幕截图:
[![Enter Image Description在此处] [1]] [1] [1]:https://i.sstatic.net/hyrkm.jpg
这是我的完整cmakelists.txt
###############################################################################
#cmake + project name
###############################################################################
cmake_minimum_required(VERSION 3.10)
project(boostdemo)
###############################################################################
#create executable
###############################################################################
add_executable(boostdemo ${PROJECT_SOURCE_DIR}/main.cpp)
###############################################################################
#boost
###############################################################################
#https://github.com/BBO-repo/cpp-boost-cmake-superbuild
set( Boost_Bootstrap_Command ${CMAKE_BINARY_DIR}/boost-download/src/boost-external/bootstrap.sh && cp ${CMAKE_BINARY_DIR}/boost-download/src/boost-external-build/b2 ${CMAKE_BINARY_DIR}/boost-download/src/boost-external/)
set( Boost_b2_Command cd ${CMAKE_BINARY_DIR}/boost-download/src/boost-external && ./b2 )
include(ExternalProject)
ExternalProject_Add(
boost-external #library name that will be used for linking in the executable
GIT_REPOSITORY https://github.com/boostorg/boost.git
GIT_TAG boost-1.79.0
PREFIX boost-download
CONFIGURE_COMMAND ${Boost_Bootstrap_Command}
BUILD_COMMAND ${Boost_b2_Command} install
--without-python
--without-mpi
--disable-icu
--prefix=${CMAKE_SOURCE_DIR}/thirdparty/boost/
--threading=single,multi
--link=shared
--variant=release
-j12
INSTALL_COMMAND ""
)
set(Boost_LIBS ${CMAKE_SOURCE_DIR}/thirdparty/boost/lib/${CMAKE_STATIC_LIBRARY_PREFIX}boost_chrono${CMAKE_SHARED_LIBRARY_SUFFIX})
set(Boost_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/thirdparty/boost/include/)
###############################################################################
#link boost
###############################################################################
add_dependencies(boostdemo boost-external)
include_directories(boostdemo ${Boost_INCLUDE_DIR})
target_link_libraries(boostdemo ${Boost_LIBS})
I am trying to install boost by ExternalProject_Add but I get error.
Question What does the error mean and how can I resolve it?
This is the error message I have:
Performing update step for 'boost-external'
No patch step for 'boost-external'
Performing configure step for 'boost-external'
'cp' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Msbuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241,5): e
rror MSB8066: Custom build for 'C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\Example_02_Boost\build\CMakeFiles\7a303cde471
9f69085ebded4413f3304\boost-external-mkdir.rule;C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\Example_02_Boost\build\CMakeF
iles\7a303cde4719f69085ebded4413f3304\boost-external-download.rule;C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\Example_02
_Boost\build\CMakeFiles\7a303cde4719f69085ebded4413f3304\boost-external-update.rule;C:\IBOIS57\_Code\Software\CPP\CMAKE\super
_build\Example_02_Boost\build\CMakeFiles\7a303cde4719f69085ebded4413f3304\boost-external-patch.rule;C:\IBOIS57\_Code\Software
\CPP\CMAKE\super_build\Example_02_Boost\build\CMakeFiles\7a303cde4719f69085ebded4413f3304\boost-external-configure.rule;C:\IB
OIS57\_Code\Software\CPP\CMAKE\super_build\Example_02_Boost\build\CMakeFiles\7a303cde4719f69085ebded4413f3304\boost-external-
build.rule;C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\Example_02_Boost\build\CMakeFiles\7a303cde4719f69085ebded4413f3304
\boost-external-install.rule;C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\Example_02_Boost\build\CMakeFiles\1a2a6d9ea64ba5
92f97cd191c1d5acb1\boost-external-complete.rule;C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\Example_02_Boost\build\CMakeF
iles\a70b522e33d20f4a0fb02fd1b3fdb173\boost-external.rule;C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\Example_02_Boost\CM
akeLists.txt' exited with code 9009. [C:\IBOIS57\_Code\Software\CPP\CMAKE\super_build\Example_02_Boost\build\boost-external.v
cxproj]
This is the screenshot:
[![enter image description here][1]][1]
[1]: https://i.sstatic.net/HyrKM.jpg
This is my full CMakeLists.txt
###############################################################################
#cmake + project name
###############################################################################
cmake_minimum_required(VERSION 3.10)
project(boostdemo)
###############################################################################
#create executable
###############################################################################
add_executable(boostdemo ${PROJECT_SOURCE_DIR}/main.cpp)
###############################################################################
#boost
###############################################################################
#https://github.com/BBO-repo/cpp-boost-cmake-superbuild
set( Boost_Bootstrap_Command ${CMAKE_BINARY_DIR}/boost-download/src/boost-external/bootstrap.sh && cp ${CMAKE_BINARY_DIR}/boost-download/src/boost-external-build/b2 ${CMAKE_BINARY_DIR}/boost-download/src/boost-external/)
set( Boost_b2_Command cd ${CMAKE_BINARY_DIR}/boost-download/src/boost-external && ./b2 )
include(ExternalProject)
ExternalProject_Add(
boost-external #library name that will be used for linking in the executable
GIT_REPOSITORY https://github.com/boostorg/boost.git
GIT_TAG boost-1.79.0
PREFIX boost-download
CONFIGURE_COMMAND ${Boost_Bootstrap_Command}
BUILD_COMMAND ${Boost_b2_Command} install
--without-python
--without-mpi
--disable-icu
--prefix=${CMAKE_SOURCE_DIR}/thirdparty/boost/
--threading=single,multi
--link=shared
--variant=release
-j12
INSTALL_COMMAND ""
)
set(Boost_LIBS ${CMAKE_SOURCE_DIR}/thirdparty/boost/lib/${CMAKE_STATIC_LIBRARY_PREFIX}boost_chrono${CMAKE_SHARED_LIBRARY_SUFFIX})
set(Boost_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/thirdparty/boost/include/)
###############################################################################
#link boost
###############################################################################
add_dependencies(boostdemo boost-external)
include_directories(boostdemo ${Boost_INCLUDE_DIR})
target_link_libraries(boostdemo ${Boost_LIBS})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果它可以帮助某人,下面是我用
externalProject_add
获得Boost的Cmake Fragment。当时我只专注于标头零件,因此可能还不完整。我从来没有对此感到完全满意,最后转而使用VCPKG获得所有第三方依赖。从那以后,我一直很开心,尤其是在提升方面。实际上,我只是从我们的存储库中删除了此文件。因此,我强烈建议您查看VCPKG(或Conan或...),而不是
externalproject_add
。In case it helps someone, below is the cmake fragment I used to have for obtaining boost with
ExternalProject_Add
. I was focussed at the time on the header only parts so it may not be complete.I was never entirely happy with this and in the end switched to obtaining all of our third party dependencies with vcpkg. I have been much happier ever since, especially with regard to boost. In fact I just deleted this file from our repo. So I strongly recommend looking at vcpkg (or conan or ...) instead of
ExternalProject_Add
.