CMakeLists.txt 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # ---[ gtest
  2. if(NOT build_gtest_already) # set by parent
  3. add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/googletest ${PROJECT_BINARY_DIR}/googletest)
  4. set(build_gtest_already ON)
  5. endif()
  6. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/googletest/googletest/include)
  7. # ---[ gflags
  8. include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/FindGFlags.cmake)
  9. include_directories(${GFLAGS_INCLUDE_DIRS})
  10. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
  11. set(test_srcs "")
  12. list(APPEND test_srcs ${CMAKE_CURRENT_SOURCE_DIR}/test_base.cpp)
  13. list(APPEND test_srcs ${CMAKE_CURRENT_SOURCE_DIR}/test_main.cpp)
  14. list(APPEND test_srcs ${CMAKE_CURRENT_SOURCE_DIR}/test_frame.cpp)
  15. if(build_encode)
  16. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../encode/src)
  17. file(GLOB_RECURSE test_encode_srcs ${CMAKE_CURRENT_SOURCE_DIR}/encode/*.cpp)
  18. list(APPEND test_srcs ${test_encode_srcs})
  19. endif()
  20. if(build_inference)
  21. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../inference/src)
  22. file(GLOB_RECURSE test_infer_srcs ${CMAKE_CURRENT_SOURCE_DIR}/inference/*.cpp)
  23. file(GLOB_RECURSE preproc ${CMAKE_CURRENT_SOURCE_DIR}/../../samples/common/preprocess/*.cpp)
  24. file(GLOB_RECURSE postproc ${CMAKE_CURRENT_SOURCE_DIR}/../../samples/common/postprocess/*.cpp)
  25. list(APPEND test_srcs ${test_infer_srcs} ${preproc} ${postproc})
  26. endif()
  27. if(build_inference2)
  28. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../inference2/src)
  29. file(GLOB_RECURSE test_infer2_srcs ${CMAKE_CURRENT_SOURCE_DIR}/inference2/*.cpp)
  30. file(GLOB_RECURSE preproc_infer2 ${CMAKE_CURRENT_SOURCE_DIR}/../../samples/common/preprocess/*.cpp)
  31. file(GLOB_RECURSE postproc_infer2 ${CMAKE_CURRENT_SOURCE_DIR}/../../samples/common/postprocess/*.cpp)
  32. list(APPEND test_srcs ${test_infer2_srcs} ${preproc_infer2} ${postproc_infer2})
  33. endif()
  34. if(build_osd)
  35. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../osd/src)
  36. file(GLOB_RECURSE test_osd_srcs ${CMAKE_CURRENT_SOURCE_DIR}/osd/*.cpp)
  37. list(APPEND test_srcs ${test_osd_srcs})
  38. endif()
  39. if(build_source)
  40. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../source/src)
  41. file(GLOB_RECURSE test_source_srcs ${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp)
  42. list(APPEND test_srcs ${test_source_srcs})
  43. endif()
  44. if(build_track)
  45. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../track/src)
  46. file(GLOB_RECURSE test_track_srcs ${CMAKE_CURRENT_SOURCE_DIR}/track/*.cpp)
  47. list(APPEND test_srcs ${test_track_srcs})
  48. endif()
  49. if(build_rtsp_sink)
  50. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../rtsp_sink/src)
  51. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../rtsp_sink/src/rtsp_server)
  52. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../encode/src/video)
  53. file(GLOB_RECURSE test_rtsp_sink_srcs ${CMAKE_CURRENT_SOURCE_DIR}/rtsp_sink/*.cpp)
  54. list(APPEND test_srcs ${test_rtsp_sink_srcs})
  55. endif()
  56. if(build_display)
  57. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../display/src)
  58. file(GLOB_RECURSE test_display_srcs ${CMAKE_CURRENT_SOURCE_DIR}/display/*.cpp)
  59. list(APPEND test_srcs ${test_display_srcs})
  60. endif()
  61. add_executable(cnstream_test ${test_srcs})
  62. add_dependencies(cnstream_test cnstream_va gtest)
  63. target_link_libraries(cnstream_test gtest dl cnstream_va pthread rt ${GFLAGS_LIBRARIES})
  64. add_test(cnstream_test ${EXECUTABLE_OUTPUT_PATH}/cnstream_test)