cmake,make,make install

image.png

CMakeList

示例:

  1. # cmake最低版本需求
  2. cmake_minimum_required(VERSION 3.5.1)
  3. # 工程名
  4. project(HERORM2021)
  5. # 使其包含c++11特性
  6. set(CMAKE_CXX_STANDARD 11)
  7. # 设置第三方库文件夹位置
  8. set(OPENCV_DIR /usr/local/share/OpenCV)
  9. # 搜索库
  10. find_package(OpenCV REQUIRED)
  11. # 添加源文件
  12. add_executable(${PROJECT_NAME}
  13. src/main.cpp
  14. src/armor_detect/armordetector.cpp
  15. src/armor_detect/armor/armor.cpp
  16. src/armor_detect/classifier/classifier.cpp
  17. src/camera/mvcamera/mvcamera.cpp
  18. src/camera/dhcamera/dhcamera.cpp
  19. src/communication/serialport.cpp
  20. src/communication/cannode.cpp
  21. src/target_solve/anglesolver.cpp
  22. src/target_solve/targetsolver.cpp
  23. src/util/timer/timer.cpp
  24. src/util/debugger/debugger.cpp
  25. src/util/util.cpp
  26. src/energy/energy.cpp
  27. src/workspace.cpp)
  28. # 添加头文件目录
  29. include_directories(
  30. ./src/
  31. ./src/armor_detect
  32. ./src/armor_detect/armor
  33. ./src/armor_detect/classifier
  34. ./src/armor_detect/classifier/darknet/include
  35. ./src/camera/
  36. ./src/camera/dhcamera
  37. ./src/camera/mvcamera
  38. ./src/communication
  39. ./src/target_solve
  40. ./src/util
  41. ./src/util/timer
  42. ./src/util/debugger
  43. ./src/energy
  44. ${OpenCV_INCLUDE_DIRS})
  45. # 添加需要链接的库文件目录
  46. link_directories(./src/armor_detect/classifier/darknet/)
  47. # 添加链接库
  48. target_link_libraries(${PROJECT_NAME}
  49. ${OpenCV_LIBRARIES}
  50. libdarknet.so
  51. -pthread
  52. -lMVSDK
  53. -lgxiapi
  54. -fopenmp
  55. /lib/libMVSDK.so)

多级CMakelist

makefile