-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
78 lines (66 loc) · 2.1 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
cmake_minimum_required( VERSION 3.5.1 )
# Set project name.
project(solution_camera_pose)
# Set executable name.
set(exe_name solution_camera_pose)
# Make cmake first look for "Find<package>.cmake" functions generated by conan.
list(PREPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
# Export commands for vscode.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Find required libraries.
find_package(OpenCV 4 REQUIRED)
find_package(Sophus REQUIRED)
find_package(GeographicLib QUIET)
# We have to apply a small workaround for finding GeographicLib via conan
if (NOT GeographicLib_FOUND)
find_package(geographiclib REQUIRED)
set(GeographicLib_LIBRARIES "GeographicLib::GeographicLib")
endif()
# We use the "OpenCV_LIBS" variable for backward compatibility with the old lab setup.
if (NOT OpenCV_LIBS)
set(OpenCV_LIBS "opencv::opencv")
endif()
# Add an executable target to the project with the specified source files.
add_executable(${PROJECT_NAME}
main.cpp
attitude.h
attitude.cpp
cartesian_position.h
cartesian_position.cpp
dataset.h
dataset.cpp
geodetic_position.h
geodetic_position.cpp
intrinsics.h
intrinsics.cpp
camera_pose_solution.h
camera_pose_solution.cpp
local_coordinate_system.h
local_coordinate_system.cpp
perspective_camera_model.h
perspective_camera_model.cpp
viewer_3d.h
viewer_3d.cpp
)
# Specify libraries that will be linked with the executable target.
target_link_libraries(${PROJECT_NAME}
${OpenCV_LIBS}
${GeographicLib_LIBRARIES}
Sophus::Sophus
)
# Set properties for the executable target.
set_target_properties(${exe_name} PROPERTIES
CXX_STANDARD_REQUIRED ON
CXX_STANDARD 17
)
# Define two groups of supported compilers.
set(gcc_like_cxx "$<COMPILE_LANG_AND_ID:CXX,ARMClang,AppleClang,Clang,GNU,LCC>")
set(msvc_cxx "$<COMPILE_LANG_AND_ID:CXX,MSVC>")
# Set compiler specific flags and definitions.
target_compile_options(${exe_name} PRIVATE
"$<${gcc_like_cxx}:$<BUILD_INTERFACE:-Wall;-Wextra;-Wpedantic;-Wshadow;-Wformat=2>>"
"$<${msvc_cxx}:$<BUILD_INTERFACE:-W4>>"
)
target_compile_definitions(${exe_name} PUBLIC
"$<${msvc_cxx}:-D_USE_MATH_DEFINES>"
)