Build pass without glog

This commit is contained in:
John Zhao 2018-09-04 16:07:36 +08:00
parent 02856194a0
commit 94ecacef6c
5 changed files with 50 additions and 2 deletions

View File

@ -44,6 +44,17 @@ message(STATUS "CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
# packages
find_package(Threads QUIET)
macro(target_link_threads NAME)
if(THREADS_HAVE_PTHREAD_ARG)
target_compile_options(PUBLIC ${NAME} "-pthread")
endif()
if(CMAKE_THREAD_LIBS_INIT)
target_link_libraries(${NAME} "${CMAKE_THREAD_LIBS_INIT}")
endif()
endmacro()
LIST(APPEND CMAKE_MODULE_PATH cmake)
include(CMakePackageConfigHelpers)
@ -176,6 +187,7 @@ endif()
add_library(${MYNTEYE_NAME} SHARED ${MYNTEYE_SRCS})
target_link_libraries(${MYNTEYE_NAME} ${MYNTEYE_LINKLIBS})
target_link_threads(${MYNTEYE_NAME})
if(OS_WIN)
target_compile_definitions(${MYNTEYE_NAME}

View File

@ -29,7 +29,7 @@ option(WITH_DEVICE_INFO_REQUIRED "Build with device info required" ON)
option(WITH_BOOST "Include Boost support" ON)
# `make 3rdparty` could build glog submodule
option(WITH_GLOG "Include glog support" ON)
option(WITH_GLOG "Include glog support" OFF)
# packages

View File

@ -15,6 +15,8 @@
#define MYNTEYE_LOGGER_H_
#pragma once
#ifdef WITH_GLOG
#include <glog/logging.h>
/** Helper to init glog with args. */
@ -62,4 +64,34 @@ struct glog_init {
}
};
#else
#include <iostream>
struct glog_init {
glog_init(int argc, char *argv[]) {
(void)argc;
(void)argv;
}
};
#define LOG(severity) std::cout
#define LOG_IF(severity, condition) std::cout
#define VLOG(verboselevel) std::cout
#define VLOG_IS_ON(verboselevel) false
#define CHECK(val) std::cout
#define CHECK_EQ(val1, val2) std::cout
#define CHECK_NE(val1, val2)
#define CHECK_LE(val1, val2)
#define CHECK_LT(val1, val2)
#define CHECK_GE(val1, val2)
#define CHECK_GT(val1, val2)
#define CHECK_NOTNULL(val)
#endif
#endif // MYNTEYE_LOGGER_H_

View File

@ -15,7 +15,7 @@
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <sstream>
#include "mynteye/logger.h"

View File

@ -16,6 +16,9 @@
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/stat.h>
@ -27,6 +30,7 @@
#include <chrono>
#include <fstream>
#include <sstream>
#include <string>
#include <thread>