-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
235 lines (218 loc) · 8.27 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
cmake_minimum_required(VERSION 3.20)
project(StructureFromMotion VERSION 1.0 DESCRIPTION "A structure from motion pipeline.")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Detect clang. Not officially reported by cmake.
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-v" ERROR_VARIABLE CXX_VER_STDERR)
if ("${CXX_VER_STDERR}" MATCHES ".*clang.*")
set (CMAKE_COMPILER_IS_CLANGXX 1)
endif ()
if (CMAKE_COMPILER_IS_CLANGXX)
message("Compiling using clang")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
message("Compiling using msvc")
set(warnings "/W4 /WX /EHsc")
else()
message( FATAL_ERROR "This project should only be compiled with clang or msvc. Currently detected ${CMAKE_CXX_COMPILER_ID}." )
endif()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
find_package(Ceres REQUIRED)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
message(" ")
if (CMAKE_BUILD_TYPE MATCHES Debug)
message("DEBUG BUILD")
add_definitions(
-DDEBUG
)
elseif(CMAKE_BUILD_TYPE MATCHES Release)
message("RELEASE BUILD")
else()
message( FATAL_ERROR "Build type not recognised: ${CMAKE_BUILD_TYPE}." )
endif ()
message(" ")
add_executable(
StructureFromMotion
src/main.cpp
headers/constants.h
headers/point_cloud.h
headers/camera.h src/camera.cpp
headers/types.h
headers/cli_util.h src/cli_util.cpp
headers/imagecollection.h src/imagecollection.cpp headers/image.h headers/features.h
headers/matches.h src/matches.cpp src/features.cpp
headers/sfm_util.h src/sfm_util.cpp
headers/scene_graph.h src/scene_graph.cpp
headers/scene_reconstruction.h src/scene_reconstruction.cpp
headers/pose.h src/pose.cpp src/point_cloud.cpp
headers/ba_util.h
headers/cost/simple_reprojection_error.h
headers/cost/rotation_free_error.h src/cost/rotation_free_error.cpp
headers/triangulation/triangulator.h src/triangulation/triangulator.cpp
src/bundle-adjustment/bundle_adjuster.cpp
headers/filters/filter.h src/filters/filter.cpp
headers/vector_util.h src/vector_util.cpp src/ba_util.cpp)
target_sources(
StructureFromMotion
PUBLIC
)
target_include_directories(
StructureFromMotion
PUBLIC
${CMAKE_SOURCE_DIR}
/Users/meganfinch/opencv-4.5.3/include
/Users/meganfinch/opencv-4.5.3/cmake-build-release
/Users/meganfinch/opencv-4.5.3/modules/calib3d/include
/Users/meganfinch/opencv-4.5.3/modules/core/include
/Users/meganfinch/opencv-4.5.3/modules/features2d/include
/Users/meganfinch/opencv-4.5.3/modules/highgui/include
/Users/meganfinch/opencv-4.5.3/modules/flann/include
/Users/meganfinch/opencv-4.5.3/modules/imgproc/include
/Users/meganfinch/opencv-4.5.3/modules/imgcodecs/include
/Users/meganfinch/opencv-4.5.3/modules/videoio/include
#/Users/meganfinch/ceres-solver/include
#/Users/meganfinch/ceres-solver/cmake-build-release/config
/Users/meganfinch/eigen
/Users/meganfinch/glog/cmake-build-release
/Users/meganfinch/glog/src
/Users/meganfinch/gflags/cmake-build-release/include
#/Users/meganfinch/CLionProjects/Pickle/headers
)
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
if (CMAKE_COMPILER_IS_CLANGXX)
#target_compile_options(sfm PRIVATE "-Werror")
target_compile_options(StructureFromMotion PRIVATE "-Weverything")
target_compile_options(StructureFromMotion PRIVATE "-Wno-c99-extensions")
target_compile_options(StructureFromMotion PRIVATE "-Wno-c++98-compat")
target_compile_options(StructureFromMotion PRIVATE "-Wno-c++98-compat-pedantic")
target_compile_options(StructureFromMotion PRIVATE "-Wno-padded")
endif()
# Where linker should search for libraries
target_link_directories(
StructureFromMotion
PUBLIC
"${CMAKE_SOURCE_DIR}"
"/Users/meganfinch/opencv-4.5.3/cmake-build-release/lib"
#"/Users/meganfinch/ceres-solver/cmake-build-release/lib"
#"/Users/meganfinch/gflags/cmake-build-release/lib"
#"/Users/meganfinch/glog/cmake-build-release/"
#/Users/meganfinch/CLionProjects/Pickle/cmake-build-release/
)
target_link_libraries(
StructureFromMotion
Threads::Threads
opencv_calib3d
opencv_core
opencv_dnn
opencv_features2d
opencv_flann
opencv_gapi
opencv_highgui
opencv_imgcodecs
opencv_imgproc
opencv_ml
opencv_objdetect
opencv_photo
opencv_stitching
opencv_videoio
opencv_video
ceres
#Pickle
#gflags
#glog
)
# ------- BUILDING LIBRARY -------
# add_library(
# SFMLib
# STATIC
# headers/constants.h
# headers/point_cloud.h src/point_cloud.cpp
# headers/camera.h src/camera.cpp
# headers/types.h
# headers/cli_util.h src/cli_util.cpp
# headers/imagecollection.h src/imagecollection.cpp
# headers/image.h
# headers/features.h src/features.cpp
# headers/matches.h src/matches.cpp
# headers/sfm_util.h src/sfm_util.cpp
# headers/scene_graph.h src/scene_graph.cpp
# headers/scene_reconstruction.h src/scene_reconstruction.cpp
# headers/pose.h src/pose.cpp
# headers/cost/simple_reprojection_error.h
# headers/cost/rotation_free_error.h src/cost/rotation_free_error.cpp
# headers/image_pair.h
# headers/cli_args.h
# headers/triangulation/triangulator.h src/triangulation/triangulator.cpp
# headers/triangulation/linear_triangulator.h
# headers/triangulation/midpoint_triangulator.h
# headers/bundle-adjustment/bundle_adjuster.h src/bundle-adjustment/bundle_adjuster.cpp
# headers/bundle-adjustment/dummy_bundle_adjuster.h
# headers/bundle-adjustment/basic_bundle_adjuster.h
# headers/bundle-adjustment/zhang_bundle_adjuster.h
# headers/bundle.h headers/vector_util.h
# headers/filters/filter.h src/filters/filter.cpp
# headers/filters/statistical_outlier_filter.h
# headers/filters/radial_outlier_filter.h headers/map_util.h headers/cost/faster_rotation_free_error.h src/cost/faster_rotation_free_error.cpp)
#
# target_include_directories(
# SFMLib
# PUBLIC
# ${CMAKE_SOURCE_DIR}
# /Users/meganfinch/opencv-4.5.3/include
# /Users/meganfinch/opencv-4.5.3/cmake-build-release
# /Users/meganfinch/opencv-4.5.3/modules/calib3d/include
# /Users/meganfinch/opencv-4.5.3/modules/core/include
# /Users/meganfinch/opencv-4.5.3/modules/features2d/include
# /Users/meganfinch/opencv-4.5.3/modules/highgui/include
# /Users/meganfinch/opencv-4.5.3/modules/flann/include
# /Users/meganfinch/opencv-4.5.3/modules/imgcodecs/include
# /Users/meganfinch/opencv-4.5.3/modules/imgproc/include
# /Users/meganfinch/opencv-4.5.3/modules/videoio/include
# /Users/meganfinch/ceres-solver/include
# /Users/meganfinch/ceres-solver/cmake-build-release/config
# /Users/meganfinch/eigen
# /Users/meganfinch/glog/cmake-build-release
# /Users/meganfinch/glog/src
# /Users/meganfinch/gflags/cmake-build-release/include
# )
#
# # Where linker should search for libraries
# target_link_directories(
# SFMLib
# PUBLIC
# "${CMAKE_SOURCE_DIR}"
# "/Users/meganfinch/opencv-4.5.3/cmake-build-release/lib"
# #"/Users/meganfinch/ceres-solver/cmake-build-release/lib"
# #"/Users/meganfinch/gflags/cmake-build-release/lib"
# #"/Users/meganfinch/glog/cmake-build-release/"
# )
#
#
# target_link_libraries(
# SFMLib
# Threads::Threads
# opencv_calib3d
# opencv_core
# opencv_dnn
# opencv_features2d
# opencv_flann
# opencv_gapi
# opencv_highgui
# opencv_imgcodecs
# opencv_imgproc
# opencv_ml
# opencv_objdetect
# opencv_photo
# opencv_stitching
# opencv_videoio
# opencv_video
# ceres
# #gflags
# #glog
# #Pickle
# )
#
# set_target_properties(SFMLib PROPERTIES VERSION ${PROJECT_VERSION})