-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathCMakeLists.txt
115 lines (94 loc) · 3.46 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
cmake_minimum_required(VERSION 2.8.12)
set(PROJECT_NAME my_vio)
project( ${PROJECT_NAME})
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread")
else()
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
# cmake -DTEST=ON to enable the tests.
option(USE_TEST "Build tests." OFF)
option(PROFILE_CPU "Profile CPU." OFF)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
if (USE_TEST)
enable_testing()
include_directories(thirdparty/googletest/googletest/include)
add_subdirectory(thirdparty/googletest/googletest)
# Configure path for test data
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.hpp.in
${CMAKE_CURRENT_SOURCE_DIR}/config.hpp @ONLY IMMEDIATE)
install(FILES config.hpp
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME}/)
endif()
if (ENABLE_VIZ)
add_definitions("-DUSE_VISUALIZATION")
endif()
if (PROFILE_CPU)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lprofiler")
endif()
# FindX.cmake files
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
find_package( OpenCV REQUIRED )
find_package( Eigen3 REQUIRED )
find_package( Ceres REQUIRED)
include_directories(
${OpenCV_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
)
# Use <package>_<component>_FOUND for a module in package.
if (OPENCV_SFM_FOUND)
add_definitions("-DSFM_FOUND")
# Fix for using cv::reconstruct
add_definitions("-DCERES_FOUND")
message(STATUS "OpenCV sfm is supported. Used in Landmark Initialization.")
else()
message(WARNING "Libmv reconstruction is disabled. OpenCV sfm for reconstruction API is required.")
endif()
if (OPENCV_VIZ_FOUND)
add_definitions("-DOPENCV_VIZ_FOUND")
endif()
message(STATUS "OpenCV library status:")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
message(STATUS "Eigen library status:")
message(STATUS " include path: ${EIGEN3_INCLUDE_DIR}")
message(STATUS "Ceres library status:")
message(STATUS " libraries: ${CERES_LIBRARIES}")
message(STATUS " include path: ${CERES_INCLUDE_DIR}")
# For config.hpp used in tests in subdirectories.
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(util)
add_subdirectory(dataset_loader)
add_subdirectory(mapdata)
add_subdirectory(camera_model)
add_subdirectory(simulator)
add_subdirectory(feature_tracker)
add_subdirectory(imu_integrator)
add_subdirectory(orientation_tracking)
add_subdirectory(multiview_helper)
add_subdirectory(map_initializer)
add_subdirectory(graph_optimizer)
add_subdirectory(pnp_estimator)
add_subdirectory(visual_inertial_odometry)
###########################################################################
# Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry)
export(PACKAGE my_vio)
# Add all targets to the build-tree export set
export(TARGETS
util
camera_model
mapdata
feature_tracker
imu_integrator
orientation_tracking
FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")
message(STATUS "Added Include Directory: ${CMAKE_INSTALL_PREFIX}")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/my_vioConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/my_vioConfig.cmake @ONLY IMMEDIATE)