CMAKE_MINIMUM_REQUIRED(VERSION 2.8.7 FATAL_ERROR)
INCLUDE(FindPackageHandleStandardArgs)
FIND_LIBRARY(GLOG_LIBRARY glog)
FIND_PATH(GLOG_INCLUDE_DIR "glog/logging.h")
SET(GLOG_LIBRARIES ${GLOG_LIBRARY})
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
Glog
REQUIRED_ARGS GLOG_INCLUDE_DIR GLOG_LIBRARY)
这是cmake文件。我已经在/apps/glog中安装了google glog 0.3.4。但是,编译该文件时为什么还会出现以下错误?我检查了,glog/logging.h位于0.3.4/include/glog/目录下。
CMake Error at cmake/FindGlog.cmake:77 (MESSAGE):
Failed to find glog - Could not find glog include directory, set
GLOG_INCLUDE_DIR to directory containing glog/logging.h
Call Stack (most recent call first):
cmake/FindGlog.cmake:103 (GLOG_REPORT_NOT_FOUND)
CMakeLists.txt:27 (FIND_PACKAGE)
glog/logging.h
)。我猜测,目录/apps/glog/0.3.4/
不是系统目录之一,因此默认情况下不会搜索该目录。当调用cmake
时,您可以通过设置CMAKE_PREFIX_PATH
变量来提示CMake关于此目录的信息:cmake -DCMAKE_PREFIX_PATH=/apps/glog/0.3.4 ...
。 - Tsyvarev