In 2011, CMake implemented a file(DOWNLOAD INACTIVITY_TIMEOUT) option that uses cURL CURLOPT_LOW_SPEED_TIME to fail much earlier than a TIMEOUT option would when the connection speed is extremely slow. However, some systems intentionally block downloads, but do so in a way that fools the underlying cURL library into not tripping INACTIVITY_TIMEOUT. Rather than try to figure out a direct fix in cURL for this apparently longstanding problem, we instead decide to implement a CMake configure-time internet connectivity detection.
When a CTest test is comprised of a CMake script, this test can be setup as a FIXTURES_SETUP to avoid calling it repeatedly for each test, instead just once for a set of tests.
The key technique here is the URL connectivitycheck.gstatic.com/generate_204 that is used by Android devices to check connectivity. Any similar URL with zero or tiny download size would also be suitable.