在CMake中,CHECK_INCLUDE_FILE_CXX如何工作? [英] In CMake, how does CHECK_INCLUDE_FILE_CXX work?

查看:100
本文介绍了在CMake中,CHECK_INCLUDE_FILE_CXX如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码不打印任何内容

The following code prints nothing

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

但是我设置了以下环境变量:

But I have the following environment variable set:

export CPLUS_INCLUDE_PATH=/usr/local/include

然后,"ls/usr/local/include/glog/logging.h"返回文件.

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

我尝试使用

include_directories( "/usr/local/include" )

但是GLOG_INCLUDE之后仍然未定义(未找到logging.h.)

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

推荐答案

看看CheckIncludeFileCXX.cmake.它应该在您的cmake安装目录中(我在/usr/share/cmake-2.8/Modules中).

Take a look at the CheckIncludeFileCXX.cmake. It should be in a directory in your cmake installation (I have it in /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
#  

因此,您可以在校准命令之前尝试设置此变量,如下所示:

So you can try setting this variable before caling the command, like this:

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

这篇关于在CMake中,CHECK_INCLUDE_FILE_CXX如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆