File download ignores HTTP_PROXY set in CMakeLists
I work behind a proxy and I have to use some 3rd party tools. I cannot assume that proxy is set on every computer that will use this script.
Though proxy is set in the script file(DOWNLOAD)
and also ExternalProject_Add
does not work. It work only if the environment variable http_proxy (or HTTP_PROXY on Windows) is set before running this script.
Eg. on Windows:
set HTTP_PROXY=http://myproxy:8080 & set HTTPS_PROXY=http://myproxy:8080 & cmake .
The affected cmake version is 3.12.0.
cmake_minimum_required(VERSION 3.8.0)
project(external VERSION 0.1.0 LANGUAGES CXX)
include(ExternalProject)
set(ENV{HTTP_PROXY} "myproxyx:8080")
ExternalProject_Add(
catch-external
PREFIX ${CMAKE_BINARY_DIR}/Catch
URL https://github.com/philsquared/Catch/archive/v1.10.0.tar.gz
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
LOG_DOWNLOAD ON
)
ExternalProject_Get_Property(catch-external source_dir)
include_directories(${source_dir}/single_include)
# It also fails:
# file(DOWNLOAD https://github.com/philsquared/Catch/archive/v1.10.0.tar.gz ./catch.tar.gz)
add_executable(main main.cpp )
add_dependencies(main catch-external)