From bed62c4f8b772ccd182f074574692cd739ae8d09 Mon Sep 17 00:00:00 2001 From: Teon Banek Date: Fri, 16 Jun 2017 12:04:26 +0200 Subject: [PATCH] Setup building with glog library Summary: To use the library in code, do the following. * Include glog, `include "glog/logging.h"` * Initialize logging from a main entry point, `google::InitGoogleLogging(argv[0]);` * Log anywhere from your code, `LOG(INFO) << "Hello world from glog";` For advanced use, refer to glog's documentation. Reviewers: mislav.bradac, florijan, dgleich, buda Reviewed By: mislav.bradac, buda Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D492 --- CMakeLists.txt | 7 +++++-- libs/CMakeLists.txt | 11 +++++++++++ libs/setup.sh | 7 +++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cd05be54f..caad58c8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -284,6 +284,7 @@ include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/libs) # needed to include configured files (plan_compiler_flags.hpp) set(generated_headers_dir ${CMAKE_BINARY_DIR}/generated_headers) include_directories(${generated_headers_dir}) +include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/libs/glog/include) # ----------------------------------------------------------------------------- # openCypher parser ----------------------------------------------------------- @@ -373,7 +374,8 @@ set(memgraph_src_files # ----------------------------------------------------------------------------- # memgraph_lib and memgraph_pic depend on these libraries -set(MEMGRAPH_ALL_LIBS gflags stdc++fs Threads::Threads fmt antlr_opencypher_parser_lib dl) +set(MEMGRAPH_ALL_LIBS gflags stdc++fs Threads::Threads fmt + antlr_opencypher_parser_lib dl ${CMAKE_SOURCE_DIR}/libs/glog/lib/libglog.a) if (READLINE_FOUND) list(APPEND MEMGRAPH_ALL_LIBS ${READLINE_LIBRARY}) endif() @@ -381,7 +383,8 @@ endif() # STATIC library used by memgraph executables add_library(memgraph_lib STATIC ${memgraph_src_files}) target_link_libraries(memgraph_lib ${MEMGRAPH_ALL_LIBS}) -add_dependencies(memgraph_lib generate_opencypher_parser) +add_dependencies(memgraph_lib generate_opencypher_parser + glog) # STATIC PIC library used by query engine add_library(memgraph_pic STATIC ${memgraph_src_files}) diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index 704b6a8ee..ac6e829a7 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -21,6 +21,17 @@ set(GFLAGS_BUILD_gflags_nothreads_LIB OFF) set(GFLAGS_BUILD_gflags_LIB ON) add_subdirectory(gflags) +# Setup google logging after gflags (so that glog can use it). +# We need to use `ExternalProject`, because currently glog's CMakeLists.txt +# doesn't detect gflags if we do `add_subdirectory`. +include(ExternalProject) +ExternalProject_Add(glog DEPENDS gflags + PREFIX ${CMAKE_SOURCE_DIR}/libs/glog + SOURCE_DIR ${CMAKE_SOURCE_DIR}/libs/glog + CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release + -DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}/libs/glog + -Dgflags_DIR=${CMAKE_CURRENT_BINARY_DIR}/gflags) + # setup cppitertools # CLion compatiblity; the target won't be built file(GLOB __CPPITERTOOLS_SOURCES __main.cpp diff --git a/libs/setup.sh b/libs/setup.sh index 663bab77c..0bc29c8c4 100755 --- a/libs/setup.sh +++ b/libs/setup.sh @@ -47,6 +47,13 @@ cd googletest git checkout ${googletest_tag} cd .. +# google logging +git clone https://github.com/google/glog.git +glog_tag="a6a166db069520dbbd653c97c2e5b12e08a8bb26" # v0.3.5 +cd glog +git checkout ${glog_tag} +cd .. + # lcov-to-coberatura-xml git clone https://github.com/eriwen/lcov-to-cobertura-xml.git lcov_to_xml_tag="59584761cb5da4687693faec05bf3e2b74e9dde9" # Dec 6, 2016