CMakeLists.txt 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
  2. # ---[ Google-gflags
  3. find_package(GFlags)
  4. list(APPEND Samples_INCLUDE_DIRS ${GFLAGS_INCLUDE_DIRS})
  5. list(APPEND Samples_LINK_LIBS ${GFLAGS_LIBRARIES})
  6. # ---[ OpenCV
  7. set(OpenCV_FIND_QUIETLY true)
  8. find_package(OpenCV OPTIONAL_COMPONENTS imgcodecs)
  9. set(imgcodecs_libs ${OpenCV_LIBS})
  10. find_package(OpenCV REQUIRED core imgproc highgui features2d)
  11. if (OpenCV_FOUND)
  12. message(STATUS "OpenCV Found")
  13. else (OpenCV_FOUND)
  14. message(FATAL_ERROR "Can not find OpenCV libs!")
  15. endif ()
  16. if (imgcodecs_FOUND)
  17. list(APPEND OpenCV_LIBS ${imgcodecs_libs})
  18. endif ()
  19. list(APPEND Samples_INCLUDE_DIRS ${OpenCV_INCLUDE_DIRS})
  20. list(APPEND Samples_LINK_LIBS ${OpenCV_LIBS})
  21. # ---[ FFmpeg
  22. find_package(FFmpeg REQUIRED)
  23. if (FFMPEG_FOUND)
  24. message(STATUS "FFmpeg Found, include: ${FFMPEG_INCLUDE_DIR}")
  25. message(STATUS "FFmpeg Found, libraries: ${FFMPEG_LIBRARIES}")
  26. else (FFMPEG_FOUND)
  27. message(FATAL_ERROR "Can not find FFmpeg libs!")
  28. endif (FFMPEG_FOUND)
  29. list(APPEND Samples_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIR})
  30. list(APPEND Samples_LINK_LIBS ${FFMPEG_LIBRARIES})
  31. # ---[ thread
  32. list(APPEND Samples_LINK_LIBS pthread dl)
  33. # workaround for gcc known issue
  34. if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
  35. set(COMPILE_FLAGS -Wno-uninitialized)
  36. elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
  37. set(COMPILE_FLAGS -Wno-maybe-uninitialized)
  38. else()
  39. message(FATAL_ERROR "Unsupported Compiler!")
  40. endif()
  41. set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin/)
  42. aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/common common_srcs)
  43. # ----- stream_app
  44. aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/stream-app stream_app_srcs)
  45. message(STATUS "@@@@@@@@@@@ Target : stream-app")
  46. add_executable(stream-app ${stream_app_srcs} ${common_srcs})
  47. add_sanitizers(stream-app)
  48. target_compile_options(stream-app PRIVATE ${COMPILE_FLAGS})
  49. target_include_directories(stream-app PRIVATE
  50. ${Samples_INCLUDE_DIRS}
  51. ${PROJECT_SOURCE_DIR}/include
  52. ${CMAKE_CURRENT_SOURCE_DIR}/common)
  53. target_link_libraries(stream-app easydk ${Samples_LINK_LIBS})
  54. install(TARGETS stream-app RUNTIME DESTINATION bin)
  55. # ----- classification
  56. aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/classification classification_srcs)
  57. message(STATUS "@@@@@@@@@@@ Target : classification")
  58. add_executable(classification ${classification_srcs} ${common_srcs})
  59. add_sanitizers(classification)
  60. target_compile_options(classification PRIVATE ${COMPILE_FLAGS})
  61. target_include_directories(classification PRIVATE
  62. ${Samples_INCLUDE_DIRS}
  63. ${PROJECT_SOURCE_DIR}/include
  64. ${CMAKE_CURRENT_SOURCE_DIR}/common)
  65. target_link_libraries(classification easydk ${Samples_LINK_LIBS})
  66. install(TARGETS classification RUNTIME DESTINATION bin)