全。
我决定使用新的cmake宏下载外部依赖项。我从Catch2库的文档中提取了示例代码。
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和移动网络)。我得到以下错误:
[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!
是否有可能一次下载依赖项,检查修订,而不尝试每次连接到远程服务器?
发布于 2021-05-05 20:40:23
文档 for FetchContent_Populate
表示,您完全可以使用FETCHCONTENT_UPDATES_DISCONNECTED
缓存变量获得所需的内容:
FETCHCONTENT_UPDATES_DISCONNECTED
..。这..。禁用更新阶段。因此,如果以前没有下载内容,则启用此选项时仍将下载该内容。这可以加快配置阶段..。默认情况下,它是OFF
。
因此,将此变量设置为全局ON
,或者只针对Catch2,将变量FETCHCONTENT_UPDATES_DISCONNECTED_Catch2
设置为ON
。
https://stackoverflow.com/questions/67408357
复制相似问题