2010-06-15 7 views
7

Il codice seguente stampa nullaIn CMake, come funziona CHECK_INCLUDE_FILE_CXX?

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

Ma ho il seguente set variabile di ambiente:

export CPLUS_INCLUDE_PATH=/usr/local/include 

E, "ls /usr/local/include/glog/logging.h" restituisce il file .

Ho provato ad utilizzare

include_directories("/usr/local/include") 

ma GLOG_INCLUDE rimane indefinito dopo (logging.h non resti trovati.)

risposta

7

Date un'occhiata al CheckIncludeFileCXX.cmake. Dovrebbe essere in una directory nella tua installazione cmake (ce l'ho in /usr/share/cmake-2.8/Modules).

Questo file afferma:

# 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 
# 

modo da poter provare l'impostazione di questa variabile prima caling il comando, in questo modo:

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

Suppongo che è strano che questo modulo non è possibile utilizzare il sistema comprende percorsi ... – avtomaton