首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何避免使用CMake FetchContent进行更新检查?

如何避免使用CMake FetchContent进行更新检查?
EN

Stack Overflow用户
提问于 2021-05-05 20:29:19
回答 1查看 2.1K关注 0票数 7

全。

我决定使用新的cmake宏下载外部依赖项。我从Catch2库的文档中提取了示例代码。

代码语言:javascript
运行
复制
include(FetchContent)

FetchContent_Declare(
    Catch2
    GIT_REPOSITORY https://github.com/catchorg/Catch2.git
    GIT_TAG        v2.13.4
)
FetchContent_GetProperties(Catch2)
if(NOT Catch2_POPULATED)
    FetchContent_Populate(Catch2)
    add_subdirectory(${catch2_SOURCE_DIR} ${catch2_BINARY_DIR})
endif()

这个解决方案很好用,除了当我离线时重新启动cmake的能力(只有我和我的笔记本电脑没有wifi和移动网络)。我得到以下错误:

代码语言:javascript
运行
复制
[0/7] Performing update step for 'catch2-populate'
fatal: «https://github.com/catchorg/Catch2.git/» недоступно: Could not resolve host: github.com
CMake Error at /Users/evgeny.proydakov/repository/ihft/build/_deps/catch2-subbuild/catch2-populate-prefix/tmp/catch2-populate-gitupdate.cmake:97 (execute_process):
  execute_process failed command indexes:

    1: "Child return code: 128"

FAILED: catch2-populate-prefix/src/catch2-populate-stamp/catch2-populate-update 
cd /Users/evgeny.proydakov/repository/ihft/build/_deps/catch2-src && /usr/local/Cellar/cmake/3.20.1/bin/cmake -P /Users/evgeny.proydakov/repository/ihft/build/_deps/catch2-subbuild/catch2-populate-prefix/tmp/catch2-populate-gitupdate.cmake
ninja: build stopped: subcommand failed.

CMake Error at /usr/local/Cellar/cmake/3.20.1/share/cmake/Modules/FetchContent.cmake:1012 (message):
  Build step for catch2 failed: 1
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.20.1/share/cmake/Modules/FetchContent.cmake:1141:EVAL:2 (__FetchContent_directPopulate)
  /usr/local/Cellar/cmake/3.20.1/share/cmake/Modules/FetchContent.cmake:1141 (cmake_language)
  /usr/local/Cellar/cmake/3.20.1/share/cmake/Modules/FetchContent.cmake:1184 (FetchContent_Populate)
  .cmake/icmake.cmake:46 (FetchContent_MakeAvailable)
  CMakeLists.txt:10 (include)

-- Configuring incomplete, errors occurred!

是否有可能一次下载依赖项,检查修订,而不尝试每次连接到远程服务器?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-05 20:40:23

文档 for FetchContent_Populate表示,您完全可以使用FETCHCONTENT_UPDATES_DISCONNECTED缓存变量获得所需的内容:

FETCHCONTENT_UPDATES_DISCONNECTED ..。这..。禁用更新阶段。因此,如果以前没有下载内容,则启用此选项时仍将下载该内容。这可以加快配置阶段..。默认情况下,它是OFF

因此,将此变量设置为全局ON,或者只针对Catch2,将变量FETCHCONTENT_UPDATES_DISCONNECTED_Catch2设置为ON

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67408357

复制
相关文章

相似问题

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