Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print result of shell script in CMake?

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.

like image 727
eonil Avatar asked Dec 25 '11 01:12

eonil


1 Answers

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})
like image 64
JesperE Avatar answered Oct 07 '22 18:10

JesperE