如何在CMake(Windows)中检索用户环境变量 [英] How to retrieve a user environment variable in CMake (Windows)
本文介绍了如何在CMake(Windows)中检索用户环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道如何使用
$ENV{EnvironmentVariableName}
但我无法检索用户特定的环境变量。
but I can not retrieve a user specific environment variable. Is it possible and how?
推荐答案
获取变量到你的CMake脚本
您可以使用cmake调用在该行上传递一个变量:
Getting variables into your CMake script
You can pass a variable on the line with the cmake invocation:
FOO=1 cmake
或通过在BASH中导出变量:
or by exporting a variable in BASH:
export FOO=1
然后你可以在cmake脚本中使用: / p>
Then you can pick it up in a cmake script using:
$ENV{FOO}
这篇关于如何在CMake(Windows)中检索用户环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文