CMakeLists.txt 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. # # compile flags
  14. # set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -O2")
  15. # set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -g")
  16. # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_REENTRANT -fPIC -Wall -Werror")
  17. option(build_kafka "build model kafka" ON)
  18. # ---[ kafka
  19. if(build_kafka)
  20. find_package(LibRDKafka)
  21. if(LIBRDKAFKA_FOUND)
  22. include_directories(${LibRDKafka_INCLUDE_DIR})
  23. list(APPEND 3RDPARTY_LIBS ${LibRDKafka_C_LIBRARIES})
  24. message(STATUS "LibRDKafka include: ${LibRDKafka_INCLUDE_DIR}")
  25. message(STATUS "LibRDKafka libraries: ${LibRDKafka_C_LIBRARIES}")
  26. else()
  27. message(FATAL_ERROR "rdkafka not found!")
  28. endif()
  29. endif()
  30. set(CMAKE_MODULE_PATH ${CNSTREAM_ROOT_DIR}/cmake/sanitizers ${CNSTREAM_ROOT_DIR}/cmake)
  31. # ---[ rapidjson
  32. include_directories(${CNSTREAM_ROOT_DIR}/3rdparty/)
  33. # ---[ modules include dirs
  34. include_directories(${CNSTREAM_ROOT_DIR}/modules/Expel/include)
  35. include_directories(${CNSTREAM_ROOT_DIR}/modules/HttpClient/include)
  36. include_directories(${CNSTREAM_ROOT_DIR}/modules/HttpServer/include)
  37. include_directories(${CNSTREAM_ROOT_DIR}/modules/InfineFilter/include)
  38. include_directories(${CNSTREAM_ROOT_DIR}/modules/Monitor/include)
  39. include_directories(${CNSTREAM_ROOT_DIR}/modules/TCPClient/include)
  40. include_directories(${CNSTREAM_ROOT_DIR}/modules/config/include)
  41. include_directories(${CNSTREAM_ROOT_DIR}/source/UserApp/include)
  42. include_directories(${CNSTREAM_ROOT_DIR}/framework/core/include)
  43. include_directories(${CNSTREAM_ROOT_DIR}/framework/request/include)
  44. include_directories(${CNSTREAM_ROOT_DIR}/plugins/ExpelPlugin/include)
  45. include_directories(${CNSTREAM_ROOT_DIR}/plugins/HttpPlugin/include)
  46. include_directories(${CNSTREAM_ROOT_DIR}/plugins/MonitorPlugin/include)
  47. include_directories(${CNSTREAM_ROOT_DIR}/plugins/TcpPlugin/include)
  48. aux_source_directory(${CNSTREAM_ROOT_DIR}/source/src srcs)
  49. aux_source_directory(${CNSTREAM_ROOT_DIR}/source/UserApp/src userApps)
  50. # ---[ add targets
  51. # set(EXECUTABLE_OUTPUT_PATH ${SOURCE_ROOT_DIR}/bin)
  52. add_executable(gsd ${srcs} ${userApps} ${3RDPARTY_LIBS})
  53. target_link_libraries(gsd gsd_core gsd_modules gsd_plugins pthread dl)