-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
232 lines (211 loc) · 8.34 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
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
#-------------------------------------------------------------------------------
# Set basic configurations
#-------------------------------------------------------------------------------
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(GwSetBuildType) # Set the build type before project is created
set(SDK_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(SDK_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(SDK_BINARY_DIR ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${SDK_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${SDK_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${SDK_BINARY_DIR}/lib)
message(STATUS "SDK_SOURCE_DIR is: " ${SDK_SOURCE_DIR})
message(STATUS "SDK_BINARY_DIR is: " ${SDK_BINARY_DIR})
message(STATUS "CMAKE_RUNTIME_OUTPUT_DIRECTORY is: " ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
message(STATUS "CMAKE_LIBRARY_OUTPUT_DIRECTORY is: " ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
message(STATUS "CMAKE_ARCHIVE_OUTPUT_DIRECTORY is: " ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
#-------------------------------------------------------------------------------
# Root project
#-------------------------------------------------------------------------------
project(gw_demo C CXX)
#-------------------------------------------------------------------------------
# CUDA host compiler must be set before CUDA is enabled as a language
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Set CUDA_DIR
#-------------------------------------------------------------------------------
# if (DEFINED CUDA_DIR)
# if((DEFINED CUDA_TOOLKIT_ROOT_DIR) AND (NOT CUDA_TOOLKIT_ROOT_DIR STREQUAL CUDA_DIR))
# message(FATAL_ERROR "Cannot set both CUDA_DIR and (legacy) CUDA_TOOLKIT_ROOT_DIR")
# endif()
# elseif (DEFINED CUDA_TOOLKIT_ROOT_DIR)
# message(WARNING "Please set CUDA_DIR instead of (legacy) CUDA_TOOLKIT_ROOT_DIR")
# set(CUDA_DIR ${CUDA_TOOLKIT_ROOT_DIR} CACHE PATH "CUDA Toolkit location.")
# else()
# set(CUDA_DIR "/usr/local/cuda/" CACHE PATH "CUDA Toolkit location.")
# endif()
# if(NOT CMAKE_CUDA_COMPILER)
# set(CMAKE_CUDA_COMPILER "${CUDA_DIR}/bin/nvcc")
# endif()
# set(CMAKE_CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER})
# enable_language(CUDA)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CUDA_STANDARD 11)
set(CMAKE_C_STANDARD 99)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
#-------------------------------------------------------------------------------
# System packages
#-------------------------------------------------------------------------------
find_package(EGL)
find_package(Threads REQUIRED)
# 暂不启用单元测试
# find_package(GTest)
#-------------------------------------------------------------------------------
# Basic configuration
#-------------------------------------------------------------------------------
include(ArchConfiguration)
include(GwConfiguration)
include(ResourcesConfiguration)
include(Gw3rdparty)
include(GwInstallConfiguration)
include(GwPackageConfiguration)
include(UploadVibrante)
include(MakeCUDASourceLibs)
if(GTest_FOUND)
# Don't enable testing until after building dependencies
enable_testing()
# in vscode using CTest as a test client
include(CTest)
include(GWTest)
endif()
#-------------------------------------------------------------------------------
# CUDA dependency
# Note: needs to be after defining all configurations
#-------------------------------------------------------------------------------
find_package(CUDA)
if(VIBRANTE)
list(APPEND CUDA_NVCC_FLAGS -lineinfo --gpu-architecture=compute_53)
list(APPEND CUDA_NVCC_FLAGS --gpu-code=sm_60,sm_62,sm_72,compute_53)
else()
list(APPEND CUDA_NVCC_FLAGS -lineinfo --gpu-architecture=compute_53)
if(NOT CUDA_HOST_GPU_CODE_FLAGS)
list(APPEND CUDA_NVCC_FLAGS --gpu-code=compute_53)
else()
# Compile for local host arch only
list(APPEND CUDA_NVCC_FLAGS ${CUDA_HOST_GPU_CODE_FLAGS})
endif()
endif()
set(CUDA_NON_PROPAGATED_HOST_FLAGS "-Wold-style-cast") # disable certain CUDA flags to be not propagated
list(APPEND CUDA_NVCC_FLAGS -std=c++11)
include_directories(SYSTEM ${CUDA_TOOLKIT_INCLUDE})
if(NOT CMAKE_CUDA_COMPILER)
set(CMAKE_CUDA_COMPILER "${CUDA_TOOLKIT_ROOT_DIR}/bin/nvcc")
endif()
set(CMAKE_CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER})
enable_language(CUDA)
#-------------------------------------------------------------------------------
# DriveWorks SDK
#-------------------------------------------------------------------------------
set(DW_ROOT /usr/local/driveworks)
find_package(CUDART MODULE REQUIRED)
find_package(cuBLAS MODULE REQUIRED)
find_package(driveworks REQUIRED CONFIG HINTS ${DW_ROOT}/cmake)
find_package(driveworks-visualization REQUIRED CONFIG HINTS ${DW_ROOT}/cmake)
find_package(driveworks-shared REQUIRED CONFIG HINTS ${DW_ROOT}/cmake)
find_package(dwdynamicmemory REQUIRED CONFIG HINTS ${DW_ROOT}/cmake)
set(Driveworks_LIBRARIES
CUDART::CUDART
cuBLAS::cuBLAS
driveworks
driveworks-shared
driveworks-visualization
${CUDA_CUDA_LIBRARY}
)
find_package(SSM REQUIRED)
if(SSM_FOUND)
list(APPEND Driveworks_LIBRARIES SSM::FRAMEWORK)
endif()
if(VIBRANTE)
list(APPEND Driveworks_LIBRARIES ${vibrante_LIBRARIES} ${vibrante_Xlibs_LIBRARIES})
find_package(cuDLA MODULE)
if(cuDLA_FOUND)
list(APPEND Driveworks_LIBRARIES cuDLA::cuDLA)
endif()
find_package(cuPVA MODULE)
if(cuPVA_FOUND)
list(APPEND Driveworks_LIBRARIES cuPVA::cuPVA)
endif()
find_package(NvMedia MODULE)
if(NvMedia_FOUND)
include_directories(${NvMedia_INCLUDE_DIR})
list(APPEND Driveworks_LIBRARIES NvMedia::NvMedia)
else()
message(STATUS "Skipping nvmedia settings.")
endif()
endif()
if (VIBRANTE OR DW_EXPERIMENTAL_FORCE_EGL)
list(APPEND Driveworks_LIBRARIES ${EGL_LIBRARIES})
endif()
#-------------------------------------------------------------------------------
# component based platform api
#-------------------------------------------------------------------------------
set(COMPONENTS
camera;
)
foreach(COMPONENT ${COMPONENTS})
if(EXISTS frameworks/${COMPONENT})
add_subdirectory(frameworks/${COMPONENT})
else()
message(WARNING "zs: Component ${COMPONENT} not exist, skipping!")
endif()
endforeach()
#-------------------------------------------------------------------------------
# module based cgf-node
# 出库:先编译channel,再编译算法,再编译node
#-------------------------------------------------------------------------------
set(MODULES
common/cgf_channel;
# demo_team
team_demo/module_demo;
team_demo/team_node;
# engineering_team
xplatform/xplatform_node;
xplatform/xplatform_ssm;
# perception_team
perception/perception_node;
)
foreach(MODULE ${MODULES})
if(EXISTS modules/${MODULE})
add_subdirectory(modules/${MODULE})
else()
message(WARNING "zs: Module ${MODULE} not exist, skipping!")
endif()
endforeach()
# 集成
add_subdirectory(modules/common/cgf_app)
# Create a symlink '_data' to '<DW-install>/data' in the build folder's root, so that `DataPath`
# can lookup the required path independent of the build folder's location relative to the
# repository's root
if(NOT EXISTS "${DW_ROOT}/data/DATA_ROOT")
message(WARNING "Expected data root '${DW_ROOT}/data/DATA_ROOT' not available, "
"likely because DW sample code was moved from install location or installation is incomplete. "
"Samples will likely not run correctly")
endif()
message(STATUS "zs: LINUX is: ${LINUX}")
message(STATUS "zs: VIBRANTE is: ${VIBRANTE}")
message(STATUS "zs: Driveworks_LIBRARIES is: ${Driveworks_LIBRARIES}")
set(GW_ORIN_SH ${CMAKE_CURRENT_SOURCE_DIR}/scripts/orin.sh)
set(GW_TMUX_SH ${CMAKE_CURRENT_SOURCE_DIR}/scripts/tmux_into.sh)
install(
DIRECTORY docker
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/target/
USE_SOURCE_PERMISSIONS
PATTERN ".gitkeep" EXCLUDE
)
install(
DIRECTORY res
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/target/
USE_SOURCE_PERMISSIONS
PATTERN ".gitkeep" EXCLUDE
)
install(
DIRECTORY scripts/.vscode
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/target/
USE_SOURCE_PERMISSIONS
PATTERN ".gitkeep" EXCLUDE
)
install(PROGRAMS
${GW_ORIN_SH} ${GW_TMUX_SH}
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/target/
)