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) # ---[ 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}") message(STATUS "ZLToolKit link dir: ${ZLTOOLKIT_LINK_DIR}") # ---[ 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/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}/modules/ExpelPlugin/src) install(DIRECTORY ExpelPlugin/include/ DESTINATION include) endif() if(build_HttpPlugin) list(APPEND module_list HttpPlugin) include_directories(${PROJECT_SOURCE_DIR}/modules/HttpPlugin/src) install(DIRECTORY HttpPlugin/include/ DESTINATION include) endif() if(build_MonitorPlugin) list(APPEND module_list MonitorPlugin) include_directories(${PROJECT_SOURCE_DIR}/modules/MonitorPlugin/src) install(DIRECTORY MonitorPlugin/include/ DESTINATION include) endif() if(build_TcpPlugin) list(APPEND module_list TcpPlugin) include_directories(${PROJECT_SOURCE_DIR}/modules/TcpPlugin/src) install(DIRECTORY TcpPlugin/include/ DESTINATION include) endif() if(build_AuditPlugin) list(APPEND module_list AuditPlugin) include_directories(${PROJECT_SOURCE_DIR}/modules/AuditPlugin/src) install(DIRECTORY AuditPlugin/include/ DESTINATION include) 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 ${3RDPARTY_LIBS} rt dl uuid pthread)