ZhangChn
ZhangChn

Reputation: 3184

How to fail CMake gracefully when an include file does not exist?

In CMakeLists.txt, I would like to check that bzlib.h exists:

include(CheckIncludeFiles)
check_include_file(bzlib.h HAVE_BZLIB_H)
if(NOT HAVE_BZLIB_H)
    # How can I exit cmake with an error message if bzlib.h does not exists?
endif()

Upvotes: 9

Views: 4386

Answers (1)

bash0r
bash0r

Reputation: 635

It's quite easy: message( FATAL_ERROR "Your message" )

Upvotes: 14

Related Questions