glog integration with cmake

2,125 views
Skip to first unread message

Lekha Agrawal

unread,
Jun 22, 2015, 5:12:47 AM6/22/15
to googl...@googlegroups.com
Hello,

I am trying to learn glog. I want to integrate glog with my small cmake project. I'm not able to find a guide for this. Could I get help?

Michael Ellery

unread,
Sep 23, 2015, 11:09:28 AM9/23/15
to google-glog


On Monday, June 22, 2015 at 2:12:47 AM UTC-7, Lekha Agrawal wrote:
Hello,

I am trying to learn glog. I want to integrate glog with my small cmake project. I'm not able to find a guide for this. Could I get help?

it's been a while since your post, but I'll take a crack at this.

I'd say integration with a CMAKE project mostly requires CMAKE work. Standard CMAKE ships with a bunch of "finder" modules for common libraries. Alas, there does not appear to be one for GLOG.  So, that means you need to write a finder module -- OR, simpler, just use a combination of find_library and find_file to locate the artifacts from GLOG that you need.  Usually this just means finding the .so or .a file and one of the associated headers (you only need to find one...and then use the path to that in your include_directories() list.  Those find_* commands in CMAKE are pretty smart and will search in standard system paths for the named things, and you can also pass additional hints/paths if you happen to be using a local source build or a strange install location.

Here's the finder module for GTEST (another google library):

https://github.com/Kitware/CMake/blob/master/Modules/FindGTest.cmake

You can use that for inspiration and just take statements from it for use in your own CMAKE files.  If you do decide to actually write a finder module for GLOG, you can then contribute it back to CMAKE and it will be included in future releases.

-Mike

Carles Fernandez

unread,
Sep 23, 2015, 1:14:19 PM9/23/15
to googl...@googlegroups.com
Here you have an example: https://github.com/gnss-sdr/gnss-sdr/blob/master/cmake/Modules/FindGLOG.cmake 

The root CMakeLists.txt script of that project searches for google-glog and gflags, downloading and building them at compile time in case they are not found. See the code starting at https://github.com/gnss-sdr/gnss-sdr/blob/master/CMakeLists.txt#L467

Hope this helps,
Carles



--
You received this message because you are subscribed to the Google Groups "google-glog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-glog...@googlegroups.com.
To post to this group, send email to googl...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-glog.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages