简体   繁体   English

是否可以将 cmake FetchContent 与安装依赖项一起使用

[英]Is it possible to use cmake FetchContent with install dependencies

I want to build an application using cppzmq and i'm looking for advice to properly managing dependencies in cmake.我想使用 cppzmq 构建一个应用程序,我正在寻找在 cmake 中正确管理依赖项的建议。

cmake_minimum_required(VERSION 3.16)

project(myTest)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED true)

include(FetchContent)

FetchContent_Declare(
    zmq
    GIT_REPOSITORY https://github.com/zeromq/libzmq.git
    GIT_TAG        v4.3.2
)
FetchContent_MakeAvailable(zmq)

FetchContent_Declare(
    cppzmq
    GIT_REPOSITORY https://github.com/zeromq/cppzmq.git
    GIT_TAG        v4.6.0
)
FetchContent_MakeAvailable(cppzmq)

I execute with the following我执行以下

mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=staging

The problem I am having is that zmq is a dependency of cppzmq and i'm not sure how to resolve it using cmake.我遇到的问题是 zmq 是 cppzmq 的依赖项,我不确定如何使用 cmake 解决它。

For example if i disable the cppzmq content and run make install, zmq will be installed and cppzmq will find it (once i re-enable it and rerun cmake)例如,如果我禁用 cppzmq 内容并运行 make install,将安装 zmq 并且 cppzmq 将找到它(一旦我重新启用它并重新运行 cmake)

Thanks in advance提前致谢

Brian布赖恩

Turns out this is an issue with the version of cppzmq i was using and has since been fixed in master原来这是我使用的 cppzmq 版本的问题,并且已经在 master 中修复

https://github.com/zeromq/cppzmq/issues/436 https://github.com/zeromq/cppzmq/issues/436

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM