forked from HHgzs/OpenRM-2024
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
184 lines (155 loc) · 3.82 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
cmake_minimum_required(VERSION 3.15)
project(OpenRM)
set(CMAKE_CXX_STANDARD 20)
# set(CMAKE_BUILD_TYPE DEBUG)
# add_compile_options(-g -O0 -w -fno-omit-frame-pointer -Wno-notes)
set(CMAKE_BUILD_TYPE RELEASE)
add_compile_options(-O3 -w)
# OpenCV
find_package(OpenCV 4.5.4 REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
# Eigen
find_package(Eigen3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIR})
# Ceres
find_package(Ceres REQUIRED)
include_directories(${CERES_INCLUDE_DIRS})
# CUDA
find_package(CUDA)
if (CUDA_FOUND)
message(STATUS "CUDA Version: ${CUDA_VERSION}")
include_directories(/usr/local/cuda/include)
endif()
# 设置主版本号、次版本号和补丁版本号
set(OPENRM_VERSION_MAJOR 1)
set(OPENRM_VERSION_MINOR 0)
set(OPENRM_VERSION_PATCH 0)
# 生成完整的版本号
set(OPENRM_VERSION ${OPENRM_VERSION_MAJOR}.${OPENRM_VERSION_MINOR}.${OPENRM_VERSION_PATCH})
# 将宏定义添加到项目
add_definitions(-DOPENRM_VERSION="${OPENRM_VERSION}")
# add_definitions(-DPOINTER_IO)
# 将版本号定义为预定义宏,使其在程序内部可访问
configure_file(
${CMAKE_SOURCE_DIR}/cmake/VersionConfig.h.in
${CMAKE_CURRENT_BINARY_DIR}/VersionConfig.h)
# 添加子目录
add_subdirectory(src/attack)
add_subdirectory(src/kalman)
add_subdirectory(src/pointer)
add_subdirectory(src/solver)
add_subdirectory(src/uniterm)
add_subdirectory(src/utils)
add_subdirectory(src/video)
if (CUDA_FOUND)
add_subdirectory(src/tensorrt)
add_subdirectory(cuda)
endif()
# 添加目标文件
if (CUDA_FOUND)
set(
TARGETS_LIST
openrm_attack
openrm_kalman
openrm_pointer
openrm_solver
openrm_delay
openrm_print
openrm_serial
openrm_tf
openrm_timer
openrm_uniterm
openrm_video
openrm_tensorrt
openrm_cudatools
)
else()
set(
TARGETS_LIST
openrm_attack
openrm_kalman
openrm_pointer
openrm_solver
openrm_delay
openrm_print
openrm_serial
openrm_tf
openrm_timer
openrm_uniterm
openrm_video
)
endif()
# 安装
install(
TARGETS
${TARGETS_LIST}
EXPORT
OpenRMTarget
RUNTIME DESTINATION
bin
LIBRARY DESTINATION
lib
ARCHIVE DESTINATION
lib
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/VersionConfig.h
DESTINATION
include/openrm
)
if (CUDA_FOUND)
install(
FILES
${CMAKE_SOURCE_DIR}/cuda/include/cudatools.h
DESTINATION
include/openrm
)
endif()
install(
DIRECTORY
${CMAKE_SOURCE_DIR}/include/
DESTINATION
include/openrm
)
install(
EXPORT
OpenRMTarget
NAMESPACE
openrm::
DESTINATION
lib/cmake/openrm
)
include(CMakePackageConfigHelpers)
if (CUDA_FOUND)
configure_package_config_file(
${CMAKE_SOURCE_DIR}/cmake/OpenRMConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/OpenRMConfig.cmake
INSTALL_DESTINATION
lib/cmake/openrm
)
else()
configure_package_config_file(
${CMAKE_SOURCE_DIR}/cmake/OpenRMConfig.cmake.in.nocuda
${CMAKE_CURRENT_BINARY_DIR}/OpenRMConfig.cmake
INSTALL_DESTINATION
lib/cmake/openrm
)
endif()
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/OpenRMConfig.cmake
DESTINATION
lib/cmake/openrm
)
# 卸载
if(NOT TARGET uninstall)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY
)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
)
endif()