file(DOWNLOAD) offline mode

It would be great if CMake could simulate an absent Internet connection for file(DOWNLOAD) via CMAKE_FILE_DOWNLOAD_OFFLINE_MODE (or CMAKE_OFFLINE_MODE, the latter also may control the FetchContent_**() or another network operations) which could also potentially controlled by --offline flag.

It could help to debug some projects without actually disconnecting from the network.

1 Like

I agree, I have a lot of internet-using CMakeLists that also need to work offline, and have made mistakes a couple times when a CMake script didn’t work on a truly offline machine.

This flag would be vital for CI, where I didn’t find a way to disconnect the Internet to the CI runner programatically especially useful for cloud CI runners.

I am not aware of any Curl library option to disable the network. I think this would be a really useful capability for CI tests.

1 Like

Most CI ends up in a Docker container of some flavor. Is it possible to set up a network namespace in there[1] and just hide all network devices from the build commands (while keeping the connection to the CI mothership intact)?

[1] I mean, everything seems to just assume root inside the container anyways these days…

I’ll note that turning off CMake’s view of the network isn’t sufficient as commands that do pip install or the like also need to be silenced. I think the “hide the network” sandboxing is the best way to do that here.

Given the “root in a container” assumptions, you could just blackhole all DNS so that at least anything that does get out is a direct IP address connection…

Oh I think this docker container is a great suggestion. Yes, the CI systems I use work well with docker. So I will give that a try when I have time. Thanks…