首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何正确下载Boost使用(CMake SuperBuild Boost Windows)?

如何正确下载Boost使用(CMake SuperBuild Boost Windows)?
EN

Stack Overflow用户
提问于 2022-06-16 22:25:34
回答 1查看 79关注 0票数 0

我试图安装boost的ExternalProject_Add,但我得到了错误。

问题这个错误意味着什么,我如何解决它?

这是我拥有的错误消息:

代码语言:javascript
运行
复制
 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]

这是截图:

1:https://i.stack.imgur.com/HyrKM.jpg

这是我的完整CMakeLists.txt

代码语言:javascript
运行
复制
###############################################################################
#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})
EN

回答 1

Stack Overflow用户

发布于 2022-06-29 05:04:10

如果它对某人有帮助,下面是我用ExternalProject_Add获得boost的cmake片段。当时我只把注意力集中在标题上,所以它可能不完整。

我对此并不完全满意,最后转而使用vcpkg获取所有第三方依赖项。从那以后,我变得更快乐了,尤其是在助推方面。事实上,我刚刚从我们的回购中删除了这个文件。所以我强烈建议看vcpkg (或者conan或.)而不是ExternalProject_Add

代码语言:javascript
运行
复制
if(WIN32)
    set( Boost_Bootstrap_Command bootstrap.bat )
    set( Boost_b2_Command b2.exe )
    set( Boost_version_dir /boost-1_77 )
else()
    set( Boost_Bootstrap_Command ./bootstrap.sh )
    set( Boost_b2_Command ./b2 )
    set( Boost_version_dir "")
endif()

ExternalProject_Add(git_boost
    URL https://boostorg.jfrog.io/artifactory/main/release/1.77.0/source/boost_1_77_0.tar.gz
    BUILD_IN_SOURCE 1
    CONFIGURE_COMMAND ${Boost_Bootstrap_Command}
    BUILD_COMMAND ""
    INSTALL_COMMAND ${Boost_b2_Command} --with-headers --with-math install --prefix=${CMAKE_CURRENT_BINARY_DIR}/boost
    TEST_COMMAND ""
)

add_library(ours_boost INTERFACE)
add_library(ours::boost ALIAS ours_boost)

target_include_directories(ours_boost INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/boost/include${Boost_version_dir})
message(${CMAKE_CURRENT_BINARY_DIR}/boost/include${Boost_version_dir})
add_dependencies(ours_boost git_boost)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72652500

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档