ExternalProject: CMake ignores proxy settings on Windows
When behind a proxy and HTTPS_PROXY variable is not set CMake will not download files using ExternalProject_Add. While this environment variable is standard on Linux, on Windows proxy is usually set up by Internet Explorer settings. One workaround is to download the file by using Powershell, which detects proxy settings and downloads the file.
Minimal example - computer needs to be behind proxy:
cmake_minimum_required(VERSION 3.1)
project(proxy_fail_example)
include(ExternalProject)
ExternalProject_Add(
gtest
URL https://github.com/google/googletest/archive/release-1.8.0.zip
URL_HASH SHA256=f3ed3b58511efd272eb074a3a6d6fb79d7c2e6a0e374323d1e6bcbcc1ef141bf
DOWNLOAD_NAME googletest-1.8.0.zip
DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gtest
INSTALL_COMMAND ""
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
)
When building the project with: cmake --build . --config Debug
CMake will try to download the file, but it will just timeout.
I tested and reproduced it on CMake 3.1 and 3.10.1, probably other versions have the same problem.