# Prevent fatal\_error on FetchContent\_Declare

**URL:** https://discourse.cmake.org/t/prevent-fatal-error-on-fetchcontent-declare/10091
**Category:** Usage
**Created:** [February 14, 2024, 3:22pm UTC](https://discourse.cmake.org/t/prevent-fatal-error-on-fetchcontent-declare/10091 "2024-02-14T15:22:05Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![etiennemlb](https://discourse.cmake.org/user_avatar/discourse.cmake.org/etiennemlb/32/3147_2.png) [@etiennemlb](https://discourse.cmake.org/u/etiennemlb)
#### Post date: [February 14, 2024, 3:22pm UTC](https://discourse.cmake.org/t/prevent-fatal-error-on-fetchcontent-declare/10091/1 "2024-02-14T15:22:06Z")

</div>

How do you use `FetchContent_Declare/FetchContent_MakeAvailable` (FetchContent\_Populate) without having it throw a fatal\_error if the download fails ?

The use case is like so:  
find\_package, if it fails do  
a `FetchContent_Declare/FetchContent_MakeAvailable` using a git url, if it fails do  
a `FetchContent_Declare/FetchContent_MakeAvailable` using a targz url, if it fails do  
a `FetchContent_Declare/FetchContent_MakeAvailable` using a filesystem targz, etc…

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [February 17, 2024, 6:39am UTC](https://discourse.cmake.org/t/prevent-fatal-error-on-fetchcontent-declare/10091/2 "2024-02-17T06:39:46Z")

</div>

You may need to implement your own `DOWNLOAD_COMMAND` to do that. You are allowed to have multiple URLs to download though (I think `file://` works), but mixing `GIT_REPOSITORY` and `URL` doesn’t seem to be trivial (as the ordering likely needs to be explicit or remembered when parsing arguments).

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [February 24, 2024, 8:59am UTC](https://discourse.cmake.org/t/prevent-fatal-error-on-fetchcontent-declare/10091/3 "2024-02-24T08:59:40Z")

</div>

`FetchContent_MakeAvailable()` always succeeds or issues a fatal error. It does not support the “optional” finding behavior like you have with `find_package()`. I have no plans to change that, it would add significant complexity, but for implementing the feature and all projects which would then have to potentially handle such a case.
