How to retrieve a user environment variable in CMake (Windows)

后端 未结 4 437
长情又很酷
长情又很酷 2020-12-07 13:46

I know how to retrieve a normal machine wide environment variable in CMAKE using

$ENV{EnvironmentVariableName}

but I can not retrieve a use

4条回答
  •  被撕碎了的回忆
    2020-12-07 14:26

    Getting variables into your CMake script

    You can pass a variable on the line with the cmake invocation:

    FOO=1 cmake
    

    or by exporting a variable in BASH:

    export FOO=1
    

    Then you can pick it up in a cmake script using:

    $ENV{FOO}
    

提交回复
热议问题