CMakeLists.txt 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. # ---[ cnis project
  9. project(cnis CXX)
  10. #######################################################################
  11. # -- Build Flags
  12. option(CNIS_RECORD_PERF "Enable record performance" ON)
  13. option(CNIS_WITH_CONTRIB "Build contrib content" ON)
  14. option(CNIS_WITH_CURL "Build infer server with curl" ON)
  15. option(CNIS_USE_MAGICMIND "Build infer server with magicmind" OFF)
  16. #######################################################################
  17. set(CNIS_VERSION_MAJOR 1)
  18. set(CNIS_VERSION_MINOR 0)
  19. set(CNIS_VERSION_PATCH 0)
  20. set(CNIS_VERSION "${CNIS_VERSION_MAJOR}.${CNIS_VERSION_MINOR}.${CNIS_VERSION_PATCH}")
  21. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
  22. ${CMAKE_CURRENT_SOURCE_DIR}/include/cnis/config.h)
  23. find_package(MLU)
  24. # set runtime path
  25. set(CMAKE_BUILD_RPATH "$ORIGIN;${NEUWARE_HOME}/lib64;")
  26. # ---[ Google-glog
  27. find_package(Glog)
  28. find_package(Gflags)
  29. if (CNIS_WITH_CONTRIB)
  30. file(GLOB_RECURSE contrib_srcs ${CMAKE_CURRENT_SOURCE_DIR}/src/contrib/*.cpp)
  31. endif()
  32. file(GLOB_RECURSE infer_server_srcs ${CMAKE_CURRENT_SOURCE_DIR}/src/core/*.cpp
  33. ${CMAKE_CURRENT_SOURCE_DIR}/src/model/*.cpp
  34. ${CMAKE_CURRENT_SOURCE_DIR}/src/processor/*.cpp
  35. ${CMAKE_CURRENT_SOURCE_DIR}/src/util/*.cpp)
  36. message(STATUS "@@@@@@@@@@@ Target : cnis")
  37. add_library(cnis SHARED ${infer_server_srcs} ${contrib_srcs})
  38. if (CNIS_WITH_CURL)
  39. find_package(CURL REQUIRED)
  40. target_compile_definitions(cnis PRIVATE CNIS_HAVE_CURL)
  41. target_include_directories(cnis PRIVATE ${CURL_INCLUDE_DIR})
  42. target_link_libraries(cnis PUBLIC ${CURL_LIBRARIES})
  43. endif()
  44. if (CNIS_USE_MAGICMIND)
  45. target_link_libraries(cnis PUBLIC ${MAGICMIND_RUNTIME_LIBS})
  46. endif()
  47. if (CNIS_RECORD_PERF)
  48. target_compile_definitions(cnis PRIVATE CNIS_RECORD_PERF)
  49. endif()
  50. # ---[ cncv
  51. if (CNIS_WITH_CONTRIB AND CNCV_LIBS)
  52. target_compile_definitions(cnis PRIVATE CNIS_HAVE_CNCV)
  53. target_link_libraries(cnis PUBLIC ${CNCV_LIBS})
  54. endif()
  55. target_include_directories(cnis PRIVATE
  56. ${NEUWARE_INCLUDE_DIR}
  57. ${CMAKE_CURRENT_SOURCE_DIR}/../include
  58. ${CMAKE_CURRENT_SOURCE_DIR}/include
  59. ${CMAKE_CURRENT_SOURCE_DIR}/src
  60. ${GLOG_INCLUDE_DIRS}
  61. ${GFLAGS_INCLUDE_DIRS})
  62. target_link_libraries(cnis PUBLIC ${CNDRV_LIBS} ${CNRT_LIBS} ${GLOG_LIBRARIES} ${GFLAGS_LIBRARIES} easydk)
  63. set_target_properties(cnis PROPERTIES VERSION ${CNIS_VERSION})
  64. set_target_properties(cnis PROPERTIES SOVERSION ${CNIS_VERSION_MAJOR})
  65. if(BUILD_TESTS)
  66. add_subdirectory(tests)
  67. endif()
  68. if(BUILD_SAMPLES)
  69. add_subdirectory(samples)
  70. endif()
  71. if (CNIS_WITH_CONTRIB)
  72. install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/cnis
  73. DESTINATION include)
  74. else()
  75. install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/cnis
  76. DESTINATION include
  77. PATTERN "contrib" EXCLUDE)
  78. endif()
  79. install(TARGETS cnis LIBRARY DESTINATION lib)