1

I'm trying to pass an environment variable to an external project in my CMakeLists.txt without any success.

In this case, I have a dependency to mbedtls library which is downloaded and built in my cmake. In Linux this works as intended, however in a Windows environment, I need to pass a variable WINDOWS_BUILD=1 to the make environment.

I have tried to add a CONFIGURE_COMMAND to a batch file which sets this environment variable in the ExternalProject_Add(), however this does not work. If I manually go into the automatically downloaded mbedtls folder and write

$ make WINDOWS_BUILD=1

it works as intended, however I want to build everything from CMake environment. Any takes?

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
MrGigu
  • 1,729
  • 3
  • 23
  • 37
  • Just write `make WINDOWS_BUILD=1` as a `BUILD_COMMAND`. Note, that the variable here is not an environment, but a `make` one. (Command for passing environment variable would be `WINDOWS_BUILD=1 make`.) – Tsyvarev Nov 06 '18 at 12:46
  • How are you calling the external project? If you use the `execute_process` [command](https://cmake.org/cmake/help/latest/command/execute_process.html), it lets you pass arguments right in the call – Jose Fernando Lopez Fernandez Nov 09 '18 at 05:35

0 Answers0