Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cmake CHECK_INCLUDE_FILES not finding header file

Tags:

c++

header

cmake

I'm trying to have Cmake check if the file cxxabi.h is available. This file is from the c++ standard library, at least with g++. My current cmake commands look like this:

include(CheckIncludeFiles)
...
check_include_files(cxxabi.h HAVE_CXXABI)
if(HAVE_CXXABI)
   ...
else(HAVE_CXXABI)
   ...
endif(HAVE_CXXABI)

When this is executed, I get:

 -- Looking for include files HAVE_CXXABI
 -- Looking for include files HAVE_CXXABI - not found.

Although the file is available in /usr/include/c++/4.6.4/ and can properly be found by g++ when I compile a c++ code.

I suspect the macro check_include_files uses the C compiler instead of the C++ one to compile a small program that includes the required file, which of course fails since cxxabi.h is a C++ file.

Any idea how to solve that? (i.e. making the macro use the C++ compiler instead of the C one)

like image 433
sunmat Avatar asked Jan 11 '23 10:01

sunmat


1 Answers

As edited in my original question:

Problem solved. There is a different macro for C++ headers, check_include_file_cxx, located in CheckIncludeFileCXX.

like image 92
sunmat Avatar answered Jan 18 '23 01:01

sunmat