CMakeLists.txt 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. cmake_minimum_required(VERSION 2.8.7)
  2. set(GSD_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
  3. include(CheckCXXCompilerFlag)
  4. CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
  5. if(NOT COMPILER_SUPPORTS_CXX11)
  6. message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
  7. endif()
  8. # compile flags
  9. # set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-as-needed")
  10. # set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -O2")
  11. # set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -g")
  12. # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_REENTRANT -fPIC -Wall -Werror")
  13. # ---[ Options
  14. option(build_ExpelPlugin "build module ExpelPlugin" ON)
  15. option(build_HttpPlugin "build module HttpPlugin" ON)
  16. option(build_MonitorPlugin "build module MonitorPlugin" ON)
  17. option(build_TcpPlugin "build module TcpPlugin" ON)
  18. # ---[ 3rdparty
  19. set(3RDPARTY_LIBS "")
  20. set(CMAKE_MODULE_PATH ${GSD_ROOT_DIR}/cmake)
  21. # ---[ rapidjson
  22. include_directories(${GSD_ROOT_DIR}/3rdparty/)
  23. include_directories(${GSD_ROOT_DIR}/framework/core/include)
  24. include_directories(${GSD_ROOT_DIR}/framework/request/include)
  25. include_directories(${GSD_ROOT_DIR}/modules/Expel/include)
  26. include_directories(${GSD_ROOT_DIR}/modules/HttpClient/include)
  27. include_directories(${GSD_ROOT_DIR}/modules/InfineFilter/include)
  28. include_directories(${GSD_ROOT_DIR}/modules/Monitor/include)
  29. include_directories(${GSD_ROOT_DIR}/modules/TCPClient/include)
  30. include_directories(${GSD_ROOT_DIR}/modules/HttpServer/include)
  31. include_directories(${GSD_ROOT_DIR}/modules/config/include)
  32. set(module_list "")
  33. set(srcs "")
  34. if(build_ExpelPlugin)
  35. list(APPEND module_list ExpelPlugin)
  36. include_directories(${PROJECT_SOURCE_DIR}/modules/ExpelPlugin/src)
  37. install(DIRECTORY ExpelPlugin/include/ DESTINATION include)
  38. endif()
  39. if(build_HttpPlugin)
  40. list(APPEND module_list HttpPlugin)
  41. include_directories(${PROJECT_SOURCE_DIR}/modules/HttpPlugin/src)
  42. install(DIRECTORY HttpPlugin/include/ DESTINATION include)
  43. endif()
  44. if(build_MonitorPlugin)
  45. list(APPEND module_list MonitorPlugin)
  46. include_directories(${PROJECT_SOURCE_DIR}/modules/MonitorPlugin/src)
  47. install(DIRECTORY MonitorPlugin/include/ DESTINATION include)
  48. endif()
  49. if(build_TcpPlugin)
  50. list(APPEND module_list TcpPlugin)
  51. include_directories(${PROJECT_SOURCE_DIR}/modules/TcpPlugin/src)
  52. install(DIRECTORY TcpPlugin/include/ DESTINATION include)
  53. endif()
  54. include_directories(${CMAKE_CURRENT_SOURCE_DIR})
  55. foreach(module ${module_list})
  56. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/${module}/include)
  57. file(GLOB_RECURSE module_src ${CMAKE_CURRENT_SOURCE_DIR}/${module}/*.cpp)
  58. list(APPEND srcs ${module_src})
  59. endforeach()
  60. set(LIBRARY_OUTPUT_PATH ${GSD_ROOT_DIR}/lib)
  61. add_library(gsd_plugins SHARED ${srcs})
  62. target_link_libraries(gsd_plugins ${3RDPARTY_LIBS} rt dl uuid pthread ZLToolKit)