CMakeLists.txt 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. cmake_minimum_required(VERSION 2.8.7)
  2. include(CheckCXXCompilerFlag)
  3. CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
  4. if(NOT COMPILER_SUPPORTS_CXX11)
  5. message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
  6. endif()
  7. if(USE_libstdcpp)
  8. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
  9. message("-- Warning: forcing libstdc++ (controlled by USE_libstdcpp option in cmake)")
  10. endif()
  11. set(CNSTREAM_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../)
  12. set(TEST_ROOT_DIR ${CNSTREAM_ROOT_DIR}/test)
  13. message(STATUS "SOURCE: CNSTREAM_ROOT_DIR = ${CNSTREAM_ROOT_DIR}")
  14. message(STATUS "SOURCE: TEST_ROOT_DIR = ${TEST_ROOT_DIR}")
  15. # # compile flags
  16. # set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -O2")
  17. # set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -g")
  18. # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_REENTRANT -fPIC -Wall -Werror")
  19. option(build_kafka "build model kafka" ON)
  20. # ---[ 3rdparty
  21. set(3RDPARTY_LIBS "")
  22. # ---[ kafka
  23. if(build_kafka)
  24. find_package(RDKafka REQUIRED)
  25. include_directories(${RDKAFKA_INCLUDE_DIR})
  26. list(APPEND 3RDPARTY_LIBS ${RDKAFKA_LIBRARIES})
  27. #link_directories(${RDKAFKA_LINK_DIR})
  28. message(STATUS "Test: RDKafka include: ${RDKAFKA_INCLUDE_DIR}")
  29. message(STATUS "Test: RDKafka libraries: ${RDKAFKA_LIBRARIES}")
  30. endif()
  31. set(ENABLE_MYSQL ON CACHE BOOL "enable mysql")
  32. #查找mysql是否安装
  33. find_package(MYSQL QUIET)
  34. if(MYSQL_FOUND AND ENABLE_MYSQL)
  35. message(STATUS "找到mysqlclient库:\"${MYSQL_INCLUDE_DIR}\",ENABLE_MYSQL宏已打开")
  36. include_directories(${MYSQL_INCLUDE_DIR})
  37. include_directories(${MYSQL_INCLUDE_DIR}/mysql)
  38. add_definitions(-DENABLE_MYSQL)
  39. list(APPEND 3RDPARTY_LIBS ${MYSQL_LIBRARIES})
  40. endif()
  41. set(CMAKE_MODULE_PATH ${CNSTREAM_ROOT_DIR}/cmake/sanitizers ${CNSTREAM_ROOT_DIR}/cmake)
  42. # ---[ ZLToolKit
  43. find_package(ZLToolKit REQUIRED)
  44. #link_directories(${ZLTOOLKIT_LINK_DIR})
  45. include_directories(${ZLTOOLKIT_INCLUDE_DIR})
  46. list(APPEND 3RDPARTY_LIBS ${ZLTOOLKIT_LIBRARIES})
  47. message(STATUS "Test: ZLToolKit include: ${ZLTOOLKIT_INCLUDE_DIR}")
  48. message(STATUS "Test: ZLToolKit libraries: ${ZLTOOLKIT_LIBRARIES}")
  49. # ---[ rapidjson
  50. include_directories(${CNSTREAM_ROOT_DIR}/3rdparty/)
  51. # ---[ httplib
  52. include_directories(${CNSTREAM_ROOT_DIR}/3rdparty/httplib/)
  53. # ---[ modules include dirs
  54. # include_directories(${CNSTREAM_ROOT_DIR}/modules/Expel/include)
  55. # include_directories(${CNSTREAM_ROOT_DIR}/modules/HttpClient/include)
  56. # include_directories(${CNSTREAM_ROOT_DIR}/modules/HttpServer/include)
  57. # include_directories(${CNSTREAM_ROOT_DIR}/modules/InfineFilter/include)
  58. # include_directories(${CNSTREAM_ROOT_DIR}/modules/Monitor/include)
  59. # include_directories(${CNSTREAM_ROOT_DIR}/modules/TCPClient/include)
  60. # include_directories(${CNSTREAM_ROOT_DIR}/modules/config/include)
  61. include_directories(${CNSTREAM_ROOT_DIR}/modules/Hepu/include)
  62. include_directories(${CNSTREAM_ROOT_DIR}/test/TestApp/include)
  63. include_directories(${CNSTREAM_ROOT_DIR}/framework/core/include)
  64. include_directories(${CNSTREAM_ROOT_DIR}/framework/request/include)
  65. # include_directories(${CNSTREAM_ROOT_DIR}/plugins/ExpelPlugin/include)
  66. # include_directories(${CNSTREAM_ROOT_DIR}/plugins/HttpPlugin/include)
  67. # include_directories(${CNSTREAM_ROOT_DIR}/plugins/MonitorPlugin/include)
  68. # include_directories(${CNSTREAM_ROOT_DIR}/plugins/TcpPlugin/include)
  69. # include_directories(${CNSTREAM_ROOT_DIR}/plugins/AuditPlugin/include)
  70. include_directories(${CNSTREAM_ROOT_DIR}/plugins/HepuPlugin/include)
  71. aux_source_directory(${CNSTREAM_ROOT_DIR}/test/src tests)
  72. aux_source_directory(${CNSTREAM_ROOT_DIR}/test/TestApp/src testApps)
  73. # ---[ add targets
  74. set(EXECUTABLE_OUTPUT_PATH ${TEST_ROOT_DIR}/bin)
  75. #add_executable(gsd ${srcs} ${userApps} ${3RDPARTY_LIBS})
  76. #target_link_libraries(gsd gsd_core gsd_modules gsd_plugins ${3RDPARTY_LIBS} pthread dl)
  77. add_executable(hepu_test ${tests} ${testApps} ${3RDPARTY_LIBS})
  78. target_link_libraries(hepu_test gsd_core gsd_modules gsd_plugins ${3RDPARTY_LIBS} pthread dl)