问题描述
遵循 FetchContent 文档,例如使用类似的东西
Following the FetchContent documentation, e.g. using something like
FetchContent_Declare(
gitache_package_libcwd_r
GIT_REPOSITORY "https://github.com/CarloWood/libcwd.git"
GIT_TAG "master"
)
FetchContent_MakeAvailable(
gitache_package_libcwd_r
)
源代码被克隆到 $ {CMAKE_BINARY_DIR}/_ deps/gitache_package_libcwd_r-src/
中.
如何将源代码放在其他地方,例如/opt/gitache/libcwd_r/src/gitache_package_libcwd_r
(就像我要使用 ExternalProject
>的 PREFIX
为/opt/gitache/libcwd_r
)?
How can I make it put the source code elsewhere, like /opt/gitache/libcwd_r/src/gitache_package_libcwd_r
(as it would be when I'd be using ExternalProject
with a PREFIX
of /opt/gitache/libcwd_r
)?
推荐答案
如果有人偶然发现了这个问题以寻找答案,我发现至少 可以替换"$ {CMAKE_BINARY_DIR}/_ deps"
部分,方法是在调用 FetchContent_Declare
之前设置 FETCHCONTENT_BASE_DIR
.我不确定是否可以进行更精细的调整.如果您使用 FetchContent_Populate的扩展版本,则似乎有可能,但是使用imho有几个缺点.
In case anyone stumbles on this question looking for an answer, I found that at least it is possible to replace the "${CMAKE_BINARY_DIR}/_deps"
part by setting FETCHCONTENT_BASE_DIR
before the call to FetchContent_Declare
. I'm not sure if more fine tuned manipulation is possible or not. It seems possible, if you use the extended version of FetchContent_Populate, but using that has several drawbacks imho.
例如
set(FETCHCONTENT_BASE_DIR "/opt/gitache/libcwd_r")
FetchContent_Declare(... etc (see question)
将克隆到/opt/gitache/libcwd_r/gitache_package_libcwd_r-src/
并使用/opt/gitache/libcwd_r/gitache_package_libcwd_r-build
作为构建目录.
will clone into /opt/gitache/libcwd_r/gitache_package_libcwd_r-src/
and use/opt/gitache/libcwd_r/gitache_package_libcwd_r-build
as build directory.
这篇关于如何获取FetchContent下载到特定位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!