Questions tagged [fetchcontent]

A CMake module allowing project authors to have dependent projects downloaded and set up during the dependent project's configuration phase.

33 questions
7
votes
2 answers

Why does FetchContent prefer subdirectory-subsumption vs installation of dependencies?

Consider two software projects, proj_a and proj_b, with the latter depending on the former; and with both using CMake. When reading about modern CMake, one gets the message that the "appropriate" way to express dependencies is via target…
einpoklum
  • 118,144
  • 57
  • 340
  • 684
6
votes
1 answer

How can I avoid target name collisions when using CMake FetchContent?

When I use CMake FetchContent to import OpenCV, it works fine: include(FetchContent) # Fetch OpenCV FetchContent_Declare( opencv GIT_REPOSITORY https://gitee.com/aiproach/opencv.git GIT_TAG …
Cook21
  • 61
  • 3
4
votes
2 answers

Is it possible to include protobuf using cmake's FetchContent?

I want to use protobuf in my C++ library. All dependencies so far are included using cmake's FetchContent module. I want to do the same with protobuf. However, I run into the following problem: Unknown CMake command "protobuf_generate_cpp". Any…
bit4fox
  • 2,021
  • 2
  • 13
  • 8
3
votes
2 answers

How can I avoid clashes with targets "imported" with FetchContent_MakeAvailable?

Suppose I'm writing an app, and managing its build with CMake; and I also want to use a library, mylib, via the FetchContent mechanism. Now, my own CMakeLists.txt defines a bunch of targets, and so does mylib's CMakeLists.txt. If I were to install…
einpoklum
  • 118,144
  • 57
  • 340
  • 684
2
votes
1 answer

How to use properly use cmake fetchcontent() to find or fetch boost

What is the best way to add a dependency on Boost when using the CMake FetContent module. In researching this issue I found this answer which seems to work fine for compiled boost libraries like thread or filesystem but does not work for header only…
2
votes
1 answer

How to add compile options to CMake FetchContent dependency using target interface

I have a dependency included using CMake's FetchContent that needs to be built using some build flag (cmake -DFLAG=ON). This question is also asked in here and the provided answer seems to be to set a variable on the current scope using set. For…
lobis
  • 145
  • 1
  • 10
2
votes
1 answer

How to use FetchContent_Populate with Eigen?

I want to use FetchContent to automatically manage the dependency to Eigen for my project, which works in general. However, when using the recommended method of FetchContent_Declare() and FetchContent_MakeAvailable() a subsequent call to install…
Devon Cornwall
  • 957
  • 1
  • 7
  • 17
2
votes
0 answers

default build location changed with CMake when building HDF5 through fetch content

I have been using CMake's fetch content functionality quite a bit recently to have self-containing build scripts. So far it works quite nicely, consider the following simplified CMakeLists.txt file: cmake_minimum_required(VERSION…
tom
  • 361
  • 3
  • 11
1
vote
1 answer

How do I make a C++ 3rd party library feched with CMake's FetchContent not show any warnings?

I'm working on a C++ project that uses wxWidgets with a CMake script I wrote to resolve this dependency when I build it. To accomplish that I used CMake's module FetchContent and it currently works properly, resolving the dependency, compiling and…
1
vote
2 answers

Why is a FetchContent using a different TAG than the one I specified? How can I resolve this?

I am trying to use a certain library with FetchContent: FetchContent_Declare( Catch2 GIT_REPOSITORY https://github.com/catchorg/Catch2.git GIT_TAG 3f0283de7a9c43200033da996ff9093be3ac84dc GIT_PROGRESS TRUE GIT_SHALLOW …
alfC
  • 14,261
  • 4
  • 67
  • 118
1
vote
0 answers

Error: Missing library 'libopencv_gapi.so.4.6.0' and no known rule to make it

I'm trying to include the OpenCV library in my project using CMake, but I'm encountering an error. This is my first time working with CMake, so I'm not sure what could be causing the issue. The error message I'm getting is: ninja: error:…
DPRCode
  • 11
  • 2
1
vote
0 answers

Adding 3rd part library (taco) by FetchContent_Declare causes issues

I would like to add a 3rd party lib (called taco) to my project. In the CMakeLists.txt of my project I did the following: FetchContent_Declare( taco GIT_REPOSITORY https://github.com/tensor-compiler/taco.git GIT_TAG…
Di Miao
  • 206
  • 2
  • 7
1
vote
0 answers

How to properly configure FetchContent_Declare for static build of dependencies

In the dependencies subdirectory of my CMake project (Win10, VS2017) I have multiple libraries retrieved and build through the FetchContent_Declare()/FetchContent_MakeAvailable() mechanism. I do have a problem with libcurl though namely some of the…
rbaleksandar
  • 8,713
  • 7
  • 76
  • 161
1
vote
1 answer

Usage of URL_HASH in FetchContent_Declare

I am a newbie in CMake and trying to understand the following CMake command FetchContent_Declare(curl URL https://github.com/curl/curl/releases/download/curl-7_75_0/curl-7.75.0.tar.xz URL_HASH …
afp_2008
  • 1,940
  • 1
  • 19
  • 46
1
vote
0 answers

Eigen not found when using FetchContent

I am attempting to include the Eigen libraries into my project. I am using CMake and FetchContent to build the project. I was able to include another library using the same method. A snippit of my "dependencies.cmake" is included below: if (NOT…
mlaza
  • 11
  • 2
1
2 3