-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
145 lines (120 loc) · 3.92 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
cmake_minimum_required(VERSION 3.17.5)
# cmake_policy(SET CMP0048 NEW)
# cmake_policy(SET CMP0042 NEW)
project(mmdet_pp)
option(BUILD_SHARED_LIBS "Build as a shared library" ON)
option(USE_DOUBLE "Use double as kernel_type" OFF)
option(TEST "BUILD TEST" ON)
option(BENCH "BUILD BENCH" OFF)
if(USE_DOUBLE)
message("Use double as kernel_type")
endif()
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif ()
############################################################
# add 3th_part library
############################################################
find_package(yaml-cpp REQUIRED)
include_directories(${YAML_CPP_INCLUDE_DIRS})
find_package(Threads)
find_package(OpenMP REQUIRED)
add_definitions("-DELPP_NO_LOG_TO_FILE")
find_package(CUDA REQUIRED QUIET)
include_directories(${CUDA_INCLUDE_DIRS})
if (CUDA_VERSION VERSION_LESS "11.0")
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -std=c++11 -Wno-deprecated-gpu-targets)
else ()
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -std=c++14 -Wno-deprecated-gpu-targets)
endif ()
find_library(NVINFER NAMES nvinfer)
find_library(NVPARSERS NAMES nvparsers)
find_library(NVONNXPARSERS NAMES nvonnxparser)
list(APPEND LINK_LIBRARY
${CUDA_cusparse_LIBRARY}
${NVINFER}
${NVONNXPARSERS}
${CUDA_LIBRARIES}
${CUDA_CUBLAS_LIBRARIES}
${CUDA_curand_LIBRARY}
${CUDA_cusparse_LIBRARY}
yaml-cpp
)
# Correct error for GCC 5 and CUDA 7.5
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DYAML_BUILD_SHARED_LIBS=ON -D_MWAITXINTRIN_H_INCLUDED -D_FORCE_INLINES ")
if (CMAKE_VERSION VERSION_LESS "3.1")
add_compile_options("-std=c++11 -fext-numeric-literals")
else ()
set(CMAKE_CXX_STANDARD 11)
endif ()
set(COMMON_INCLUDES ${CMAKE_CURRENT_BINARY_DIR})
############################################################
# Create a library in subdirectory
############################################################
set(PROJECT_LIB_NAME mmdet_pp_lib)
include_directories(${COMMON_INCLUDES})
add_subdirectory(${PROJECT_SOURCE_DIR}/pointpillars)
message(STATUS " PROJECT_SOURCE_DIR : ${PROJECT_SOURCE_DIR}")
message(STATUS " PROJECT_LIB_NAME : ${PROJECT_LIB_NAME}")
############################################################
# ROS
############################################################
find_package(catkin REQUIRED COMPONENTS
roscpp
roslib
pcl_ros
autoware_msgs
autoware_perception_msgs
)
catkin_package(
CATKIN_DEPENDS
roslib
pcl_ros
autoware_msgs
autoware_perception_msgs
)
include_directories(
include
${catkin_INCLUDE_DIRS}
)
set(SOURCE_FILES
nodes/mmdet_node.cc
nodes/mmdet_ros.cc
)
add_executable(mmdet_pp
${SOURCE_FILES}
)
add_dependencies(mmdet_pp
${catkin_EXPORTED_TARGETS}
)
target_link_libraries(mmdet_pp
${catkin_LIBRARIES}
${PROJECT_LIB_NAME}
)
install(
TARGETS
${PROJECT_LIB_NAME}
mmdet_pp
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
message(STATUS " TEST : ${TEST}")
############################################################
# Create an executable
############################################################
if (TEST)
message("Building tests")
find_package(rostest REQUIRED)
catkin_add_gtest(test-mmdet_pp test/src/pointpillars_test.cc)
target_link_libraries(test-mmdet_pp ${catkin_LIBRARIES} ${PROJECT_LIB_NAME})
endif ()
message(STATUS "")
message(STATUS "BUILD SUMMARY")
message(STATUS " CMAKE_GENERATOR : ${CMAKE_GENERATOR}")
message(STATUS " Compiler ID : ${CMAKE_CXX_COMPILER_ID}")
message(STATUS " Build type : ${CMAKE_BUILD_TYPE}")
message(STATUS " Build shared libs : ${BUILD_SHARED_LIBS}")
message(STATUS " Use double for kernel: ${USE_DOUBLE}")
message(STATUS " Build tests : ${TEST}")
message(STATUS "")