Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c

cmake

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()
like image 704
ZhangChn Avatar asked Feb 03 '13 16:02

ZhangChn


People also ask

Where does CMake look for include files?

cmake is searched first in CMAKE_MODULE_PATH , then in the CMake module directory. There is one exception to this: if the file which calls include() is located itself in the CMake builtin module directory, then first the CMake builtin module directory is searched and CMAKE_MODULE_PATH afterwards.

What is CMakeLists txt?

CMakeLists. txt file contains a set of directives and instructions describing the project's source files and targets (executable, library, or both). When you create a new project, CLion generates CMakeLists. txt file automatically and places it in the project root directory.

What files does CMake generate?

CMake is a meta build system that uses scripts called CMakeLists to generate build files for a specific environment (for example, makefiles on Unix machines). When you create a new CMake project in CLion, a CMakeLists. txt file is automatically generated under the project root.

How does CMake command work?

Cmake allows to provide cross platform build files that would generate platform specific project/make files for particular compilation/platform. cmake . inside your project's directory on Windows platform,Cmake will generate all the necessary project/solution files ( . sln etc.).


1 Answers

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

like image 121
bash0r Avatar answered Sep 16 '22 20:09

bash0r