Add glog target cmake configure file (#216)
author박세희/동작제어Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Thu, 10 May 2018 23:57:28 +0000 (08:57 +0900)
committer박종현/동작제어Lab(SR)/Senior Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 10 May 2018 23:57:28 +0000 (08:57 +0900)
* Add glog target cmake configure file

This will add glog configure file that adds glog target.
Unlike gflags, latest glog source archieve has issue(namespace difference) with latest gflags so cannot use built from source glog at the moment.
So this commit only includes adding target interface with system installed version.
Download and build from source may be added later when isses are fixed somehow.

Signed-off-by: SaeHie Park <saehie.park@samsung.com>
* move status message

* remove empty line

cmake/packages/GLogConfig.cmake [new file with mode: 0644]

diff --git a/cmake/packages/GLogConfig.cmake b/cmake/packages/GLogConfig.cmake
new file mode 100644 (file)
index 0000000..61253a0
--- /dev/null
@@ -0,0 +1,30 @@
+function(_GLog_import)
+  if(TARGET glog)
+    set(GLog_FOUND True PARENT_SCOPE)
+    return()
+  endif()
+
+  nncc_find_package(GFlags REQUIRED)
+  if(NOT GFlags_FOUND)
+    set(GLog_FOUND False PARENT_SCOPE)
+    return()
+  endif(NOT GFlags_FOUND)
+
+  set(GLOG_ROOT_DIR "" CACHE PATH "Folder contains Google Log")
+  find_path(GLOG_INCLUDE_DIR glog/logging.h PATHS ${GLOG_ROOT_DIR})
+  find_library(GLOG_LIBRARY glog)
+
+  if(NOT GLOG_INCLUDE_DIR)
+    set(GLog_FOUND False PARENT_SCOPE)
+    return()
+  endif(NOT GLOG_INCLUDE_DIR)
+
+  add_library(glog INTERFACE)
+  target_include_directories(glog INTERFACE ${GLOG_INCLUDE_DIR} ${GFLAGS_INCLUDE_DIR})
+  target_link_libraries(glog INTERFACE ${GLOG_LIBRARY} gflags)
+
+  message(STATUS "Found GLog: TRUE")
+  set(GLog_FOUND True PARENT_SCOPE)
+endfunction(_GLog_import)
+
+_GLog_import()