-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
86 lines (62 loc) · 2.53 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
cmake_minimum_required(VERSION 2.8)
project(sysDetectSpeed)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # -std=gnu++11
# setup CUDA
find_package(CUDA)
set(
CUDA_NVCC_FLAGS
${CUDA_NVCC_FLAGS};
-O3
-gencode arch=compute_53,code=sm_53 #tegra tx1
-gencode arch=compute_61,code=sm_61 #gtx 1060
-gencode arch=compute_62,code=sm_62 #tegra tx2
-gencode arch=compute_75,code=[sm_75,compute_75]
)
# setup project output paths
set(PROJECT_OUTPUT_DIR ${PROJECT_BINARY_DIR}/${CMAKE_SYSTEM_PROCESSOR})
set(PROJECT_INCLUDE_DIR ${PROJECT_OUTPUT_DIR}/include)
file(MAKE_DIRECTORY ${PROJECT_INCLUDE_DIR})
file(MAKE_DIRECTORY ${PROJECT_OUTPUT_DIR}/bin)
message("-- system arch: ${CMAKE_SYSTEM_PROCESSOR}")
message("-- output path: ${PROJECT_OUTPUT_DIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_OUTPUT_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_OUTPUT_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_OUTPUT_DIR}/lib)
# build C/C++ interface
include_directories(${PROJECT_INCLUDE_DIR} ${GIE_PATH}/include)
include_directories(${PROJECT_INCLUDE_DIR}
/home/hs/software/caffe/include
/home/hs/software/caffe/.build_release/src
/usr/include/openblas/
)
file(GLOB inferenceSources *.cpp *.cu )
file(GLOB inferenceIncludes *.h )
cuda_add_library(sysDetectSpeed SHARED ${inferenceSources})
target_link_libraries(sysDetectSpeed
/home/hs/software/caffe/.build_release/lib/libcaffe.so
/usr/lib64/libglog.so
/usr/lib64/libgflags.so
/usr/lib64/libgflags.so.2.1
/usr/lib64/boost/lib/libboost_system.so
/root/anaconda3/envs/venv/lib/libstdc++.so.6
/usr/lib64/libtiff.so
)
# transfer all headers to the include directory
foreach(include ${inferenceIncludes})
message("-- Copying ${include}")
configure_file(${include} ${PROJECT_INCLUDE_DIR} COPYONLY)
endforeach()
# create symbolic link for network data
execute_process( COMMAND "${CMAKE_COMMAND}" "-E" "create_symlink" "${PROJECT_SOURCE_DIR}/data/networks" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/networks" )
add_subdirectory(detectnet)
#setup opencv
FIND_PACKAGE(OpenCV REQUIRED)
TARGET_LINK_LIBRARIES(sysDetectSpeed ${OpenCV_LIBS})
# install
foreach(include ${inferenceIncludes})
install(FILES "${include}" DESTINATION include/sysDetectSpeed)
endforeach()
# install the shared library
install(TARGETS sysDetectSpeed DESTINATION lib/sysDetectSpeed EXPORT sysDetectSpeedConfig)
# install the cmake project, for importing
install(EXPORT sysDetectSpeedConfig DESTINATION share/sysDetectSpeed/cmake)