In CMake, how does CHECK_INCLUDE_FILE_CXX work?

The following code does not print anything

CHECK_INCLUDE_FILE_CXX(glog/logging.h GLOG_INCLUDE) IF(GLOG_INCLUDE) MESSAGE("YY") ENDIF(GLOG_INCLUDE) 

But I have the following set of environment variables:

 export CPLUS_INCLUDE_PATH=/usr/local/include 

And, "ls / usr / local / include / glog / logging.h" returns the file.

I tried to use

 include_directories( "/usr/local/include" ) 

but GLOG_INCLUDE remains undefined after (logging.h not found.)

+7
cmake
source share
1 answer

Take a look at CheckIncludeFileCXX.cmake. It should be in the directory in your cmake installation (I have it in / usr / share / cmake -2.8 / Modules).

This file indicates:

 # The following variables may be set before calling this macro to # modify the way the check is run: # # CMAKE_REQUIRED_FLAGS = string of compile command line flags # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories # 

So, you can try to set this variable before sending the command, for example:

 set (CMAKE_REQUIRED_INCLUDES "/usr/local/include") CHECK_INCLUDE_FILE_CXX(glog/logging.h GLOG_INCLUDE) IF(GLOG_INCLUDE) MESSAGE("YY") ENDIF(GLOG_INCLUDE) 
+7
source share

All Articles