我可以从CMake macro
的中间返回吗?我想到的一个用例如下。
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()
答案 0 :(得分:3)
CMake中的宏基本上是替换,所以你实际上并没有从中返回。我建议你包装" b"和" c"代码到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()