CMake宏从流的中间返回吗? [英] CMake macro return from middle of the flow?
本文介绍了CMake宏从流的中间返回吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以从CMake 宏
的中间返回吗?我想到的一个用例如下。
Can I return from the middle of a CMake macro
? A use case I have in mind is below.
macro (my_macro a b c)
if (NOT USE_${a})
# I WANT TO RETURN FROM HERE.
endif ()
if (NOT USE_${b})
# I WANT TO RETURN FROM HERE.
endif ()
# Do something to c...
endmacro()
推荐答案
CMake中的宏基本上是替代品,因此您实际上并没有从中返回。我建议您将 b和 c代码包装到 else()
中:
Macros in CMake are basically substitutions, so you don't actually return from it. I'd suggest you wrapping "b" and "c" code into else()
:
macro (my_macro a b c)
if (NOT USE_${a})
# I WANT TO RETURN FROM HERE.
else ()
if (NOT USE_${b})
# I WANT TO RETURN FROM HERE.
endif ()
# Do something to c...
endif(NOT USE_${a})
endmacro()
这篇关于CMake宏从流的中间返回吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文