Add glog option

This commit is contained in:
John Zhao 2018-09-04 14:35:27 +08:00
parent 55165b8878
commit 30a9397602
10 changed files with 79 additions and 41 deletions

View File

@ -44,10 +44,6 @@ message(STATUS "CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
# packages
LIST(APPEND CMAKE_PREFIX_PATH third_party/glog/_build)
find_package(glog REQUIRED)
message(STATUS "Found glog: ${glog_VERSION}")
LIST(APPEND CMAKE_MODULE_PATH cmake)
include(CMakePackageConfigHelpers)
@ -90,12 +86,14 @@ set(MYNTEYE_CMAKE_INSTALLDIR "${MYNTEYE_CMAKE_LIBDIR}/cmake/${MYNTEYE_NAME}")
## main
add_executable(main src/main.cc)
target_link_libraries(main glog::glog)
target_include_directories(main PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/include
)
if(WITH_GLOG)
add_executable(main src/main.cc)
target_link_libraries(main glog::glog)
target_include_directories(main PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/include
)
endif()
## libmynteye
@ -164,16 +162,16 @@ if(WITH_API)
)
endif()
set(MYNTEYE_LINKLIBS
glog::glog
${UVC_LIB}
)
set(MYNTEYE_LINKLIBS ${UVC_LIB})
if(WITH_API)
list(APPEND MYNTEYE_LINKLIBS ${OpenCV_LIBS})
endif()
if(WITH_BOOST_FILESYSTEM)
list(APPEND MYNTEYE_LINKLIBS ${Boost_LIBRARIES})
endif()
if(WITH_GLOG)
list(APPEND MYNTEYE_LINKLIBS glog::glog)
endif()
#message(STATUS "MYNTEYE_LINKLIBS: ${MYNTEYE_LINKLIBS}")
add_library(${MYNTEYE_NAME} SHARED ${MYNTEYE_SRCS})

View File

@ -30,9 +30,10 @@ help:
@echo " make apidoc make api doc"
@echo " make opendoc open api doc (html)"
@echo " make init init project"
@echo " make 3rdparty build 3rdparty: glog"
@echo " make build build project"
@echo " make test build test and run"
@echo " make install install project"
@echo " make test build test and run"
@echo " make samples build samples"
@echo " make tools build tools"
@echo " make ros build ros wrapper"
@ -41,7 +42,7 @@ help:
.PHONY: help
all: test tools samples
all: test samples tools
.PHONY: all
@ -75,7 +76,9 @@ third_party: submodules
@$(call echo,Make glog,33)
@$(call cmake_build,./third_party/glog/_build)
.PHONY: submodules third_party
3rdparty: third_party
.PHONY: submodules third_party 3rdparty
# init
@ -87,7 +90,7 @@ init: submodules
# build
build: third_party
build: submodules
@$(call echo,Make $@)
ifeq ($(HOST_OS),Win)
@$(call cmake_build,./_build,..,-DCMAKE_INSTALL_PREFIX=$(MKFILE_DIR)/_install)

26
cmake/DetectGLog.cmake Normal file
View File

@ -0,0 +1,26 @@
# Copyright 2018 Slightech Co., Ltd. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
include(${CMAKE_CURRENT_LIST_DIR}/IncludeGuard.cmake)
cmake_include_guard()
get_filename_component(__pro_dir ${CMAKE_CURRENT_LIST_DIR} DIRECTORY)
LIST(APPEND CMAKE_PREFIX_PATH ${__pro_dir}/third_party/glog/_build)
find_package(glog REQUIRED)
if(glog_FOUND)
add_definitions(-DWITH_GLOG)
endif()
unset(__pro_dir)

View File

@ -28,6 +28,9 @@ 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)
# packages
@ -59,6 +62,10 @@ if(NOT WITH_FILESYSTEM)
endif()
endif()
if(WITH_GLOG)
include(${CMAKE_CURRENT_LIST_DIR}/DetectGLog.cmake)
endif()
find_package(CUDA QUIET)
# summary
@ -125,6 +132,16 @@ if(WITH_BOOST)
endif()
endif()
status(" WITH_GLOG: ${WITH_GLOG}")
if(WITH_GLOG)
if(glog_FOUND)
status(" glog: YES")
status(" glog_VERSION: ${glog_VERSION}")
else()
status(" glog: NO")
endif()
endif()
status("")
status("Features:")
status(" Filesystem: "

View File

@ -14,4 +14,7 @@
@PACKAGE_INIT@
set(mynteye_WITH_API @WITH_API@)
set(mynteye_WITH_GLOG @WITH_GLOG@)
include("${CMAKE_CURRENT_LIST_DIR}/mynteye-targets.cmake")

View File

@ -47,10 +47,6 @@ message(STATUS "CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
# packages
LIST(APPEND CMAKE_PREFIX_PATH ${PRO_DIR}/third_party/glog/_build)
find_package(glog REQUIRED)
message(STATUS "Found glog: ${glog_VERSION}")
LIST(APPEND CMAKE_PREFIX_PATH ${PRO_DIR}/_install/lib/cmake)
find_package(mynteye REQUIRED)
message(STATUS "Found mynteye: ${mynteye_VERSION}")

View File

@ -57,16 +57,16 @@ message(STATUS "CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
# packages
LIST(APPEND CMAKE_PREFIX_PATH ${PRO_DIR}/third_party/glog/_build)
find_package(glog REQUIRED)
message(STATUS "Found glog: ${glog_VERSION}")
LIST(APPEND CMAKE_PREFIX_PATH ${PRO_DIR}/_install/lib/cmake)
find_package(mynteye REQUIRED)
message(STATUS "Found mynteye: ${mynteye_VERSION}")
include(${PRO_DIR}/cmake/DetectOpenCV.cmake)
if(mynteye_WITH_GLOG)
include(${PRO_DIR}/cmake/DetectGLog.cmake)
endif()
#LIST(APPEND CMAKE_MODULE_PATH ${PRO_DIR}/cmake)
## gtest

View File

@ -43,16 +43,16 @@ message(STATUS "CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
# packages
LIST(APPEND CMAKE_PREFIX_PATH ${PRO_DIR}/third_party/glog/_build)
find_package(glog REQUIRED)
message(STATUS "Found glog: ${glog_VERSION}")
LIST(APPEND CMAKE_PREFIX_PATH ${PRO_DIR}/_install/lib/cmake)
find_package(mynteye REQUIRED)
message(STATUS "Found mynteye: ${mynteye_VERSION}")
include(${PRO_DIR}/cmake/DetectOpenCV.cmake)
if(mynteye_WITH_GLOG)
include(${PRO_DIR}/cmake/DetectGLog.cmake)
endif()
#LIST(APPEND CMAKE_MODULE_PATH ${PRO_DIR}/cmake)
# targets

View File

@ -77,10 +77,6 @@ message(STATUS "CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
# packages
LIST(APPEND CMAKE_PREFIX_PATH ${PRO_DIR}/third_party/glog/_build)
find_package(glog REQUIRED)
message(STATUS "Found glog: ${glog_VERSION}")
LIST(APPEND CMAKE_PREFIX_PATH ${PRO_DIR}/_install/lib/cmake)
find_package(mynteye REQUIRED)
message(STATUS "Found mynteye: ${mynteye_VERSION}")

View File

@ -56,9 +56,6 @@ checkPackage("sensor_msgs" "")
checkPackage("std_msgs" "")
checkPackage("tf" "")
find_package(OpenCV REQUIRED)
message(STATUS "Found OpenCV: ${OpenCV_VERSION}")
## messages
add_message_files(
@ -82,14 +79,16 @@ catkin_package(
get_filename_component(SDK_DIR "${PROJECT_SOURCE_DIR}/../../../.." ABSOLUTE)
LIST(APPEND CMAKE_PREFIX_PATH ${SDK_DIR}/third_party/glog/_build)
find_package(glog REQUIRED)
message(STATUS "Found glog: ${glog_VERSION}")
LIST(APPEND CMAKE_PREFIX_PATH ${SDK_DIR}/_install/lib/cmake)
find_package(mynteye REQUIRED)
message(STATUS "Found mynteye: ${mynteye_VERSION}")
include(${SDK_DIR}/cmake/DetectOpenCV.cmake)
if(mynteye_WITH_GLOG)
include(${SDK_DIR}/cmake/DetectGLog.cmake)
endif()
# targets
add_compile_options(-std=c++11)