Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cause CMAKE to generate an error

Tags:

cmake

People also ask

What does CMake generate do?

CMake can generate a native build environment that will compile source code, create libraries, generate wrappers and build executables in arbitrary combinations. CMake supports in-place and out-of-place builds, and can therefore support multiple builds from a single source tree.

What files does CMake generate?

When you create a new CMake project in CLion, a CMakeLists. txt file is automatically generated under the project root.

How do I exit CMake script?

[CMake] EXIT() or RETURN() commands.


The message() method has an optional argument for the mode, allowing STATUS, WARNING, AUTHOR_WARNING, SEND_ERROR, and FATAL_ERROR. STATUS messages go to stdout. Every other mode of message, including none, goes to stderr.

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.

Something like:

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