导致CMAKE产生错误

导致CMAKE产生错误

本文介绍了导致CMAKE产生错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何让CMAKE在特定条件下产生错误。也就是说,我想要这样的东西:

How can I get CMAKE to generate an error on a particular condition. That is, I want something like this:

if( SOME_COND )
  error( "You can't do that" )
endif()


推荐答案

a href =https://cmake.org/cmake/help/v2.8.8/cmake.html#command%3amessage> message()方法具有该类型的可选参数,允许STATUS,WARNING, AUTHOR_WARNING,SEND_ERROR和FATAL_ERROR。

The message() method has an optional argument for the type, allowing STATUS, WARNING, AUTHOR_WARNING, SEND_ERROR and FATAL_ERROR.

如果您想要输出错误,则需要SEND_ERROR,但继续处理。
如果你想退出CMake处理,你想要FATAL_ERROR。

You want SEND_ERROR if you want to output an error, but continue processing.You want FATAL_ERROR if you want to exit CMake processing.

像:

if( SOME_COND )
  message( SEND_ERROR "You can't do that" )
elsif( SOME_CRITICAL_COND )
  message( FATAL_ERROR "You can not do this at all, CMake will exit." )
endif()

这篇关于导致CMAKE产生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 12:15