Glog: How to use Glog in Cmake project ?
# Documents
- [How To Use Google Logging Library (glog)](http://rpg.ifi.uzh.ch/docs/glog.html)
- [FindGlog.cmake Version 1](https://github.com/BVLC/caffe/blob/master/cmake/Modules/FindGlog.cmake)
- [FindGlog.cmake Version 2](https://ceres-solver.googlesource.com/ceres-solver/+/78cc2c4719a68fea2597fce6346cb79443536367/cmake/FindGlog.cmake)
# Install Glog
```sh
sudo apt install libgoogle-glog-dev
```
# Cmake
```cmake
cmake_minimum_required(VERSION 3.10)
# set the project name
project(useGlog)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules)
find_package(Glog REQUIRED)
INCLUDE_DIRECTORIES(${GLOG_INCLUDE_DIR})
# add the executable
add_executable(example example.cpp)
target_link_libraries(example ${GLOG_LIBRARY})
```
# Example
Use "glog/logging.h"
```cpp
#include
int main(int argc, char* argv[]) {
// Initialize Google's logging library.
google::InitGoogleLogging(argv[0]);
// ...
LOG(INFO) << "Found " << num_cookies << " cookies";
}
```
No comments