123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- 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(TEST_ROOT_DIR ${CNSTREAM_ROOT_DIR}/test)
- message(STATUS "TEST: CNSTREAM_ROOT_DIR = ${CNSTREAM_ROOT_DIR}")
- message(STATUS "TEST: TEST_ROOT_DIR = ${TEST_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)
- # ---[ 3rdparty
- set(3RDPARTY_LIBS "")
- # ---[ 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 "TEST: RDKafka include: ${RDKAFKA_INCLUDE_DIR}")
- message(STATUS "TEST: 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()
- set(CMAKE_MODULE_PATH ${CNSTREAM_ROOT_DIR}/cmake/sanitizers ${CNSTREAM_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 "TEST: ZLToolKit include: ${ZLTOOLKIT_INCLUDE_DIR}")
- message(STATUS "TEST: ZLToolKit libraries: ${ZLTOOLKIT_LIBRARIES}")
- # ---[ 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}/modules/Hepu/include)
- include_directories(${CNSTREAM_ROOT_DIR}/test/TestApp/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)
- include_directories(${CNSTREAM_ROOT_DIR}/plugins/HepuPlugin/include)
- aux_source_directory(${CNSTREAM_ROOT_DIR}/test/src tests)
- aux_source_directory(${CNSTREAM_ROOT_DIR}/test/TestApp/src testApps)
- # ---[ add targets
- set(EXECUTABLE_OUTPUT_PATH ${TEST_ROOT_DIR}/bin)
- add_executable(hepu_test ${tests} ${testApps} ${3RDPARTY_LIBS})
- target_link_libraries(hepu_test gsd_core gsd_modules gsd_plugins ${3RDPARTY_LIBS} pthread dl)
|