CMakeLists.txt 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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(SOURCE_ROOT_DIR ${CNSTREAM_ROOT_DIR}/source)
  13. #message(STATUS "SOURCE: CNSTREAM_ROOT_DIR = ${CNSTREAM_ROOT_DIR}")
  14. #message(STATUS "SOURCE: SOURCE_ROOT_DIR = ${SOURCE_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. # ---[ kafka
  21. if(build_kafka)
  22. find_package(LibRDKafka)
  23. if(LIBRDKAFKA_FOUND)
  24. include_directories(${LibRDKafka_INCLUDE_DIR})
  25. list(APPEND 3RDPARTY_LIBS ${LibRDKafka_C_LIBRARIES})
  26. message(STATUS "LibRDKafka include: ${LibRDKafka_INCLUDE_DIR}")
  27. message(STATUS "LibRDKafka libraries: ${LibRDKafka_C_LIBRARIES}")
  28. else()
  29. message(FATAL_ERROR "rdkafka not found!")
  30. endif()
  31. endif()
  32. set(ENABLE_MYSQL ON CACHE BOOL "enable mysql")
  33. #查找mysql是否安装
  34. find_package(MYSQL QUIET)
  35. if(MYSQL_FOUND AND ENABLE_MYSQL)
  36. message(STATUS "找到mysqlclient库:\"${MYSQL_INCLUDE_DIR}\",ENABLE_MYSQL宏已打开")
  37. include_directories(${MYSQL_INCLUDE_DIR})
  38. include_directories(${MYSQL_INCLUDE_DIR}/mysql)
  39. add_definitions(-DENABLE_MYSQL)
  40. list(APPEND 3RDPARTY_LIBS ${MYSQL_LIBRARIES})
  41. endif()
  42. set(CMAKE_MODULE_PATH ${CNSTREAM_ROOT_DIR}/cmake/sanitizers ${CNSTREAM_ROOT_DIR}/cmake)
  43. # ---[ ZLToolKit
  44. find_package(ZLToolKit REQUIRED)
  45. link_directories(${ZLTOOLKIT_LINK_DIRS})
  46. include_directories(${ZLTOOLKIT_INCLUDE_DIRS})
  47. # ---[ rapidjson
  48. include_directories(${CNSTREAM_ROOT_DIR}/3rdparty/)
  49. # ---[ httplib
  50. include_directories(${CNSTREAM_ROOT_DIR}/3rdparty/httplib/)
  51. # ---[ modules include dirs
  52. include_directories(${CNSTREAM_ROOT_DIR}/modules/Expel/include)
  53. include_directories(${CNSTREAM_ROOT_DIR}/modules/HttpClient/include)
  54. include_directories(${CNSTREAM_ROOT_DIR}/modules/HttpServer/include)
  55. include_directories(${CNSTREAM_ROOT_DIR}/modules/InfineFilter/include)
  56. include_directories(${CNSTREAM_ROOT_DIR}/modules/Monitor/include)
  57. include_directories(${CNSTREAM_ROOT_DIR}/modules/TCPClient/include)
  58. include_directories(${CNSTREAM_ROOT_DIR}/modules/config/include)
  59. include_directories(${CNSTREAM_ROOT_DIR}/source/UserApp/include)
  60. include_directories(${CNSTREAM_ROOT_DIR}/framework/core/include)
  61. include_directories(${CNSTREAM_ROOT_DIR}/framework/request/include)
  62. include_directories(${CNSTREAM_ROOT_DIR}/plugins/ExpelPlugin/include)
  63. include_directories(${CNSTREAM_ROOT_DIR}/plugins/HttpPlugin/include)
  64. include_directories(${CNSTREAM_ROOT_DIR}/plugins/MonitorPlugin/include)
  65. include_directories(${CNSTREAM_ROOT_DIR}/plugins/TcpPlugin/include)
  66. include_directories(${CNSTREAM_ROOT_DIR}/plugins/AuditPlugin/include)
  67. aux_source_directory(${CNSTREAM_ROOT_DIR}/source/src srcs)
  68. aux_source_directory(${CNSTREAM_ROOT_DIR}/source/UserApp/src userApps)
  69. # ---[ add targets
  70. # set(EXECUTABLE_OUTPUT_PATH ${SOURCE_ROOT_DIR}/bin)
  71. add_executable(gsd ${srcs} ${userApps} ${3RDPARTY_LIBS})
  72. target_link_libraries(gsd gsd_core gsd_modules gsd_plugins pthread dl)