CMake ENDIF和ELSE参数的目的 [英] Purpose of CMake ENDIF and ELSE arguments
问题描述
在CMake中, ELSE
和 ENDIF
控制流函数将表达式作为参数。根据文档,这些是可选。那么这些目的是什么?仅仅是为了维护目的而使原始 IF
表达式更清晰,还是提供某些功能?
In CMake the ELSE
and ENDIF
control flow functions take expressions as arguments. These are optional according to the documentation. What is the purpose of these then? Is it just to make the original IF
expression clearer for maintenance purposes, or does it provide some functionality?
推荐答案
这些表达式如您所说是可选的,当您嵌套 if()
语句时它们很有用-当<$ c时,cmake会警告您 endif()
中的$ c> expr 与最近的<$中的 expr
不匹配c $ c> if()。
These expressions are optional as you said and they are useful when you have nested if()
statements - cmake will warn you when expr
in endif()
doesn't match expr
in nearest if()
.
else()
同样
简单-这可以保护您免受 if()
else()
endif()
嵌套链。
Simply - this protects you from mistakes in if()
else()
endif()
nested chains.
这篇关于CMake ENDIF和ELSE参数的目的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!