# FetchContent\_Declare() UPDATE\_DISCONNECTED and vcpkg

**URL:** <https://discourse.cmake.org/t/fetchcontent-declare-update-disconnected-and-vcpkg/11312>\
**Category:** Code\
**Created:** [July 23, 2024, 9:15pm UTC](https://discourse.cmake.org/t/fetchcontent-declare-update-disconnected-and-vcpkg/11312 "2024-07-23T21:15:43Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![silverqx](https://discourse.cmake.org/user_avatar/discourse.cmake.org/silverqx/32/2353_2.png) [@silverqx](https://discourse.cmake.org/u/silverqx)\
**Post date:** [July 23, 2024, 9:15pm UTC](https://discourse.cmake.org/t/fetchcontent-declare-update-disconnected-and-vcpkg/11312/1 "2024-07-23T21:15:43Z")

</div>

After upgrading to CMake 3.30 simple `FetchContent_Declare()` doesn’t work anymore with the vcpkg toolchain file used.

My CI pipelines started failing like [this](https://github.com/silverqx/TinyORM/actions/runs/10065521915/job/27826112068).

Here is the actual [code](https://github.com/silverqx/TinyORM-HelloWorld/blob/main/CMakeLists.txt#L32).

I’m **replacing** the GIT\_TAG with the **commit ID** inside my GitHub actions, so at the end of the day it looks like this:

```auto
FetchContent_Declare(TinyOrm
    GIT_REPOSITORY https://github.com/silverqx/TinyORM.git
    GIT_TAG 5c0bce878777d02bcacefe7d7309e8e1a0b88eb6
    OVERRIDE_FIND_PACKAGE
)

```

I don’t understand why this is happening, I know that the vcpkg internally sets `UPDATE_DISCONNECTED` (somewhere/somehow) but I would expect that my FetchContent commands will work.

As you can see I’m using `OVERRIDE_FIND_PACKAGE` to make the fetchcontent-ed project available during the `find_package(TinyOrm)` call, until 3.30. 🤔

What am I doing wrong? Thx for any advice.

---

<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:** [July 23, 2024, 9:56pm UTC](https://discourse.cmake.org/t/fetchcontent-declare-update-disconnected-and-vcpkg/11312/2 "2024-07-23T21:56:19Z")

</div>

Looks like you must have also updated the project, since the first line now starts with:

```cmake
cmake_minimum_required(VERSION 3.22...3.30 FATAL_ERROR)

```

So we can eliminate some things from the discussion, can you please change that line back to whatever it was before. The 3.30 would have to have been some older CMake version. If you made any other changes to the project, ideally undo those as well so that the only thing changing will be the version of CMake used in the CI job. Once you’ve reverted those changes, please try re-running the same job as before (i.e. still using CMake 3.30) and post the results.

---

<div class="post-metadata">

**Author:** ![silverqx](https://discourse.cmake.org/user_avatar/discourse.cmake.org/silverqx/32/2353_2.png) [@silverqx](https://discourse.cmake.org/u/silverqx)\
**Post date:** [July 24, 2024, 6:28am UTC](https://discourse.cmake.org/t/fetchcontent-declare-update-disconnected-and-vcpkg/11312/3 "2024-07-24T06:28:20Z")

</div>

Nothing changed as you can see from the [commit history](https://github.com/silverqx/TinyORM-HelloWorld/commits/main/), the only thing that was changed was the CMake policy max. version from 3.29 to 3.30, I always want to use all the new CMake policies to make sure I’m compatible.

Which CMP do you think can cause this, only one I see is CMP170 but it talks about the `FETCHCONTENT_FULLY_DISCONNECTED` and not about `UPDATE_DISCONNECTED`, are these two settings somehow related?

**The following isn’t true, read also the next post.**

I’m pretty sure the CI pipeline finishes successfully with CMake max. version set to 3.29.

Here is the [Revert](https://github.com/silverqx/TinyORM-HelloWorld-TinyDrivers/commits/main/) and [here](https://github.com/silverqx/TinyORM/actions/runs/10071637187) is the re-invoked CI pipeline.

---

<div class="post-metadata">

**Author:** ![silverqx](https://discourse.cmake.org/user_avatar/discourse.cmake.org/silverqx/32/2353_2.png) [@silverqx](https://discourse.cmake.org/u/silverqx)\
**Post date:** [July 24, 2024, 6:49am UTC](https://discourse.cmake.org/t/fetchcontent-declare-update-disconnected-and-vcpkg/11312/4 "2024-07-24T06:49:54Z")

</div>

Ok, now it starts to be a little messy 😁, everything about Reverting the CMake max. version to 3.29 isn’t true as I reverted it for the wrong HelloWorld example project (I have two) 😊.

As you can see there were two CI pipeline launches, the first one failed again, that was with 3.30 max. version and the same build folders (I’m not deleting build folder to have faster rebuilds, this CI pipeline is running on selfhosted GH runner, and is the same problem I have described in the first post).

The second run (I manually reinvoked this failed run) was also with max. version 3.30 but I deleted all build folders and as you can see it finished successfully.

So no revert to CMake max. 3.29 happened at all and it finished successfully after manually deleting the build folders.

I screwed it up, sry about this.

---

<div class="post-metadata">

**Author:** ![silverqx](https://discourse.cmake.org/user_avatar/discourse.cmake.org/silverqx/32/2353_2.png) [@silverqx](https://discourse.cmake.org/u/silverqx)\
**Post date:** [July 24, 2024, 7:02am UTC](https://discourse.cmake.org/t/fetchcontent-declare-update-disconnected-and-vcpkg/11312/5 "2024-07-24T07:02:52Z")

</div>

[Here](https://github.com/silverqx/TinyORM/actions/runs/10071936627) is the CI pipeline run with the second HelloWorld example (on which I reverted the CMake max. version to 3.29 **but didn’t invoke it** ), and this run is with max. version 3.30 with deleted build folders and it finished successfully.

So from my view this problem happened if I upgraded max. version from 3.29 to 3.30, with CMake 3.30 and build folders from cmake 3.29.

I think no need to put more effort into it from my side to reproduce it.

---

<div class="post-metadata">

**Author:** ![silverqx](https://discourse.cmake.org/user_avatar/discourse.cmake.org/silverqx/32/2353_2.png) [@silverqx](https://discourse.cmake.org/u/silverqx)\
**Post date:** [July 24, 2024, 7:00pm UTC](https://discourse.cmake.org/t/fetchcontent-declare-update-disconnected-and-vcpkg/11312/6 "2024-07-24T19:00:06Z")

</div>

Ok, now I discovered that the problem is more serious because I must always delete the build folder to avoid this problem. Even if the build folder was created by the CMake 3.30.

So I tried to decrease the max. CMake version to 3.29 as you proposed (this time I didn’t screw it) and the build was successful.

Is this an expected behavior or a bug?

---

<div class="post-metadata">

**Author:** ![silverqx](https://discourse.cmake.org/user_avatar/discourse.cmake.org/silverqx/32/2353_2.png) [@silverqx](https://discourse.cmake.org/u/silverqx)\
**Post date:** [July 25, 2024, 2:03pm UTC](https://discourse.cmake.org/t/fetchcontent-declare-update-disconnected-and-vcpkg/11312/7 "2024-07-25T14:03:14Z")

</div>

I invested ~6 hours to debug this line by line and here is what I have found.

Setting the `set_property(DIRECTORY PROPERTY EP_UPDATE_DISCONNECTED ON/OFF)` has no effect, setting the `-DFETCHCONTENT_UPDATES_DISCONNECTED:BOOL=OFF/ON` or `-DFETCHCONTENT_UPDATES_DISCONNECTED_TINYORM:BOOL=OFF/ON` has no effect.

I don’t know if setting `FETCHCONTENT_UPDATES_DISCONNECTED/_XYZ` should work or not.

But setting the `set_property(DIRECTORY PROPERTY EP_UPDATE_DISCONNECTED ON/OFF)` must work as is described in the [docs](https://cmake.org/cmake/help/latest/module/ExternalProject.html#update-step-options) to populate the default value.

The reason why the `EP_UPDATE_DISCONNECTED` doesn’t work is, that the [`can_fetch_default`](https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/ExternalProject/shared_internal_commands.cmake#L1590) is initialized too late and isn’t available for the [`_ep_write_gitupdate_script()`](https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/ExternalProject/shared_internal_commands.cmake#L1563) command that needs it a few lines above, the `configure_file()` that needs it is [here](https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/ExternalProject/shared_internal_commands.cmake#L541) and the template file where the value should be used is [here](https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/ExternalProject/gitupdate.cmake.in#L48).

I tried to move this [`can_fetch_default`](https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/ExternalProject/shared_internal_commands.cmake#L1590) init. logic above the [`_ep_write_gitupdate_script()`](https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/ExternalProject/shared_internal_commands.cmake#L1563) command and everything started working, not only the `EP_UPDATE_DISCONNECTED`, but now I can control these updates by the `FETCHCONTENT_UPDATES_DISCONNECTED/_XYZ` option/s.

I want to tell that isn’t fully possible to understand code like this in a few hours and also there is a lot of written in the docs.

---

<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:** [July 26, 2024, 1:18am UTC](https://discourse.cmake.org/t/fetchcontent-declare-update-disconnected-and-vcpkg/11312/8 "2024-07-26T01:18:10Z")

</div>

Thanks for the analysis, your assessment is correct. I’ve opened a new [bug report](https://gitlab.kitware.com/cmake/cmake/-/issues/26164) for this, and a fix should be following shortly.
