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)
This is the cmake file. I installed the google glog 0.3.4 in the /apps/glog. Why when compiling this file, there is still the following error? I checked, glog/logging.h is under 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 now (at most four years after this question was asked) has CMake support! They have very good documentation here: https://github.com/google/glog#cmake
But this is the gist of what you should do:
cmake_minimum_required (VERSION 3.0.2)
project(myproj VERSION 1.0)
find_package(glog 0.6.0 REQUIRED)
add_executable(myapp main.cpp)
target_link_libraries(myapp PRIVATE glog::glog)
Just like any other well-behaved, CMake-aware library!
As of November 18, 2017, official glog does not support CMake.
GitHub user sergiud added CMake support in a fork.
Please see the discussion in
https://github.com/google/glog/issues/4.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With