-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
135 lines (100 loc) · 4.36 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
cmake_minimum_required(VERSION 3.16)
project(Aurora_Remote_SDK_Demo)
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release)
ENDIF()
MESSAGE("Build type: " ${CMAKE_BUILD_TYPE})
# Check C++14 support
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
if(COMPILER_SUPPORTS_CXX14)
else()
if (NOT WIN32)
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support. Please use a different C++ compiler.")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++14")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
endif()
endif()
option(ENABLE_DEMOS_WITH_OPENCV "Build Demo with OpenCV" ON)
if(ENABLE_DEMOS_WITH_OPENCV)
find_package(OpenCV 4.2 QUIET)
if(OpenCV_FOUND)
MESSAGE("OPENCV VERSION:")
MESSAGE(${OpenCV_VERSION})
else()
MESSAGE(WARNING "OpenCV > 4.2 not found. Demos that use OpenCV will not be compiled.")
set(ENABLE_DEMOS_WITH_OPENCV OFF)
endif()
else()
MESSAGE("OpenCV support is disabled.")
endif()
# Determine platform and architecture
if(WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(AURORA_LIB_PATH "${PROJECT_SOURCE_DIR}/aurora_remote_public/lib/win64")
else()
message(FATAL_ERROR "Unsupported architecture for Windows. Only x64 is supported.")
endif()
elseif(UNIX AND NOT APPLE)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
set(AURORA_LIB_PATH "${PROJECT_SOURCE_DIR}/aurora_remote_public/lib/linux_aarch64")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
set(AURORA_LIB_PATH "${PROJECT_SOURCE_DIR}/aurora_remote_public/lib/linux_x86_64")
else()
message(FATAL_ERROR "Unsupported architecture for Linux. Only aarch64 and x86_64 are supported.")
endif()
else()
message(FATAL_ERROR "Unsupported platform. Only Windows and Linux are supported.")
endif()
# Set the library name
set(AURORA_LIB_NAME slamtec_aurora_remote_sdk)
# Add the determined library path to the linker search path
include_directories(${PROJECT_SOURCE_DIR}/aurora_remote_public/include)
link_directories(${AURORA_LIB_PATH})
message(STATUS "Aurora SDK library path: ${AURORA_LIB_PATH}")
# Build Demos
## simple_pose
add_executable(simple_pose demo/simple_pose/src/simple_pose.cpp)
target_link_libraries(simple_pose ${AURORA_LIB_NAME})
# copy the .so or .dll with ${AURORA_LIB_NAME} to the build directory
add_custom_command(TARGET simple_pose POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${AURORA_LIB_PATH}
$<TARGET_FILE_DIR:simple_pose>)
## relocalization
add_executable(relocalization demo/relocalization/src/relocalization.cpp)
target_link_libraries(relocalization ${AURORA_LIB_NAME})
# copy the .so or .dll with ${AURORA_LIB_NAME} to the build directory
add_custom_command(TARGET relocalization POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${AURORA_LIB_PATH}
$<TARGET_FILE_DIR:relocalization>)
## pure_c_demo
add_executable(pure_c_demo demo/pure_c_demo/src/pure_c_demo.c)
target_link_libraries(pure_c_demo ${AURORA_LIB_NAME})
## imu_fetcher
add_executable(imu_fetcher demo/imu_fetcher/src/imu_fetcher.cpp)
target_link_libraries(imu_fetcher ${AURORA_LIB_NAME})
## vslam_map_saveload
add_executable(vslam_map_saveload demo/vslam_map_saveload/src/vslam_map_saveload.cpp)
target_link_libraries(vslam_map_saveload ${AURORA_LIB_NAME})
## frame preview, only enabled when ENABLE_DEMOS_WITH_OPENCV is ON
if(ENABLE_DEMOS_WITH_OPENCV)
## frame preview
add_executable(frame_preview demo/frame_preview/src/frame_preview.cpp)
target_include_directories(frame_preview PRIVATE ${OpenCV_INCLUDE_DIRS})
target_link_libraries(frame_preview ${AURORA_LIB_NAME} ${OpenCV_LIBS})
## map render
add_executable(map_render demo/map_render/src/map_render.cpp)
target_include_directories(map_render PRIVATE ${OpenCV_INCLUDE_DIRS})
target_link_libraries(map_render ${AURORA_LIB_NAME} ${OpenCV_LIBS})
## lidar scan plot
add_executable(lidar_scan_plot demo/lidar_scan_plot/src/lidar_scan_plot.cpp)
target_include_directories(lidar_scan_plot PRIVATE ${OpenCV_INCLUDE_DIRS})
target_link_libraries(lidar_scan_plot ${AURORA_LIB_NAME} ${OpenCV_LIBS})
## lidar 2d map render
add_executable(lidar_2dmap_render demo/lidar_2dmap_render/src/lidar_2dmap_render.cpp)
target_include_directories(lidar_2dmap_render PRIVATE ${OpenCV_INCLUDE_DIRS})
target_link_libraries(lidar_2dmap_render ${AURORA_LIB_NAME} ${OpenCV_LIBS})
endif()