6

I'm trying to build the library which included 'gflags/gflags.h' and am having trouble getting it to find.

I installed gflags and glog with homebrew.

CMake output says:

-- Found installed version of gflags: /usr/local/lib/cmake/gflags
-- Detected gflags version: 2.2.2
-- Found Gflags: /usr/local/include
-- Found Glog: /usr/local/include

While running "cmake" everything is okay there is no error. But when I run "make install" it cannot build and it says "fatal error: 'gflags/gflags.h' file not found"

How can I build the library which requires gflags in OsX?

xfarxod
  • 123
  • 2
  • 6
  • 1
    try to see inside of Cmake file if Gflags path is set manually? – mudin Apr 23 '20 at 00:17
  • In Cmake file there is only `find_package(Gflags REQUIRED)` `find_package(Glog REQUIRED)` – xfarxod Apr 23 '20 at 00:19
  • 2
    Could you provide the CmakeList somehow? My guess is that you are not linking the gflags directory for your executable. – Thomas Caissard Apr 23 '20 at 00:48
  • 2
    Please provide your CMake code, including the code showing how you use the Gflags variables after the calls to `find_package()`. Without seeing the code you are using, we can only **guess** what the problem might be... – Kevin Apr 23 '20 at 01:15
  • @ThomasCaissard @squareskittles Thank you guys It was problem in `include_directories` – xfarxod Apr 23 '20 at 04:04

1 Answers1

4

First, find your package

find_package(Gflags REQUIRED)
find_package(Glog REQUIRED)

And then assign these library's header files to your executable include path

include_directories(${GLOG_INCLUDE_DIRS} ${GFLAGS_INCLUDE_DIRS})

Make sure that these variables are set properly

message(STATUS "GFLAGS include path: ${GFLAGS_INCLUDE_DIRS}")
Kevin
  • 321
  • 1
  • 8
  • 1
    gflag and glog provide Modern CMake Targets `gflags::gflags` et `glog::glog` -> stop using deprecated *_INCLUDE_DIRS. Thx – Mizux Apr 23 '20 at 10:02