fix(cmake): fix include ceres and move definitions to mynteye.h

This commit is contained in:
John Zhao 2019-01-14 17:25:41 +08:00
parent 60ea66b1ec
commit b114dc8159
10 changed files with 49 additions and 119 deletions

View File

@ -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
)
@ -245,7 +245,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()
@ -268,8 +268,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})
@ -333,6 +332,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
@ -354,7 +359,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}

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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_

View File

@ -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_

View File

@ -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")

View File

@ -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

View File

@ -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()

View File

@ -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()