I am trying to move from an own written tool to cmake for Windows to simplify our build environment.
We have a tool in the build process that requires to have set environment variables. I would like to set them with cmake but don't know how. What I have tried:
set(ENV{MYENVVAR} "My-Content")
I would expect that I can read this environment variable again with
message($ENV{MYENVVAR})
But this does not work. Even setting a variable before invoking cmake (instead of setting it in cmake) does not help, I cant read the variable in cmake.
What do I do wrong?
Edit:
- I do invoke cmake again after changing CMakeLists.exe.
- I do set environment variables with
set MYENVVAR=My-Content
in Windows cmd.exe and then invoke cmake from exactly this console. - cmake is version 3.20.0 for Windows.