"$< $< CONFIG:Debug>:Release>"是什么意思?在cmake中是什么意思? [英] What does "$<$<CONFIG:Debug>:Release>" mean in cmake?
问题描述
在 buildem_cmake_recipe.cmake 中,我看到了一个表达式:
In buildem_cmake_recipe.cmake, I saw an expression:
externalproject_add_step(${_name} BuildOtherConfig
COMMAND ${CMAKE_COMMAND} --build ${BINARY_DIR} --config "$<$<CONFIG:Debug>:Release>$<$<CONFIG:Release>:Debug>" --target INSTALL
DEPENDEES install
)
$< $< CONFIG:Debug>:Release> $< $< CONFIG:Release>:Debug>
是什么意思?
推荐答案
That's a CMake generator expression. You can follow the link for a full discussion of what these are and what they can do. In short, it's a piece of text which CMake will evaluate at generate time (when it's done parsing all CMakeLists and is generating the buildsystem); it can evaluate to a different value for each configuration.
您那里的那个大概就是这个(伪代码):
The one you have there means roughly this (pseudo-code):
if current_configuration == "Debug"
output "Release"
if current_configuration == "Release"
output "Debug"
因此,如果当前配置为Debug,则整个表达式的计算结果将为 Release
.如果当前配置为Release,它将评估为 Debug
.注意,被添加的步骤被称为"BuildOtherConfig".因此,这种反向逻辑是有道理的.
So, if the current configuration is Debug, the whole expression will evaluate to Release
. If the current configuration's Release, it will evaluate to Debug
. Notice that the step being added is called "BuildOtherConfig," so this inverted logic makes sense.
其工作原理,再详细一点:
How it works, in a little more detail:
$<CONFIG:Debug>
如果当前配置为 Debug
,这将评估为 1
,否则为 0
.
This will evaluate to a 1
if the current config is Debug
, and to a 0
otherwise.
$<1:X>
计算为 X
.
$<0:X>
计算为空字符串(无值).
Evaluates to an empty string (no value).
放在一起,我们有 $< $< CONFIG:Debug>:Release>
.当前配置为 Debug
时,其评估结果如下:
Putting it together, we have $<$<CONFIG:Debug>:Release>
. When the current config is Debug
, it evaluates like this:
$<$<CONFIG:Debug>:Release>
$<1:Release>
Release
当当前配置不是 Debug
时,其评估结果如下:
When the current config is not Debug
, it evaluates like this:
$<$<CONFIG:Debug>:Release>
$<0:Release>
这篇关于"$< $< CONFIG:Debug>:Release>"是什么意思?在cmake中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!