From 3e184b4cfc5c1ce59d89eafe5961b4d31ead00a5 Mon Sep 17 00:00:00 2001 From: innerNULL Date: Thu, 7 Jul 2022 11:42:28 +0000 Subject: [PATCH] dev: Integrates glog/gflags with FetchContent style. --- CMakeLists.txt | 21 +++++++++++++++++++++ README.md | 2 +- qmf/bpr.cpp | 4 ++-- qmf/wals.cpp | 4 ++-- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7624194..9b04a29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin/") set(CMAKE_FILES_DIRECTORY "build/") # includes +include(FetchContent) include_directories(SYSTEM ${PROJECT_SOURCE_DIR}) include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/qmf/third-party/gtest-1.7.0/fused-src) @@ -42,6 +43,26 @@ set(SOURCES ${PROJECT_SOURCE_DIR}/qmf/utils/Util.cpp ) +set(FETCHCONTENT_QUIET FALSE) + +FetchContent_Declare( + glog + GIT_REPOSITORY https://github.com/google/glog.git + GIT_TAG v0.4.0 + GIT_PROGRESS TRUE +) +FetchContent_Declare(glog) +FetchContent_MakeAvailable(glog) + +FetchContent_Declare( + gflags + GIT_REPOSITORY https://github.com/gflags/gflags.git + GIT_TAG v2.2.2 + GIT_PROGRESS TRUE +) +FetchContent_Declare(gflags) +FetchContent_MakeAvailable(gflags) + add_library(qmf STATIC ${SOURCES}) target_link_libraries(qmf glog gflags lapack) diff --git a/README.md b/README.md index d8eb4d0..d4af47b 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ QMF requires gcc 5.0+, as it uses the C++14 standard, and CMake version 2.8+. It To install libraries dependencies: ``` -sudo apt-get install libgoogle-glog-dev libgflags-dev liblapack-dev +sudo apt-get install liblapack-dev ``` To build the binaries: diff --git a/qmf/bpr.cpp b/qmf/bpr.cpp index ad03bd4..d418602 100644 --- a/qmf/bpr.cpp +++ b/qmf/bpr.cpp @@ -59,8 +59,8 @@ DEFINE_string(user_factors, "", "filename of user factors"); DEFINE_string(item_factors, "", "filename of item factors"); int main(int argc, char** argv) { - google::SetUsageMessage("bpr"); - google::ParseCommandLineFlags(&argc, &argv, true); + gflags::SetUsageMessage("bpr"); + gflags::ParseCommandLineFlags(&argc, &argv, true); google::InitGoogleLogging(argv[0]); // make glog to log to stderr FLAGS_logtostderr = 1; diff --git a/qmf/wals.cpp b/qmf/wals.cpp index 8ecbf51..4764569 100644 --- a/qmf/wals.cpp +++ b/qmf/wals.cpp @@ -49,8 +49,8 @@ DEFINE_string(user_factors, "", "filename of user factors"); DEFINE_string(item_factors, "", "filename of item factors"); int main(int argc, char** argv) { - google::SetUsageMessage("wals"); - google::ParseCommandLineFlags(&argc, &argv, true); + gflags::SetUsageMessage("wals"); + gflags::ParseCommandLineFlags(&argc, &argv, true); google::InitGoogleLogging(argv[0]); // make glog to log to stderr FLAGS_logtostderr = 1;