Skip to content

Commit

Permalink
Add glog option
Browse files Browse the repository at this point in the history
  • Loading branch information
John Zhao committed Sep 4, 2018
1 parent 55165b8 commit 30a9397
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 41 deletions.
26 changes: 12 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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})
Expand Down
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -41,7 +42,7 @@ help:

.PHONY: help

all: test tools samples
all: test samples tools

.PHONY: all

Expand Down Expand Up @@ -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

Expand All @@ -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)
Expand Down
26 changes: 26 additions & 0 deletions cmake/DetectGLog.cmake
Original file line number Diff line number Diff line change
@@ -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)
17 changes: 17 additions & 0 deletions cmake/Option.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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: "
Expand Down
3 changes: 3 additions & 0 deletions mynteye-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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")
4 changes: 0 additions & 4 deletions samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
8 changes: 4 additions & 4 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions wrappers/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
13 changes: 6 additions & 7 deletions wrappers/ros/src/mynt_eye_ros_wrapper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
Expand Down

0 comments on commit 30a9397

Please sign in to comment.