1

In a cmake project, I download an external project with FetchContent. I am behind a proxy, but this is no problem locally, where I can set the environment variables HTTP_PROXY and HTTPS_PROXY.

However, I want to use an automation server for testing and deployment. On this automation server for some reason, I can set environment variables for the build step, but not for the configure step where FetchContent tries to download the external project.

All I can do is give command-line arguments to cmake.

Solutions that work, but I do not want:

  • hardcode the proxy into my CMakeLists.txt by setting an environment variable in cmake
  • set the environment variable globally on the automation server

Solutions that do not work:

  • giving the http proxy as a cmake cache variable (i.e. cmake -DHTTP_PROXY=...)

Is there any way to give the http proxy to cmake via a command-line option?

1 Answer 1

3
+50

All I can do is give command-line arguments to cmake.

Then I believe CMAKE_PROJECT_INCLUDE or any of the other script injection variables could work.

IE create a CMake file proxy.cmake:

set(ENV{HTTP_PROXY} "...")

Then pass this to the configure step:

cmake -DCMAKE_PROJECT_INCLUDE=proxy.cmake

Now that CMake script will run during the configuration step setting up your desired environment.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.