-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
164 lines (145 loc) · 7.47 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
cmake_minimum_required(VERSION 2.8)
set(PROJECT_NAME "REVO")
project(${PROJECT_NAME})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/" )
MESSAGE("cmake: ${CMAKE_SOURCE_DIR}/ThirdParty/libuvc/build/CMakeFiles")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -O1 -msse3 -msse4.1 -mavx2 -fopenmp")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O1 -msse3 -msse4.1 -mavx2 -fopenmp")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -msse3 -msse4.1 -mavx2 -fopenmp")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -msse3 -msse4.1 -mavx2 -fopenmp")
SET(CMAKE_BUILD_TYPE DEBUG)
#SET(CMAKE_BUILD_TYPE RELEASE)
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")
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has C++11 support. Please use a different C++ compiler.")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
#thirdparty
OPTION(WITH_PANGOLIN_VIEWER "Build with Pangolin viewer?" ON)
if (WITH_PANGOLIN_VIEWER)
find_package(Pangolin REQUIRED)
include_directories(${Pangolin_INCLUDE_DIRS})
list(APPEND LIBS ${Pangolin_LIBRARIES})
list(APPEND SRC_FILES "gui/Viewer.cc" "gui/MapDrawer.cc")
list(APPEND HEADER_FILES "gui/Viewer.h" "gui/MapDrawer.h" "gui/PointCloudBuffered.h")
add_definitions(-DWITH_PANGOLIN_VIEWER)
endif()
#LibRealSense
OPTION(WITH_REALSENSE "Build with RealSense Sensor?" ON)
if (WITH_REALSENSE)
list(APPEND SRC_FILES "io/realsensesensor.cpp")
list(APPEND HEADER_FILES "io/realsensesensor.h")
add_definitions(-DWITH_REALSENSE)
list(APPEND LIBS "realsense")
endif()
find_package(OpenCV 4 REQUIRED opencv_core opencv_videoio opencv_imgcodecs opencv_imgproc opencv_calib3d opencv_highgui)
if(NOT OpenCV_FOUND)
find_package(OpenCV 2.4.3 QUIET)
if(NOT OpenCV_FOUND)
message(FATAL_ERROR "OpenCV > 2.4.3 not found.")
endif()
endif()
#Orbbec Astra
#OPTION(WITH_ORBBEC_ASTRA_PRO "Build with Orbbec support?" ON)
OPTION(WITH_ORBBEC_FFMPEG "Use FFMPEG for ORBBEC Astra Pro (recommended)" ON)
OPTION(WITH_ORBBEC_UVC "Use LibUVC for ORBBEC Astra Pro (not recommended)" OFF)
OPTION(WITH_ORBBEC_OPENNI "Use OpenNI for ORBBEC Astra (NOTE: This is for the non-pro version!!)" ON)
IF (WITH_ORRBEC_FFMPEG AND WITH_ORBBEC_UVC)
MESSAGE(FATAL_ERROR "Please choose either FFMPEG (recommended) or libUVC for Orbbec Astra support")
ENDIF()
IF (WITH_ORBBEC_UVC)
IF (WITH_REALSENSE)
MESSAGE(FATAL_ERROR "CAN'T BUILD WITH REALSENSE AND ORBBEC SENSOR!!! This is because of the different libuvc versions!")
ENDIF(WITH_REALSENSE)
find_package(libuvc REQUIRED)
IF(DEFINED libuvc_INCLUDE_DIRS)
include_directories(${libuvc_INCLUDE_DIRS})
add_definitions(-DCOMPILE_WITH_LibUVC)
list(APPEND LIBS "${libuvc_LIBRARIES}")
list(APPEND SRC_FILES "orbbec_astra_pro/OrbbecAstraEngineUVC.cpp")
list(APPEND HEADER_FILES "orbbec_astra_pro/OrbbecAstraEngineUVC.h")
if (NOT DEFINED OpenNI_ASTRA_PRO_LIB)
set(OpenNI_ASTRA_PRO_LIB "${CMAKE_SOURCE_DIR}/orbbec_astra_pro/drivers/libOpenNI2.so")
endif()
if (NOT DEFINED OpenNI_ASTRA_PRO_INCLUDE_DIR)
set(OpenNI_ASTRA_PRO_INCLUDE_DIR " ${CMAKE_SOURCE_DIR}/orbbec_astra_pro/drivers/Include/")
endif()
include_directories(${OpenNI_ASTRA_PRO_INCLUDE_DIR})
list(APPEND LIBS ${OpenNI_ASTRA_PRO_LIB} ${OpenCV_LIBS})
ELSE()
MESSAGE(FATAL_ERROR "LIBUVC directories not found!")
ENDIF()
add_definitions(-DWITH_ORBBEC_ASTRA_PRO)
ENDIF(WITH_ORBBEC_UVC)
IF (WITH_ORBBEC_FFMPEG)
if (NOT DEFINED OpenNI_ASTRA_PRO_LIB)
set(OpenNI_ASTRA_PRO_LIB "${CMAKE_SOURCE_DIR}/orbbec_astra_pro/drivers/libOpenNI2.so")
endif()
if (NOT DEFINED OpenNI_ASTRA_PRO_INCLUDE_DIR)
set(OpenNI_ASTRA_PRO_INCLUDE_DIR " ${CMAKE_SOURCE_DIR}/orbbec_astra_pro/drivers/Include/")
endif()
include_directories(${OpenNI_ASTRA_PRO_INCLUDE_DIR})
list(APPEND LIBS ${OpenNI_ASTRA_PRO_LIB})
add_definitions(-DWITH_ORBBEC_FFMPEG)
include("cmake/external_FFMPEG.cmake")
#now we try to add ffmpeg
list(APPEND SRC_FILES "orbbec_astra_pro/OrbbecAstraEngineFFMPEG.cpp")
list(APPEND HEADER_FILES "orbbec_astra_pro/OrbbecAstraEngineFFMPEG.h")
include_directories(${FFMPEG_INCLUDE_DIR})
add_definitions(-DWITH_ORBBEC_ASTRA_PRO)
ENDIF(WITH_ORBBEC_FFMPEG)
#for the standard Orbbec Astra
IF (WITH_ORBBEC_OPENNI)
if (NOT DEFINED OpenNI_ASTRA_PRO_LIB)
set(OpenNI_ASTRA_PRO_LIB "${CMAKE_SOURCE_DIR}/orbbec_astra_pro/drivers/libOpenNI2.so")
endif()
if (NOT DEFINED OpenNI_ASTRA_PRO_INCLUDE_DIR)
set(OpenNI_ASTRA_PRO_INCLUDE_DIR " ${CMAKE_SOURCE_DIR}/orbbec_astra_pro/drivers/Include/")
endif()
include_directories(${OpenNI_ASTRA_PRO_INCLUDE_DIR})
list(APPEND SRC_FILES "orbbec_astra_pro/OrbbecAstraOpenNIEngine.cpp")
list(APPEND HEADER_FILES "orbbec_astra_pro/OrbbecAstraOpenNIEngine.h")
add_definitions(-DWITH_ORBBEC_ASTRA)
ENDIF(WITH_ORBBEC_OPENNI)
list(APPEND LIBS ${OpenCV_LIBS})
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${FLAGS}")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS}")
message("OpenCV: ${OpenCV_INCLUDE_DIRS}")
find_package(Eigen3 REQUIRED)
INCLUDE_DIRECTORIES("thirdparty/Sophus")
include_directories(${EIGEN3_INCLUDE_DIRS})
message("Eigen found: ${EIGEN3_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} ${Eigen_INCLUDE_DIRS}")
# just try
#SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "/usr/local/include/boost")
#SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "/usr/local/boost_1_70_0" "/usr/lib/x86_64-linux-gnu")
find_package(Boost COMPONENTS system filesystem REQUIRED)
list(APPEND LIBS ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY})
list(APPEND LIBS /usr/local/lib/libboost_filesystem.so.1.70 /usr/local/lib/libboost_system.so.1.70)
#UTILS
list(APPEND UTILITY_SRC_FILES "utils/Logging.cpp")
list(APPEND UTILITY_HEADER_FILES "utils/timer.h" "utils/Logging.h")
#DATA STRUCTURES
list(APPEND DATASTRUC_SRC_FILES "datastructures/imgpyramidrgbd.cpp")
list(APPEND DATASTRUC_HEADER_FILES "datastructures/imgpyramidrgbd.h" "datastructures/camerapyr.h")
#Input/Output
list(APPEND DATASTRUC_SRC_FILES "io/iowrapperRGBD.cpp")
list(APPEND DATASTRUC_HEADER_FILES "io/iowrapperRGBD.h")
#CORE SYSTEM
list(APPEND DATASTRUC_SRC_FILES "system/system.cpp" "system/tracker.cpp" "system/optimizer.cpp")# "system/windowedoptimization.cpp")
list(APPEND DATASTRUC_HEADER_FILES "system/system.h" "system/tracker.h" "system/optimizer.h")# "system/windowedoptimization.h")
list(APPEND SRC_FILES ${SRC_FILES} "main.cpp")
add_executable(${PROJECT_NAME} ${SRC_FILES} ${HEADER_FILES} ${UTILITY_SRC_FILES} ${UTILITY_HEADER_FILES} ${DATASTRUC_SRC_FILES} ${DATASTRUC_HEADER_FILES})
message("libuvc_LIBRARIES: ${libuvc_LIBRARIES}, ${LIBS}")
message("ffmpeg_include_dir: ${FFMPEG_INCLUDE_DIR}")
message("ffmpeg_libraries: ${FFMPEG_LIBRARIES}")
#target_link_libraries(${PROJECT_NAME} ${LIBS} /usr/lib/x86_64-linux-gnu/libxcb.so.1 /usr/lib/x86_64-linux-gnu/libxcb-shm.so.0 ${FFMPEG_LIBRARIES})
target_link_libraries(${PROJECT_NAME} ${LIBS} ${FFMPEG_LIBRARIES} ${XCB_LIBRARIES})