123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- cmake_minimum_required(VERSION 2.8.7)
- set(GSD_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
- #message(STATUS "PLUGIN: GSD_ROOT_DIR = ${GSD_ROOT_DIR}")
- 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()
- # compile flags
- # set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-as-needed")
- # 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")
- # ---[ Options
- option(build_ExpelPlugin "build module ExpelPlugin" ON)
- option(build_HttpPlugin "build module HttpPlugin" ON)
- option(build_MonitorPlugin "build module MonitorPlugin" ON)
- option(build_TcpPlugin "build module TcpPlugin" ON)
- option(build_AuditPlugin "build module AuditPlugin" ON)
- option(build_HepuPlugin "build module HepuPlugin" ON)
- option(build_kafka "build module kafka" ON)
- # ---[ 3rdparty
- set(3RDPARTY_LIBS "")
- set(CMAKE_MODULE_PATH ${GSD_ROOT_DIR}/cmake)
- # ---[ ZLToolKit
- find_package(ZLToolKit REQUIRED)
- #link_directories(${ZLTOOLKIT_LINK_DIR})
- include_directories(${ZLTOOLKIT_INCLUDE_DIR})
- list(APPEND 3RDPARTY_LIBS ${ZLTOOLKIT_LIBRARIES})
- message(STATUS "ZLToolKit include: ${ZLTOOLKIT_INCLUDE_DIR}")
- message(STATUS "ZLToolKit libraries: ${ZLTOOLKIT_LIBRARIES}")
- # ---[ rapidjson
- include_directories(${GSD_ROOT_DIR}/3rdparty/)
- include_directories(${GSD_ROOT_DIR}/3rdparty/httplib/)
- include_directories(${GSD_ROOT_DIR}/framework/core/include)
- include_directories(${GSD_ROOT_DIR}/framework/request/include)
- include_directories(${GSD_ROOT_DIR}/modules/Expel/include)
- include_directories(${GSD_ROOT_DIR}/modules/HttpClient/include)
- include_directories(${GSD_ROOT_DIR}/modules/Hepu/include)
- include_directories(${GSD_ROOT_DIR}/modules/InfineFilter/include)
- include_directories(${GSD_ROOT_DIR}/modules/Monitor/include)
- include_directories(${GSD_ROOT_DIR}/modules/TCPClient/include)
- include_directories(${GSD_ROOT_DIR}/modules/HttpServer/include)
- include_directories(${GSD_ROOT_DIR}/modules/config/include)
- include_directories(${GSD_ROOT_DIR}/modules/Audit/include)
- set(module_list "")
- set(srcs "")
- if(build_ExpelPlugin)
- list(APPEND module_list ExpelPlugin)
- #include_directories(${PROJECT_SOURCE_DIR}/plugins/ExpelPlugin/src)
- install(DIRECTORY ExpelPlugin/include/ DESTINATION include)
- endif()
- if(build_HttpPlugin)
- list(APPEND module_list HttpPlugin)
- #include_directories(${PROJECT_SOURCE_DIR}/plugins/HttpPlugin/src)
- install(DIRECTORY HttpPlugin/include/ DESTINATION include)
- endif()
- if(build_HepuPlugin)
- list(APPEND module_list HepuPlugin)
- #include_directories(${PROJECT_SOURCE_DIR}/plugins/HepuPlugin/src)
- install(DIRECTORY HepuPlugin/include/ DESTINATION include)
- endif()
- if(build_MonitorPlugin)
- list(APPEND module_list MonitorPlugin)
- #include_directories(${PROJECT_SOURCE_DIR}/plugins/MonitorPlugin/src)
- install(DIRECTORY MonitorPlugin/include/ DESTINATION include)
- endif()
- if(build_TcpPlugin)
- list(APPEND module_list TcpPlugin)
- #include_directories(${PROJECT_SOURCE_DIR}/plugins/TcpPlugin/src)
- install(DIRECTORY TcpPlugin/include/ DESTINATION include)
- endif()
- if(build_AuditPlugin)
- list(APPEND module_list AuditPlugin)
- # include_directories(${PROJECT_SOURCE_DIR}/plugins/AuditPlugin/src)
- install(DIRECTORY AuditPlugin/include/ DESTINATION include)
- endif()
- # ---[ kafka
- if(build_kafka)
- find_package(RDKafka REQUIRED)
- include_directories(${RDKAFKA_INCLUDE_DIR})
- list(APPEND 3RDPARTY_LIBS ${RDKAFKA_LIBRARIES})
- #link_directories(${RDKAFKA_LINK_DIR})
- message(STATUS "RDKafka include: ${RDKAFKA_INCLUDE_DIR}")
- message(STATUS "RDKafka libraries: ${RDKAFKA_LIBRARIES}")
- 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()
- include_directories(${CMAKE_CURRENT_SOURCE_DIR})
- foreach(module ${module_list})
- include_directories(${CMAKE_CURRENT_SOURCE_DIR}/${module}/include)
- file(GLOB_RECURSE module_src ${CMAKE_CURRENT_SOURCE_DIR}/${module}/*.cpp)
- list(APPEND srcs ${module_src})
- endforeach()
- set(LIBRARY_OUTPUT_PATH ${GSD_ROOT_DIR}/lib)
- add_library(gsd_plugins SHARED ${srcs})
- target_link_libraries(gsd_plugins gsd_modules ${3RDPARTY_LIBS} rt dl uuid pthread)
|