cmake - CMake 生成器表达式和 CONFIG 变量查询
问题描述
这个 CMake 文档:https ://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html告诉我们:
$<CONFIG> Configuration name.
然后 :
Conditional generator expressions depend on a boolean condition that must be 0 or 1.
$<condition:true_string> Evaluates to true_string if condition is 1. Otherwise evaluates to the empty string.
$<IF:condition,true_string,false_string> New in version 3.8.
Evaluates to true_string if condition is 1. Otherwise evaluates to false_string.
Typically, the condition is a boolean generator expression. For instance,
$<$<CONFIG:Debug>:DEBUG_MODE> expands to DEBUG_MODE when the Debug configuration is used, and otherwise expands to the empty string.
如果我理解正确,在 Visual Studio 中,如果我从 Debug 切换到 Release 这一行:
$<$<CONFIG:Debug>:DEBUG_MODE>
也应该扩展到 DEBUG_MODE,不是吗?因为根据我的理解,CONFIG 将包含“Release”并且它是一个非空字符串,因此它将扩展为 Debug,而不是由于文档中的以下语句,最后一个生成器表达式将扩展为 DEBUG_MODE:
$condition:true_string 如果条件为 1,则计算为 true_string。否则计算为空字符串。
我知道我错了,请帮助我理解它是如何工作的。
解决方案
因为 CONFIG 将包含
CONFIG
不包含,它不是条件,它是具有特殊规则的特定变量查询。
$<CONFIG:cfgs> 1 if config is any one of the entries in cfgs, else 0. [...]
假设它是这样工作的:
- 提取零件
A
等B
$<A:B>
- 如果部分
A
是CONFIG
- 然后做与CONFIG
A
例如,如果 part是 - 然后做与 .相关的STREQUAL
事情。B
STREQUAL
- 对于每种情况...
- 否则是 a
condition
,如果是1
,则返回B
,否则为空字符串。
推荐阅读
- apache-kafka - debezium kafka 连接问题
- powershell - 通过 PowerShell 自动将主机名移动到 OU
- c - 为什么调试语句Serial.println(i)时for循环行为会发生变化;存在与注释掉
- c# - 使用 DontDestroyOnLoad 调用场景加载方法
- laravel-8 - Laravel 惯性链接与 id
- firebase - 为什么我在 QuerySnapShot firestore 颤动时遇到错误?
- excel - 在 2 列中查找最接近的匹配 x、y、z 点,然后计算距离 [Excel VBA 或公式]
- python - 如果 else 语句在自定义 python 函数中不起作用
- php - php解析错误的问题:无效的数字文字
- testcafe - 在 Testcafe 中调用 .getVue() 时出现错误“_keys2 未定义”