CMakeLists.txt 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. cmake_minimum_required(VERSION 2.8.7)
  2. if(POLICY CMP0046)
  3. cmake_policy(SET CMP0046 NEW)
  4. endif()
  5. if(POLICY CMP0054)
  6. cmake_policy(SET CMP0054 NEW)
  7. endif()
  8. set(CNSTREAM_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..)
  9. # compile flags
  10. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -O2")
  11. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -g")
  12. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_REENTRANT -fPIC -Wno-deprecated-declarations -Wall -Werror")
  13. set(CMAKE_MODULE_PATH ${CNSTREAM_ROOT_DIR}/cmake)
  14. # ---[ neuware
  15. find_package(Neuware)
  16. include_directories(${NEUWARE_INCLUDE_DIR})
  17. # ---[ pybind11
  18. set(PYBIND11_PYTHON_VERSION 3.5)
  19. add_subdirectory(${CNSTREAM_ROOT_DIR}/3rdparty/pybind11 ${CMAKE_CURRENT_BINARY_DIR}/pybind11)
  20. # ---[ rapidjson
  21. include_directories(${CNSTREAM_ROOT_DIR}/3rdparty/rapidjson/include)
  22. set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/webserver)
  23. include_directories("${CNSTREAM_ROOT_DIR}/modules")
  24. include_directories("${CNSTREAM_ROOT_DIR}/modules/inference/include")
  25. include_directories("${CNSTREAM_ROOT_DIR}/modules/inference2/include")
  26. include_directories("${CNSTREAM_ROOT_DIR}/modules/osd/include")
  27. include_directories("${CNSTREAM_ROOT_DIR}/modules/source/include")
  28. include_directories("${CNSTREAM_ROOT_DIR}/modules/encode/include")
  29. include_directories("${CNSTREAM_ROOT_DIR}/modules/track/include")
  30. include_directories("${CNSTREAM_ROOT_DIR}/modules/display/include")
  31. include_directories("${CNSTREAM_ROOT_DIR}/modules/rtsp_sink/include")
  32. include_directories("${CNSTREAM_ROOT_DIR}/modules/util/include")
  33. include_directories("${CNSTREAM_ROOT_DIR}/samples/common")
  34. include_directories(${CMAKE_CURRENT_SOURCE_DIR})
  35. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/pycnstream_backend)
  36. aux_source_directory(${CNSTREAM_ROOT_DIR}/samples/common/ util_src)
  37. list(APPEND service_srcs ${util_src})
  38. aux_source_directory(${CNSTREAM_ROOT_DIR}/samples/common/preprocess preprocess_srcs)
  39. list(APPEND service_srcs ${preprocess_srcs})
  40. aux_source_directory(${CNSTREAM_ROOT_DIR}/samples/common/postprocess postprocess_srcs)
  41. list(APPEND service_srcs ${postprocess_srcs})
  42. aux_source_directory(${CNSTREAM_ROOT_DIR}/samples/common/obj_filter obj_filter_srcs)
  43. list(APPEND service_srcs ${obj_filter_srcs})
  44. aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src/pycnstream_backend pyapi_src)
  45. list(APPEND service_srcs ${pyapi_src})
  46. # make python or cpp api
  47. set(make_pythonapi true)
  48. if(make_pythonapi)
  49. set(MAKE_PYTHONAPI true)
  50. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMAKE_PYTHONAPI")
  51. message("target : pycnservice package")
  52. include_directories(${CNSTREAM_ROOT_DIR}/3rdparty/pybind11/include)
  53. include(${CNSTREAM_ROOT_DIR}/cmake/have_cnstream_target.cmake)
  54. have_framework_target(${CNSTREAM_ROOT_DIR})
  55. have_easydk_target(${CNSTREAM_ROOT_DIR})
  56. have_modules_target(${CNSTREAM_ROOT_DIR})
  57. have_modules_contrib_target(${CNSTREAM_ROOT_DIR})
  58. pybind11_add_module(pycnservice SHARED ${service_srcs})
  59. if(HAVE_FRAMEWORK_TARGET)
  60. add_dependencies(pycnservice cnstream_core)
  61. endif()
  62. if(HAVE_EASYDK_TARGET)
  63. add_dependencies(pycnservice easydk cnis)
  64. endif()
  65. if(HAVE_MODULES_TARGET)
  66. add_dependencies(pycnservice cnstream_va)
  67. endif()
  68. if(HAVE_MODULES_CONTRIB_TARGET)
  69. add_dependencies(pycnservice cnstream_contrib)
  70. endif()
  71. target_link_libraries(pycnservice PRIVATE cnstream_va easydk cnis cnstream_core ${OpenCV_LIBS} ${FFMPEG_LIBRARIES} pthread dl)
  72. if(HAVE_MODULES_CONTRIB)
  73. set(CMAKE_EXE_LINKER_FLAGS "-Wl,--no-as-needed")
  74. target_link_libraries(pycnservice PRIVATE cnstream_contrib)
  75. endif()
  76. endif()
  77. # web visualize unitest
  78. set(web_visualize_unitest false)
  79. if(web_visualize_unitest)
  80. add_subdirectory(unitest)
  81. endif()