12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- cmake_minimum_required(VERSION 2.8.7)
- include(CheckCXXCompilerFlag)
- CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
- if(NOT COMPILER_SUPPORTS_CXX11)
- message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
- endif()
- if(USE_libstdcpp)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
- message("-- Warning: forcing libstdc++ (controlled by USE_libstdcpp option in cmake)")
- endif()
- set(CNSTREAM_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../)
- set(SOURCE_ROOT_DIR ${CNSTREAM_ROOT_DIR}/source)
- #message(STATUS "SOURCE: CNSTREAM_ROOT_DIR = ${CNSTREAM_ROOT_DIR}")
- #message(STATUS "SOURCE: SOURCE_ROOT_DIR = ${SOURCE_ROOT_DIR}")
- # # compile flags
- # set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -O2")
- # set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -g")
- # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_REENTRANT -fPIC -Wall -Werror")
- option(build_kafka "build model kafka" ON)
- # ---[ kafka
- if(build_kafka)
- find_package(LibRDKafka)
- if(LIBRDKAFKA_FOUND)
- include_directories(${LibRDKafka_INCLUDE_DIR})
- list(APPEND 3RDPARTY_LIBS ${LibRDKafka_C_LIBRARIES})
- message(STATUS "LibRDKafka include: ${LibRDKafka_INCLUDE_DIR}")
- message(STATUS "LibRDKafka libraries: ${LibRDKafka_C_LIBRARIES}")
- else()
- message(FATAL_ERROR "rdkafka not found!")
- endif()
- endif()
- set(ENABLE_MYSQL ON CACHE BOOL "enable mysql")
- #查找mysql是否安装
- find_package(MYSQL QUIET)
- if(MYSQL_FOUND AND ENABLE_MYSQL)
- message(STATUS "找到mysqlclient库:\"${MYSQL_INCLUDE_DIR}\",ENABLE_MYSQL宏已打开")
- include_directories(${MYSQL_INCLUDE_DIR})
- include_directories(${MYSQL_INCLUDE_DIR}/mysql)
- add_definitions(-DENABLE_MYSQL)
- list(APPEND 3RDPARTY_LIBS ${MYSQL_LIBRARIES})
- endif()
- set(CMAKE_MODULE_PATH ${CNSTREAM_ROOT_DIR}/cmake/sanitizers ${CNSTREAM_ROOT_DIR}/cmake)
- # ---[ ZLToolKit
- find_package(ZLToolKit REQUIRED)
- link_directories(${ZLTOOLKIT_LINK_DIRS})
- include_directories(${ZLTOOLKIT_INCLUDE_DIRS})
- # ---[ rapidjson
- include_directories(${CNSTREAM_ROOT_DIR}/3rdparty/)
- # ---[ httplib
- include_directories(${CNSTREAM_ROOT_DIR}/3rdparty/httplib/)
- # ---[ modules include dirs
- include_directories(${CNSTREAM_ROOT_DIR}/modules/Expel/include)
- include_directories(${CNSTREAM_ROOT_DIR}/modules/HttpClient/include)
- include_directories(${CNSTREAM_ROOT_DIR}/modules/HttpServer/include)
- include_directories(${CNSTREAM_ROOT_DIR}/modules/InfineFilter/include)
- include_directories(${CNSTREAM_ROOT_DIR}/modules/Monitor/include)
- include_directories(${CNSTREAM_ROOT_DIR}/modules/TCPClient/include)
- include_directories(${CNSTREAM_ROOT_DIR}/modules/config/include)
- include_directories(${CNSTREAM_ROOT_DIR}/source/UserApp/include)
- include_directories(${CNSTREAM_ROOT_DIR}/framework/core/include)
- include_directories(${CNSTREAM_ROOT_DIR}/framework/request/include)
- include_directories(${CNSTREAM_ROOT_DIR}/plugins/ExpelPlugin/include)
- include_directories(${CNSTREAM_ROOT_DIR}/plugins/HttpPlugin/include)
- include_directories(${CNSTREAM_ROOT_DIR}/plugins/MonitorPlugin/include)
- include_directories(${CNSTREAM_ROOT_DIR}/plugins/TcpPlugin/include)
- include_directories(${CNSTREAM_ROOT_DIR}/plugins/AuditPlugin/include)
- aux_source_directory(${CNSTREAM_ROOT_DIR}/source/src srcs)
- aux_source_directory(${CNSTREAM_ROOT_DIR}/source/UserApp/src userApps)
- # ---[ add targets
- # set(EXECUTABLE_OUTPUT_PATH ${SOURCE_ROOT_DIR}/bin)
- add_executable(gsd ${srcs} ${userApps} ${3RDPARTY_LIBS})
- target_link_libraries(gsd gsd_core gsd_modules gsd_plugins pthread dl)
|