CMake set 语法

参考CMake官方文档:https://cmake.org/cmake/help/v3.14/command/set.html

1. 普通变量

set(<variable> <value>... [PARENT_SCOPE])

设置变量<variable> 的值为 <value>

如果后面增加了 PARENT_SCOPE 选项的话, 表示 在上层作用域/目录 设置<variable> 的值为 <value>, 但是当前作用域/目录 该<variable> 的值不变

2. 设置缓存条目

set(<variable> <value>... CACHE <type> <docstring> [FORCE])

 设置给定的缓存变量<variable> 的值为 <value>.

由于缓存项旨在提供用户可设置的值,因此默认情况下不会覆盖现有缓存项。使用FORCE选项覆盖现有条目。

<type> 必须是下列类型之一:

BOOL
Boolean ON/OFF value. 
FILEPATH
文件路径. 
PATH
目录路径. 
STRING
一行文本. cmake-gui(1) offers a text field or a drop-down selection if the STRINGS cache entry property is set.
INTERNAL
一行文本. cmake-gui(1) does not show internal entries. They may be used to store variables persistently across runs. Use of this type implies FORCE.

The <docstring> must be specified as a line of text providing a quick summary of the option for presentation to cmake-gui(1) users.

3. 设置环境变量

set(ENV{<variable>} [<value>])

设置环境变量<variable>的值为<value>. 后面使用 $ENV{<variable>} 可以获取该值.

This command affects only the current CMake process, not the process from which CMake was called, nor the system environment at large, nor the environment of subsequent build or test processes.

If no argument is given after ENV{<variable>} or if <value> is an empty string, then this command will clear any existing value of the environment variable.

Arguments after <value> are ignored. If extra arguments are found, then an author warning is issued.

转载于:https://www.cnblogs.com/lvchaoshun/p/10431380.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值