diff --git a/CMakeLists.txt b/CMakeLists.txt index 62c59a4..1da872b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) diff --git a/Makefile b/Makefile index e8555fd..5483d78 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/cmake/DetectGLog.cmake b/cmake/DetectGLog.cmake new file mode 100644 index 0000000..daf42d7 --- /dev/null +++ b/cmake/DetectGLog.cmake @@ -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) diff --git a/cmake/Option.cmake b/cmake/Option.cmake index f649391..8a414fd 100644 --- a/cmake/Option.cmake +++ b/cmake/Option.cmake @@ -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: " diff --git a/mynteye-config.cmake.in b/mynteye-config.cmake.in index aaeb16a..3514b78 100644 --- a/mynteye-config.cmake.in +++ b/mynteye-config.cmake.in @@ -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") diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 2a0c4c6..4781867 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -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}") diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 11c68cd..18be45b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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 diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index a617541..4d57c04 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -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 diff --git a/wrappers/python/CMakeLists.txt b/wrappers/python/CMakeLists.txt index 4cecbff..384407d 100644 --- a/wrappers/python/CMakeLists.txt +++ b/wrappers/python/CMakeLists.txt @@ -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}") diff --git a/wrappers/ros/src/mynt_eye_ros_wrapper/CMakeLists.txt b/wrappers/ros/src/mynt_eye_ros_wrapper/CMakeLists.txt index 83ffce1..74a36d1 100644 --- a/wrappers/ros/src/mynt_eye_ros_wrapper/CMakeLists.txt +++ b/wrappers/ros/src/mynt_eye_ros_wrapper/CMakeLists.txt @@ -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)