123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- cmake_minimum_required(VERSION 3.5)
- project(gsd CXX)
- include(CheckIncludeFileCXX)
- set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
- # add_compile_options(-DRELEASE)
- check_include_file_cxx(any HAS_ANY)
- check_include_file_cxx(string_view HAS_STRING_VIEW)
- check_include_file_cxx(coroutine HAS_COROUTINE)
- if (NOT "${CMAKE_CXX_STANDARD}" STREQUAL "")
- # Do nothing
- elseif (HAS_ANY AND HAS_STRING_VIEW AND HAS_COROUTINE)
- set(CMAKE_CXX_STANDARD 20)
- elseif (HAS_ANY AND HAS_STRING_VIEW)
- set(CMAKE_CXX_STANDARD 17)
- else ()
- set(CMAKE_CXX_STANDARD 14)
- endif ()
- set(CMAKE_CXX_STANDARD_REQUIRED ON)
- set(CMAKE_CXX_EXTENSIONS OFF)
- set(LINK_LIB_LIST "")
- 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 LINK_LIB_LIST ${MYSQL_LIBRARIES})
- endif()
- link_directories(/usr/local/lib)
- include_directories(${PROJECT_SOURCE_DIR}/3rdparty/rapidjson/include/)
- include_directories(${PROJECT_SOURCE_DIR}/3rdparty/CSerialPort/)
- include_directories(/usr/local/include/)
- include_directories(${PROJECT_SOURCE_DIR}/3rdparty/)
- include_directories(${PROJECT_SOURCE_DIR}/include/)
- include_directories(${PROJECT_SOURCE_DIR}/modules/)
- include_directories(${PROJECT_SOURCE_DIR}/plugins/)
- add_executable(${PROJECT_NAME} main.cc)
- # ##############################################################################
- # If you include the drogon source code locally in your project, use this method
- # to add drogon
- # add_subdirectory(drogon)
- # target_link_libraries(${PROJECT_NAME} PRIVATE drogon)
- #
- # and comment out the following lines
- find_package(Drogon CONFIG REQUIRED)
- target_link_libraries(${PROJECT_NAME} Drogon::Drogon ZLToolKit ${LINK_LIB_LIST})
- # ##############################################################################
- if (CMAKE_CXX_STANDARD LESS 17)
- # With C++14, use boost to support any, string_view and filesystem
- message(STATUS "use c++14")
- find_package(Boost 1.61.0 REQUIRED)
- target_link_libraries(${PROJECT_NAME} PUBLIC Boost::boost)
- elseif (CMAKE_CXX_STANDARD LESS 20)
- message(STATUS "use c++17")
- else ()
- message(STATUS "use c++20")
- endif ()
- aux_source_directory(controllers CTL_SRC)
- aux_source_directory(filters FILTER_SRC)
- aux_source_directory(plugins PLUGIN_SRC)
- aux_source_directory(models MODEL_SRC)
- aux_source_directory(modules MODULE_SRC)
- drogon_create_views(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/views
- ${CMAKE_CURRENT_BINARY_DIR})
- # use the following line to create views with namespaces.
- # drogon_create_views(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/views
- # ${CMAKE_CURRENT_BINARY_DIR} TRUE)
- # use the following line to create views with namespace CHANGE_ME prefixed
- # and path namespaces.
- # drogon_create_views(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/views
- # ${CMAKE_CURRENT_BINARY_DIR} TRUE CHANGE_ME)
- target_include_directories(${PROJECT_NAME}
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_CURRENT_SOURCE_DIR}/models /usr/local/lib/)
- target_sources(${PROJECT_NAME}
- PRIVATE
- ${SRC_DIR}
- ${CTL_SRC}
- ${FILTER_SRC}
- ${PLUGIN_SRC}
- ${MODEL_SRC}
- ${MODULE_SRC})
- # ##############################################################################
- # uncomment the following line for dynamically loading views
- # set_property(TARGET ${PROJECT_NAME} PROPERTY ENABLE_EXPORTS ON)
- # ##############################################################################
- add_subdirectory(test)
|