If I want to check currently exported environment variables, I do this in shell.
export
In CMake, I do this to print something.
MESSAGE ("This is message.")
How can I print former one with CMake?
I know that CMake is stand for cross-platform building, anyway when debugging something I need to check raw values. So I need this.
If you want to know the value of a specific variable, you can use $ENV{varname}
:
message(STATUS $ENV{PATH})
If you want to see all variables, you probably need to resort to invoking an external command such as env
(on Unix) or set
(on Windows):
# Windows
execute_process(COMMAND cmd /c set OUTPUT_VARIABLE output)
message(${output})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With