diff --git a/CMakeLists.txt b/CMakeLists.txt index 09a1fb9..ed9d1ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,7 +141,7 @@ if(WITH_CAM_MODELS) message(STATUS "EIGEN_INCLUDE_DIRS: ${EIGEN_INCLUDE_DIRS}") include_directories( - ${catkin_INCLUDE_DIRS} + ${CERES_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} src/mynteye/api/camodocal/include ) @@ -246,7 +246,7 @@ if(WITH_API) endif() endif() -if(NOT WITH_GLOG) +if(NOT WITH_GLOG AND NOT WITH_CAM_MODELS) list(APPEND MYNTEYE_SRCS src/mynteye/miniglog.cc) endif() @@ -269,8 +269,7 @@ if(OS_MAC) target_link_libraries( ${MYNTEYE_NAME} ${OSX_EXTRA_LIBS} ) endif() if(WITH_CAM_MODELS) -# link_directories("./_output/lib") -target_link_libraries(${MYNTEYE_NAME} "${OUT_DIR}/lib/libcamodocal.a") + target_link_libraries(${MYNTEYE_NAME} camodocal) endif() target_link_threads(${MYNTEYE_NAME}) @@ -334,6 +333,12 @@ if(NOT WITH_GLOG) DESTINATION ${MYNTEYE_CMAKE_INCLUDE_DIR} ) endif() +if(WITH_CAM_MODELS) + install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/ceres/include/ceres/internal/miniglog/glog/logging.h + DESTINATION ${MYNTEYE_CMAKE_INCLUDE_DIR}/glog + ) +endif() install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/deprecated/mynteye/callbacks.h @@ -355,7 +360,12 @@ if(WITH_API) ) endif() -install(TARGETS ${MYNTEYE_NAME} +set(__install_targets ${MYNTEYE_NAME}) +if(WITH_CAM_MODELS) + list(APPEND __install_targets camodocal) +endif() + +install(TARGETS ${__install_targets} EXPORT ${MYNTEYE_NAME}-targets RUNTIME DESTINATION ${MYNTEYE_CMAKE_BINDIR} LIBRARY DESTINATION ${MYNTEYE_CMAKE_LIBDIR} diff --git a/cmake/DetectGLog.cmake b/cmake/DetectGLog.cmake deleted file mode 100644 index daf42d7..0000000 --- a/cmake/DetectGLog.cmake +++ /dev/null @@ -1,26 +0,0 @@ -# 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/DetectOpenCV.cmake b/cmake/DetectOpenCV.cmake index d166f50..ce15c40 100644 --- a/cmake/DetectOpenCV.cmake +++ b/cmake/DetectOpenCV.cmake @@ -26,14 +26,13 @@ if(OpenCV_FOUND) #message(STATUS "Found OpenCV: ${OpenCV_VERSION}") set(WITH_OPENCV TRUE) -add_definitions(-DWITH_OPENCV) if(OpenCV_VERSION VERSION_LESS 3.0) - add_definitions(-DWITH_OPENCV2) + set(WITH_OPENCV2 TRUE) elseif(OpenCV_VERSION VERSION_LESS 4.0) - add_definitions(-DWITH_OPENCV3) + set(WITH_OPENCV3 TRUE) else() - add_definitions(-DWITH_OPENCV4) + set(WITH_OPENCV4 TRUE) endif() list(FIND OpenCV_LIBS "opencv_world" __index) diff --git a/cmake/Option.cmake b/cmake/Option.cmake index cdbd897..7380672 100644 --- a/cmake/Option.cmake +++ b/cmake/Option.cmake @@ -42,22 +42,12 @@ else() set(WITH_CAM_MODELS OFF) endif() -if(WITH_DEVICE_INFO_REQUIRED) - add_definitions(-DWITH_DEVICE_INFO_REQUIRED) -endif() - -if(WITH_CAM_MODELS) - add_definitions(-DWITH_CAM_MODELS) -endif() - if(WITH_BOOST) find_package(Boost COMPONENTS filesystem) if(Boost_FOUND) set(Boost_VERSION_STRING "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") set(WITH_FILESYSTEM TRUE) set(WITH_BOOST_FILESYSTEM TRUE) - add_definitions(-DWITH_FILESYSTEM) - add_definitions(-DWITH_BOOST_FILESYSTEM) endif() endif() @@ -65,13 +55,11 @@ if(NOT WITH_FILESYSTEM) if(MSVC OR MSYS OR MINGW) # win set(WITH_FILESYSTEM TRUE) set(WITH_NATIVE_FILESYSTEM TRUE) - add_definitions(-DWITH_FILESYSTEM) - add_definitions(-DWITH_NATIVE_FILESYSTEM) endif() endif() if(WITH_GLOG) - include(${CMAKE_CURRENT_LIST_DIR}/DetectGLog.cmake) + find_package(glog REQUIRED) endif() find_package(CUDA QUIET) diff --git a/include/mynteye/logger.h b/include/mynteye/logger.h index 83a7642..91b83fb 100644 --- a/include/mynteye/logger.h +++ b/include/mynteye/logger.h @@ -74,10 +74,23 @@ struct glog_init { } }; +#include "mynteye/mynteye.h" + +#ifdef WITH_CAM_MODELS + +#define MAX_LOG_LEVEL google::INFO + +// include ceres miniglog +#include "glog/logging.h" + +#else + #define MYNTEYE_MAX_LOG_LEVEL google::INFO #include "mynteye/miniglog.h" #endif +#endif + #endif // MYNTEYE_LOGGER_H_ diff --git a/include/mynteye/mynteye.h.in b/include/mynteye/mynteye.h.in index ee58cdf..bd2fafb 100644 --- a/include/mynteye/mynteye.h.in +++ b/include/mynteye/mynteye.h.in @@ -68,4 +68,19 @@ void UNUSED(T &&...) {} MYNTEYE_END_NAMESPACE +#cmakedefine WITH_API +#cmakedefine WITH_DEVICE_INFO_REQUIRED +#cmakedefine WITH_CAM_MODELS + +#cmakedefine WITH_OPENCV +#cmakedefine WITH_OPENCV2 +#cmakedefine WITH_OPENCV3 +#cmakedefine WITH_OPENCV4 +#cmakedefine WITH_OPENCV_WORLD + +#cmakedefine WITH_GLOG +#cmakedefine WITH_FILESYSTEM +#cmakedefine WITH_BOOST_FILESYSTEM +#cmakedefine WITH_NATIVE_FILESYSTEM + #endif // MYNTEYE_MYNTEYE_H_ diff --git a/mynteye-config.cmake.in b/mynteye-config.cmake.in index f9f666a..d064911 100644 --- a/mynteye-config.cmake.in +++ b/mynteye-config.cmake.in @@ -13,10 +13,9 @@ # limitations under the License. @PACKAGE_INIT@ -set(mynteye_WITH_API @WITH_API@) -set(mynteye_WITH_GLOG @WITH_GLOG@) set(mynteye_WITH_API @WITH_API@) set(mynteye_WITH_GLOG @WITH_GLOG@) +set(mynteye_WITH_CAM_MODELS @WITH_CAM_MODELS@) include("${CMAKE_CURRENT_LIST_DIR}/mynteye-targets.cmake") diff --git a/wrappers/ros/src/mynt_eye_ros_wrapper/CMakeLists.txt b/wrappers/ros/src/mynt_eye_ros_wrapper/CMakeLists.txt index dc8129f..41ad760 100644 --- a/wrappers/ros/src/mynt_eye_ros_wrapper/CMakeLists.txt +++ b/wrappers/ros/src/mynt_eye_ros_wrapper/CMakeLists.txt @@ -83,13 +83,10 @@ if(NOT mynteye_WITH_API) message(FATAL_ERROR "Must with API layer :(") endif() -include(cmake/DetectOpenCV.cmake) +find_package(OpenCV REQUIRED) if(mynteye_WITH_GLOG) find_package(glog REQUIRED) - if(glog_FOUND) - add_definitions(-DWITH_GLOG) - endif() endif() # targets diff --git a/wrappers/ros/src/mynt_eye_ros_wrapper/cmake/DetectOpenCV.cmake b/wrappers/ros/src/mynt_eye_ros_wrapper/cmake/DetectOpenCV.cmake deleted file mode 100644 index 4a9ef81..0000000 --- a/wrappers/ros/src/mynt_eye_ros_wrapper/cmake/DetectOpenCV.cmake +++ /dev/null @@ -1,42 +0,0 @@ -# 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() - -find_package(OpenCV REQUIRED) - -message(STATUS "Found OpenCV: ${OpenCV_VERSION}") - -set(WITH_OPENCV TRUE) -add_definitions(-DWITH_OPENCV) - -if(OpenCV_VERSION VERSION_LESS 3.0) - add_definitions(-DWITH_OPENCV2) -elseif(OpenCV_VERSION VERSION_LESS 4.0) - add_definitions(-DWITH_OPENCV3) -else() - add_definitions(-DWITH_OPENCV4) -endif() - -list(FIND OpenCV_LIBS "opencv_world" __index) -if(${__index} GREATER -1) - set(WITH_OPENCV_WORLD TRUE) -endif() - -if(MSVC OR MSYS OR MINGW) - get_filename_component(OpenCV_LIB_SEARCH_PATH "${OpenCV_LIB_PATH}/../bin" ABSOLUTE) -else() - set(OpenCV_LIB_SEARCH_PATH "${OpenCV_LIB_PATH}") -endif() diff --git a/wrappers/ros/src/mynt_eye_ros_wrapper/cmake/IncludeGuard.cmake b/wrappers/ros/src/mynt_eye_ros_wrapper/cmake/IncludeGuard.cmake deleted file mode 100644 index 4c5dd68..0000000 --- a/wrappers/ros/src/mynt_eye_ros_wrapper/cmake/IncludeGuard.cmake +++ /dev/null @@ -1,23 +0,0 @@ -# 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_guard: https://cmake.org/cmake/help/latest/command/include_guard.html - -macro(cmake_include_guard) - get_property(INCLUDE_GUARD GLOBAL PROPERTY "_INCLUDE_GUARD_${CMAKE_CURRENT_LIST_FILE}") - if(INCLUDE_GUARD) - return() - endif() - set_property(GLOBAL PROPERTY "_INCLUDE_GUARD_${CMAKE_CURRENT_LIST_FILE}" TRUE) -endmacro()