以下代码不打印任何内容
CHECK_INCLUDE_FILE_CXX(glog/logging.h GLOG_INCLUDE)
IF(GLOG_INCLUDE)
MESSAGE("YY")
ENDIF(GLOG_INCLUDE)
Run Code Online (Sandbox Code Playgroud)
但我有以下环境变量集:
export CPLUS_INCLUDE_PATH=/usr/local/include
Run Code Online (Sandbox Code Playgroud)
并且,"ls /usr/local/include/glog/logging.h"返回文件.
我试过用
include_directories( "/usr/local/include" )
Run Code Online (Sandbox Code Playgroud)
但GLOG_INCLUDE仍然未定义(找不到logging.h.)
看看CheckIncludeFileCXX.cmake.它应该在你的cmake安装目录中(我在/usr/share/cmake-2.8/Modules中有它).
该文件说明:
# 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
#
Run Code Online (Sandbox Code Playgroud)
因此,您可以在调用命令之前尝试设置此变量,如下所示:
set (CMAKE_REQUIRED_INCLUDES "/usr/local/include")
CHECK_INCLUDE_FILE_CXX(glog/logging.h GLOG_INCLUDE)
IF(GLOG_INCLUDE)
MESSAGE("YY")
ENDIF(GLOG_INCLUDE)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3806 次 |
| 最近记录: |