Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake can't find glog

Tags:

cmake

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)
like image 566
hidemyname Avatar asked Oct 26 '25 07:10

hidemyname


2 Answers

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!

like image 192
Alex Reinking Avatar answered Oct 29 '25 07:10

Alex Reinking


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.

like image 20
fukatani Avatar answered Oct 29 '25 09:10

fukatani



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!