|
| 1 | + |
| 2 | +cmake_minimum_required(VERSION 2.8) |
| 3 | +project(sysDetectSpeed) |
| 4 | + |
| 5 | +# setup tensorRT flags |
| 6 | +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # -std=gnu++11 |
| 7 | +set(BUILD_DEPS "YES" CACHE BOOL "If YES, will install dependencies into sandbox. Automatically reset to NO after dependencies are installed.") |
| 8 | + |
| 9 | +# if this is the first time running cmake, perform pre-build dependency install script (or if the user manually triggers re-building the dependencies) |
| 10 | +#if( ${BUILD_DEPS} ) |
| 11 | +# message("Launching pre-build dependency installer script...") |
| 12 | +# |
| 13 | +# execute_process(COMMAND sh ../CMakePreBuild.sh |
| 14 | +# WORKING_DIRECTORY ${PROJECT_BINARY_DIR} |
| 15 | +# RESULT_VARIABLE PREBUILD_SCRIPT_RESULT) |
| 16 | + |
| 17 | +# set(BUILD_DEPS "NO" CACHE BOOL "If YES, will install dependencies into sandbox. #Automatically reset to NO after dependencies are installed." FORCE) |
| 18 | +# message("Finished installing dependencies") |
| 19 | +#endif() |
| 20 | + |
| 21 | + |
| 22 | +# Qt is used to load images (installed by ubuntu-desktop) |
| 23 | +find_package(Qt4 REQUIRED) |
| 24 | +include(${QT_USE_FILE}) |
| 25 | +add_definitions(${QT_DEFINITIONS}) |
| 26 | + |
| 27 | + |
| 28 | +# setup CUDA |
| 29 | +find_package(CUDA) |
| 30 | + |
| 31 | +set( |
| 32 | + CUDA_NVCC_FLAGS |
| 33 | + ${CUDA_NVCC_FLAGS}; |
| 34 | + -O3 |
| 35 | + -gencode arch=compute_53,code=sm_53 |
| 36 | + -gencode arch=compute_62,code=sm_62 |
| 37 | +) |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +# setup project output paths |
| 42 | +set(PROJECT_OUTPUT_DIR ${PROJECT_BINARY_DIR}/${CMAKE_SYSTEM_PROCESSOR}) |
| 43 | +set(PROJECT_INCLUDE_DIR ${PROJECT_OUTPUT_DIR}/include) |
| 44 | + |
| 45 | +file(MAKE_DIRECTORY ${PROJECT_INCLUDE_DIR}) |
| 46 | +file(MAKE_DIRECTORY ${PROJECT_OUTPUT_DIR}/bin) |
| 47 | + |
| 48 | +message("-- system arch: ${CMAKE_SYSTEM_PROCESSOR}") |
| 49 | +message("-- output path: ${PROJECT_OUTPUT_DIR}") |
| 50 | + |
| 51 | +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_OUTPUT_DIR}/bin) |
| 52 | +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_OUTPUT_DIR}/lib) |
| 53 | +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_OUTPUT_DIR}/lib) |
| 54 | + |
| 55 | + |
| 56 | +# build C/C++ interface |
| 57 | +include_directories(${PROJECT_INCLUDE_DIR} ${GIE_PATH}/include) |
| 58 | +include_directories(/usr/include/gstreamer-1.0 /usr/lib/aarch64-linux-gnu/gstreamer-1.0/include /usr/include/glib-2.0 /usr/include/libxml2 /usr/lib/aarch64-linux-gnu/glib-2.0/include/ /usr/local/cuda-9.0/extras/CUPTI/include) |
| 59 | +include_directories(${PROJECT_INCLUDE_DIR} |
| 60 | + /home/nvidia/caffe/include |
| 61 | + /home/nvidia/caffe/build/include |
| 62 | + /usr/local/include |
| 63 | + /usr/local/cuda/include |
| 64 | + /usr/include |
| 65 | +) |
| 66 | + |
| 67 | + |
| 68 | +file(GLOB inferenceSources *.cpp *.cu ) |
| 69 | +file(GLOB inferenceIncludes *.h ) |
| 70 | + |
| 71 | +cuda_add_library(sysDetectSpeed SHARED ${inferenceSources}) |
| 72 | +target_link_libraries(sysDetectSpeed nvcaffe_parser nvinfer Qt4::QtGui GL gstreamer-1.0 gstapp-1.0) #GLEW # gstreamer-0.10 gstbase-0.10 gstapp-0.10 |
| 73 | +target_link_libraries(sysDetectSpeed |
| 74 | + /home/nvidia/caffe/build/lib/libcaffe.so |
| 75 | + /usr/lib/aarch64-linux-gnu/libglog.so |
| 76 | + /usr/lib/aarch64-linux-gnu/libgflags.so.2 |
| 77 | + /usr/lib/aarch64-linux-gnu/libboost_system.so |
| 78 | + /usr/lib/aarch64-linux-gnu/libGLEW.so.1.13 |
| 79 | +) |
| 80 | + |
| 81 | + |
| 82 | +# transfer all headers to the include directory |
| 83 | +foreach(include ${inferenceIncludes}) |
| 84 | + message("-- Copying ${include}") |
| 85 | + configure_file(${include} ${PROJECT_INCLUDE_DIR} COPYONLY) |
| 86 | +endforeach() |
| 87 | + |
| 88 | + |
| 89 | +# create symbolic link for network data |
| 90 | +execute_process( COMMAND "${CMAKE_COMMAND}" "-E" "create_symlink" "${PROJECT_SOURCE_DIR}/data/networks" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/networks" ) |
| 91 | + |
| 92 | + |
| 93 | +# copy image data |
| 94 | +file(GLOB imageData ${PROJECT_SOURCE_DIR}/data/images/*) |
| 95 | + |
| 96 | +foreach(image ${imageData}) |
| 97 | + message("-- Copying ${image}") |
| 98 | + file(COPY ${image} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) |
| 99 | + #configure_file(${include} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COPYONLY) |
| 100 | +endforeach() |
| 101 | + |
| 102 | + |
| 103 | +add_subdirectory(detectnet) |
| 104 | + |
| 105 | + |
| 106 | +#setup opencv |
| 107 | +FIND_PACKAGE(OpenCV REQUIRED) |
| 108 | + |
| 109 | +TARGET_LINK_LIBRARIES(sysDetectSpeed ${OpenCV_LIBS}) |
| 110 | + |
| 111 | +# install |
| 112 | +foreach(include ${inferenceIncludes}) |
| 113 | + install(FILES "${include}" DESTINATION include/sysDetectSpeed) |
| 114 | +endforeach() |
| 115 | + |
| 116 | +# install the shared library |
| 117 | +install(TARGETS sysDetectSpeed DESTINATION lib/sysDetectSpeed EXPORT sysDetectSpeedConfig) |
| 118 | + |
| 119 | +# install the cmake project, for importing |
| 120 | +install(EXPORT sysDetectSpeedConfig DESTINATION share/sysDetectSpeed/cmake) |
| 121 | + |
0 commit comments