0

I wanted to use logging in my app. In the CMake file I made (the relevant part see below) for a while everything runs smoothly, gflags seems to be installed OK. However, when compiling glog, I receive the error message: fatal error: 'gflags/gflags.h' file not found

The missing file is found in the generated code, so I guess that some switches/options are set in some incorrect way. Or, the other thing that I download the files from a wrong site. (I found and downloaded several pathched glog files, they all present me error messages, with different ones.) How can I fix it? (I would prefer a non-manual patch)

# Download and install GoogleFlags
ExternalProject_Add(
gflags
URL https://github.com/gflags/gflags/archive/master.zip
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gflags
INSTALL_COMMAND ""
)

# Create a libgflags target to be used as a dependency by test programs
add_library(libgflags IMPORTED STATIC GLOBAL)
add_dependencies(libgflags gflags)

# Set gflag properties
ExternalProject_Get_Property(gflags source_dir binary_dir)
set_target_properties(libgflags PROPERTIES
"IMPORTED_LOCATION" "${binary_dir}/libgflags.a"
"IMPORTED_LINK_INTERFACE_LIBRARIES" "${CMAKE_THREAD_LIBS_INIT}"
)
include_directories("${source_dir}/include")

# Download and install GoogleLog
ExternalProject_Add(
glog
URL https://github.com/emzeat/google-glog/archive/master.zip
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/glog
INSTALL_COMMAND ""
)

# Create a libglog target to be used as a dependency by test programs
add_library(libglog IMPORTED STATIC GLOBAL)
add_dependencies(libglog glog)

# Set glog properties
ExternalProject_Get_Property(glog source_dir binary_dir)
set_target_properties(libglog PROPERTIES
"IMPORTED_LOCATION" "${binary_dir}/libglog.a"
"IMPORTED_LINK_INTERFACE_LIBRARIES" "${CMAKE_THREAD_LIBS_INIT}"
#    "INTERFACE_INCLUDE_DIRECTORIES" "${source_dir}/include"
)
# I couldn't make it work with INTERFACE_INCLUDE_DIRECTORIES
include_directories("${source_dir}/include")
katang
  • 2,474
  • 5
  • 24
  • 48
  • With `make VERBOSE=1` you can see how CMake invokes the compiler. – usr1234567 Nov 13 '15 at 19:59
  • Variables, targets, etc. which is set in the main project doesn't affect on External project at all. External project can only be adjusted using options passed to the `ExternalProject_Add` macro. `glog` project *requires* `gflags` to be **installed**, but you only build it (INSTALL_COMMAND is empty). Note also, that `gflags` should be installed to the *default system-wide directory*, but by default `ExternalProject_Add` installs into local directory. – Tsyvarev Nov 13 '15 at 21:46
  • @ Tsyvarev On OSX, do you mean something like /Applications, or /usr/local/bin ? – katang Nov 14 '15 at 17:59

0 Answers0