2019-08-31 00:27:57 +00:00
|
|
|
cmake_minimum_required(VERSION 3.5)
|
2019-08-08 07:17:09 +00:00
|
|
|
|
2020-02-29 07:46:08 +00:00
|
|
|
project(drogon)
|
2020-12-13 14:12:01 +00:00
|
|
|
|
2020-01-25 03:58:20 +00:00
|
|
|
message(STATUS "compiler: " ${CMAKE_CXX_COMPILER_ID})
|
2021-01-17 04:03:27 +00:00
|
|
|
|
2023-07-31 15:16:15 +00:00
|
|
|
option(BUILD_CTL "Build drogon_ctl" ON)
|
|
|
|
option(BUILD_EXAMPLES "Build examples" ON)
|
2019-12-11 10:39:10 +00:00
|
|
|
option(BUILD_ORM "Build orm" ON)
|
2020-04-30 05:30:37 +00:00
|
|
|
option(COZ_PROFILING "Use coz for profiling" OFF)
|
2022-06-29 09:29:20 +00:00
|
|
|
option(BUILD_SHARED_LIBS "Build drogon as a shared lib" OFF)
|
2021-07-18 05:36:13 +00:00
|
|
|
option(BUILD_DOC "Build Doxygen documentation" OFF)
|
2021-10-08 00:42:34 +00:00
|
|
|
option(BUILD_BROTLI "Build Brotli" ON)
|
2023-03-20 11:02:13 +00:00
|
|
|
option(BUILD_YAML_CONFIG "Build yaml config" ON)
|
2023-03-08 16:16:21 +00:00
|
|
|
option(USE_SUBMODULE "Use trantor as a submodule" ON)
|
2019-12-11 10:39:10 +00:00
|
|
|
|
2021-03-24 02:32:55 +00:00
|
|
|
include(CMakeDependentOption)
|
|
|
|
CMAKE_DEPENDENT_OPTION(BUILD_POSTGRESQL "Build with postgresql support" ON "BUILD_ORM" OFF)
|
|
|
|
CMAKE_DEPENDENT_OPTION(LIBPQ_BATCH_MODE "Use batch mode for libpq" ON "BUILD_POSTGRESQL" OFF)
|
|
|
|
CMAKE_DEPENDENT_OPTION(BUILD_MYSQL "Build with mysql support" ON "BUILD_ORM" OFF)
|
|
|
|
CMAKE_DEPENDENT_OPTION(BUILD_SQLITE "Build with sqlite3 support" ON "BUILD_ORM" OFF)
|
|
|
|
CMAKE_DEPENDENT_OPTION(BUILD_REDIS "Build with redis support" ON "BUILD_ORM" OFF)
|
2023-12-04 15:42:35 +00:00
|
|
|
CMAKE_DEPENDENT_OPTION(USE_SPDLOG "Allow using the spdlog logging library" OFF "USE_SUBMODULE" OFF)
|
2021-03-24 02:32:55 +00:00
|
|
|
|
2019-08-08 07:17:09 +00:00
|
|
|
set(DROGON_MAJOR_VERSION 1)
|
2023-09-24 02:52:52 +00:00
|
|
|
set(DROGON_MINOR_VERSION 9)
|
2024-06-08 12:31:23 +00:00
|
|
|
set(DROGON_PATCH_VERSION 5)
|
2019-08-08 07:17:09 +00:00
|
|
|
set(DROGON_VERSION
|
2021-03-24 02:32:55 +00:00
|
|
|
${DROGON_MAJOR_VERSION}.${DROGON_MINOR_VERSION}.${DROGON_PATCH_VERSION})
|
2023-10-29 03:43:24 +00:00
|
|
|
set(DROGON_VERSION_STRING "${DROGON_VERSION}")
|
2019-08-08 07:17:09 +00:00
|
|
|
|
2021-08-22 11:31:47 +00:00
|
|
|
include(GNUInstallDirs)
|
2019-08-08 07:17:09 +00:00
|
|
|
# Offer the user the choice of overriding the installation directories
|
2021-08-22 11:31:47 +00:00
|
|
|
set(INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation directory for libraries")
|
|
|
|
set(INSTALL_BIN_DIR ${CMAKE_INSTALL_BINDIR} CACHE PATH "Installation directory for executables")
|
|
|
|
set(INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH "Installation directory for header files")
|
|
|
|
set(DEF_INSTALL_DROGON_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/Drogon)
|
2021-03-24 02:32:55 +00:00
|
|
|
set(INSTALL_DROGON_CMAKE_DIR ${DEF_INSTALL_DROGON_CMAKE_DIR}
|
|
|
|
CACHE PATH "Installation directory for cmake files")
|
2021-03-13 11:13:54 +00:00
|
|
|
|
2021-05-27 12:09:57 +00:00
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
2023-12-04 15:42:35 +00:00
|
|
|
# Force MSVC to use UTF-8 because that's what we use. Otherwise it uses
|
|
|
|
# the default of whatever Windows sets and causes encoding issues.
|
|
|
|
message(STATUS "You are using MSVC. Forceing to use UTF-8")
|
|
|
|
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
|
|
|
|
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
|
|
|
|
if (MSVC_VERSION GREATER_EQUAL 1914)
|
|
|
|
# Tells Visual Studio 2017 (15.7+) and newer to correctly set the value of the standard __cplusplus macro,
|
|
|
|
# instead of leaving it to 199711L and settings the effective c++ version in _MSVC_LANG
|
|
|
|
# Dropping support for older versions of VS would allow to only rely on __cplusplus
|
|
|
|
add_compile_options("/Zc:__cplusplus")
|
|
|
|
endif()
|
2021-05-27 12:09:57 +00:00
|
|
|
endif ()
|
|
|
|
|
2022-06-29 09:29:20 +00:00
|
|
|
add_library(${PROJECT_NAME})
|
|
|
|
if (BUILD_SHARED_LIBS)
|
2021-04-09 02:17:28 +00:00
|
|
|
find_package(Threads)
|
2021-03-13 11:13:54 +00:00
|
|
|
# set(BUILD_EXAMPLES FALSE)
|
|
|
|
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
|
2021-03-24 02:32:55 +00:00
|
|
|
"${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}" isSystemDir)
|
2021-03-13 11:13:54 +00:00
|
|
|
if ("${isSystemDir}" STREQUAL "-1")
|
|
|
|
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}")
|
|
|
|
endif ("${isSystemDir}" STREQUAL "-1")
|
2021-04-22 05:22:13 +00:00
|
|
|
set_target_properties(${PROJECT_NAME} PROPERTIES
|
|
|
|
VERSION ${DROGON_VERSION}
|
|
|
|
SOVERSION ${DROGON_MAJOR_VERSION})
|
2021-04-09 02:17:28 +00:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC Threads::Threads)
|
2021-05-17 13:45:18 +00:00
|
|
|
if (WIN32)
|
2024-01-18 05:38:27 +00:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC rpcrt4 crypt32 advapi32 ws2_32)
|
2021-05-17 13:45:18 +00:00
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
|
|
|
|
# Ignore MSVC C4251 and C4275 warning of exporting std objects with no dll export
|
|
|
|
# We export class to facilitate maintenance, thus if you compile
|
|
|
|
# drogon on windows as a shared library, you will need to use
|
|
|
|
# exact same compiler for drogon and your app.
|
|
|
|
target_compile_options(${PROJECT_NAME} PUBLIC /wd4251 /wd4275)
|
|
|
|
endif ()
|
|
|
|
endif ()
|
2022-06-29 09:29:20 +00:00
|
|
|
endif (BUILD_SHARED_LIBS)
|
2019-12-12 04:49:18 +00:00
|
|
|
|
2023-12-04 15:42:35 +00:00
|
|
|
if(USE_SPDLOG)
|
|
|
|
find_package(spdlog CONFIG)
|
|
|
|
if(spdlog_FOUND)
|
|
|
|
message(STATUS "spdlog found!")
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC spdlog::spdlog_header_only)
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC DROGON_SPDLOG_SUPPORT SPDLOG_FMT_EXTERNAL FMT_HEADER_ONLY)
|
|
|
|
endif(spdlog_FOUND)
|
|
|
|
endif(USE_SPDLOG)
|
|
|
|
|
2021-07-11 04:29:37 +00:00
|
|
|
if (NOT ${CMAKE_PLATFORM_NAME} STREQUAL "Windows" AND CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
2021-04-15 11:27:15 +00:00
|
|
|
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Werror)
|
2021-05-17 13:45:18 +00:00
|
|
|
endif ()
|
2021-04-15 11:27:15 +00:00
|
|
|
|
2021-04-09 02:17:28 +00:00
|
|
|
include(GenerateExportHeader)
|
|
|
|
generate_export_header(${PROJECT_NAME} EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/exports/drogon/exports.h)
|
|
|
|
|
2020-10-12 13:51:39 +00:00
|
|
|
include(cmake/DrogonUtilities.cmake)
|
2021-05-27 12:09:57 +00:00
|
|
|
include(cmake/ParseAndAddDrogonTests.cmake)
|
2019-07-26 14:22:12 +00:00
|
|
|
include(CheckIncludeFileCXX)
|
|
|
|
|
2019-08-31 00:27:57 +00:00
|
|
|
check_include_file_cxx(any HAS_ANY)
|
|
|
|
check_include_file_cxx(string_view HAS_STRING_VIEW)
|
2021-02-06 09:05:58 +00:00
|
|
|
check_include_file_cxx(coroutine HAS_COROUTINE)
|
2021-08-24 08:34:07 +00:00
|
|
|
if (NOT "${CMAKE_CXX_STANDARD}" STREQUAL "")
|
|
|
|
set(DROGON_CXX_STANDARD ${CMAKE_CXX_STANDARD})
|
|
|
|
elseif (HAS_ANY AND HAS_STRING_VIEW AND HAS_COROUTINE)
|
2021-03-13 11:13:54 +00:00
|
|
|
set(DROGON_CXX_STANDARD 20)
|
|
|
|
else ()
|
2023-08-23 03:33:30 +00:00
|
|
|
set(DROGON_CXX_STANDARD 17)
|
2021-03-13 11:13:54 +00:00
|
|
|
endif ()
|
2023-03-08 16:16:21 +00:00
|
|
|
if(USE_SUBMODULE)
|
|
|
|
target_include_directories(
|
|
|
|
${PROJECT_NAME}
|
|
|
|
PUBLIC
|
|
|
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/trantor>)
|
|
|
|
endif()
|
2019-08-31 00:27:57 +00:00
|
|
|
target_include_directories(
|
2021-03-24 02:32:55 +00:00
|
|
|
${PROJECT_NAME}
|
|
|
|
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/lib/inc>
|
|
|
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/orm_lib/inc>
|
|
|
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/nosql_lib/redis/inc>
|
|
|
|
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
|
2021-04-09 02:17:28 +00:00
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/exports>
|
2021-03-24 02:32:55 +00:00
|
|
|
$<INSTALL_INTERFACE:${INSTALL_INCLUDE_DIR}>)
|
2021-03-13 11:13:54 +00:00
|
|
|
|
|
|
|
if (WIN32)
|
|
|
|
target_include_directories(
|
2021-03-24 02:32:55 +00:00
|
|
|
${PROJECT_NAME}
|
|
|
|
PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third_party/mman-win32>)
|
2021-03-13 11:13:54 +00:00
|
|
|
endif (WIN32)
|
2020-01-25 03:58:20 +00:00
|
|
|
|
2023-03-08 16:16:21 +00:00
|
|
|
if(USE_SUBMODULE)
|
2019-08-08 07:17:09 +00:00
|
|
|
add_subdirectory(trantor)
|
2019-08-31 00:27:57 +00:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC trantor)
|
2023-03-08 16:16:21 +00:00
|
|
|
else()
|
|
|
|
find_package(Trantor CONFIG REQUIRED)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC Trantor::Trantor)
|
|
|
|
endif()
|
2019-08-31 00:27:57 +00:00
|
|
|
|
2021-08-28 03:47:24 +00:00
|
|
|
if(${CMAKE_SYSTEM_NAME} STREQUAL "Haiku")
|
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE network)
|
|
|
|
elseif (NOT WIN32 AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
|
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE dl)
|
|
|
|
elseif (WIN32)
|
2024-01-18 05:38:27 +00:00
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE shlwapi ws2_32 iphlpapi)
|
2021-08-28 03:47:24 +00:00
|
|
|
endif ()
|
2021-03-13 11:13:54 +00:00
|
|
|
|
2021-08-24 08:34:07 +00:00
|
|
|
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules/)
|
|
|
|
|
|
|
|
find_package(Filesystem COMPONENTS Final)
|
|
|
|
if(CXX_FILESYSTEM_HAVE_FS)
|
|
|
|
message(STATUS "Found std::filesystem")
|
2023-08-23 03:33:30 +00:00
|
|
|
else ()
|
|
|
|
message(FATAL_ERROR "Not found std::filesystem, please use a newer compiler")
|
2021-08-24 08:34:07 +00:00
|
|
|
endif()
|
|
|
|
|
2023-08-23 03:33:30 +00:00
|
|
|
if (DROGON_CXX_STANDARD EQUAL 17)
|
2021-03-13 11:13:54 +00:00
|
|
|
message(STATUS "use c++17")
|
2021-07-12 14:38:02 +00:00
|
|
|
# Check for partial implementation of c++17 (Windows/OSX only?)
|
2023-08-23 03:33:30 +00:00
|
|
|
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
|
|
|
try_compile(check_filesystem_path ${CMAKE_BINARY_DIR}/cmaketest
|
|
|
|
${PROJECT_SOURCE_DIR}/cmake/tests/check_has_std_filesystem_path.cc
|
|
|
|
CXX_STANDARD 17)
|
|
|
|
set(CMAKE_TRY_COMPILE_TARGET_TYPE)
|
|
|
|
if (NOT check_filesystem_path)
|
|
|
|
message(FATAL_ERROR "The std::filesystem seems to be a partial implementation,"
|
|
|
|
" please use a newer compiler")
|
2021-07-12 14:38:02 +00:00
|
|
|
endif()
|
2021-03-13 11:13:54 +00:00
|
|
|
else ()
|
|
|
|
message(STATUS "use c++20")
|
2021-08-24 08:34:07 +00:00
|
|
|
endif ()
|
|
|
|
|
2019-07-26 14:22:12 +00:00
|
|
|
|
2023-08-23 03:33:30 +00:00
|
|
|
option(HAS_STD_FILESYSTEM_PATH "use std::filesystem" ON)
|
|
|
|
# HACK: Needed to be compiled on Yocto Linux
|
|
|
|
if(TARGET std::filesystem)
|
|
|
|
get_property(CAN_LINK_FS TARGET std::filesystem PROPERTY INTERFACE_LINK_LIBRARIES SET)
|
|
|
|
if ( CAN_LINK_FS )
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC std::filesystem)
|
|
|
|
endif()
|
2021-08-09 14:37:23 +00:00
|
|
|
endif()
|
|
|
|
|
2023-08-23 03:33:30 +00:00
|
|
|
|
2019-08-31 00:27:57 +00:00
|
|
|
# jsoncpp
|
|
|
|
find_package(Jsoncpp REQUIRED)
|
2020-03-18 11:54:48 +00:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC Jsoncpp_lib)
|
2019-08-31 00:27:57 +00:00
|
|
|
list(APPEND INCLUDE_DIRS_FOR_DYNAMIC_VIEW ${JSONCPP_INCLUDE_DIRS})
|
2019-08-08 07:17:09 +00:00
|
|
|
|
2023-03-08 16:17:11 +00:00
|
|
|
# yamlcpp
|
2023-03-20 11:02:13 +00:00
|
|
|
if(BUILD_YAML_CONFIG)
|
|
|
|
find_package(yaml-cpp QUIET)
|
|
|
|
if(yaml-cpp_FOUND)
|
2023-07-29 15:23:05 +00:00
|
|
|
if (NOT YAML_CPP_LIBRARIES)
|
|
|
|
find_library(YAML_CPP_LINK_LIBRARY "yaml-cpp")
|
|
|
|
if(NOT YAML_CPP_LINK_LIBRARY)
|
|
|
|
message(STATUS "yaml-cpp not used")
|
|
|
|
else()
|
|
|
|
message(STATUS "yaml-cpp found ")
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${YAML_CPP_LINK_LIBRARY})
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC HAS_YAML_CPP)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
message(STATUS "yaml-cpp found ")
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${YAML_CPP_LIBRARIES})
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC HAS_YAML_CPP)
|
|
|
|
endif()
|
2023-03-20 11:02:13 +00:00
|
|
|
else()
|
2023-07-29 15:23:05 +00:00
|
|
|
message(STATUS "yaml-cpp not used")
|
|
|
|
endif()
|
2023-03-08 16:17:11 +00:00
|
|
|
else()
|
2023-03-20 11:02:13 +00:00
|
|
|
message(STATUS "yaml-cpp not used")
|
|
|
|
endif(BUILD_YAML_CONFIG)
|
2023-03-08 16:17:11 +00:00
|
|
|
|
2021-03-24 02:32:55 +00:00
|
|
|
if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD"
|
|
|
|
AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD"
|
|
|
|
AND NOT WIN32)
|
2021-03-13 11:13:54 +00:00
|
|
|
find_package(UUID REQUIRED)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE UUID_lib)
|
|
|
|
|
|
|
|
try_compile(normal_uuid ${CMAKE_BINARY_DIR}/cmaketest
|
2021-03-24 02:32:55 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/cmake/tests/normal_uuid_lib_test.cc
|
2023-08-22 13:24:42 +00:00
|
|
|
LINK_LIBRARIES UUID_lib
|
|
|
|
OUTPUT_VARIABLE NORMAL_UUID_COMPILE_OUTPUT)
|
2021-03-13 11:13:54 +00:00
|
|
|
try_compile(ossp_uuid ${CMAKE_BINARY_DIR}/cmaketest
|
2021-03-24 02:32:55 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/cmake/tests/ossp_uuid_lib_test.cc
|
2023-08-22 13:24:42 +00:00
|
|
|
LINK_LIBRARIES UUID_lib
|
|
|
|
OUTPUT_VARIABLE OSSP_UUID_COMPILE_OUTPUT)
|
2021-03-13 11:13:54 +00:00
|
|
|
if (normal_uuid)
|
|
|
|
add_definitions(-DUSE_OSSP_UUID=0)
|
|
|
|
elseif (ossp_uuid)
|
|
|
|
add_definitions(-DUSE_OSSP_UUID=1)
|
|
|
|
else ()
|
2023-08-22 13:24:42 +00:00
|
|
|
message(FATAL_ERROR "uuid lib error:\n${NORMAL_UUID_COMPILE_OUTPUT}\n${OSSP_UUID_COMPILE_OUTPUT}")
|
2021-03-13 11:13:54 +00:00
|
|
|
endif ()
|
2021-03-24 02:32:55 +00:00
|
|
|
endif (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD"
|
|
|
|
AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD"
|
|
|
|
AND NOT WIN32)
|
2019-08-31 00:27:57 +00:00
|
|
|
|
2021-10-08 00:42:34 +00:00
|
|
|
if (BUILD_BROTLI)
|
|
|
|
find_package(Brotli)
|
|
|
|
if (Brotli_FOUND)
|
|
|
|
message(STATUS "Brotli found")
|
|
|
|
add_definitions(-DUSE_BROTLI)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE Brotli_lib)
|
|
|
|
endif (Brotli_FOUND)
|
|
|
|
endif (BUILD_BROTLI)
|
2020-04-04 10:15:15 +00:00
|
|
|
|
2019-08-31 00:27:57 +00:00
|
|
|
set(DROGON_SOURCES
|
2021-03-24 02:32:55 +00:00
|
|
|
lib/src/AOPAdvice.cc
|
2023-09-04 02:16:44 +00:00
|
|
|
lib/src/AccessLogger.cc
|
2021-03-24 02:32:55 +00:00
|
|
|
lib/src/CacheFile.cc
|
2023-09-04 02:16:44 +00:00
|
|
|
lib/src/ConfigAdapterManager.cc
|
2021-03-24 02:32:55 +00:00
|
|
|
lib/src/ConfigLoader.cc
|
|
|
|
lib/src/Cookie.cc
|
|
|
|
lib/src/DrClassMap.cc
|
|
|
|
lib/src/DrTemplateBase.cc
|
2024-05-10 02:03:20 +00:00
|
|
|
lib/src/MiddlewaresFunction.cc
|
2023-09-04 02:16:44 +00:00
|
|
|
lib/src/FixedWindowRateLimiter.cc
|
|
|
|
lib/src/GlobalFilters.cc
|
|
|
|
lib/src/Histogram.cc
|
|
|
|
lib/src/Hodor.cc
|
2021-03-24 02:32:55 +00:00
|
|
|
lib/src/HttpAppFrameworkImpl.cc
|
2021-03-28 02:56:23 +00:00
|
|
|
lib/src/HttpBinder.cc
|
2021-03-24 02:32:55 +00:00
|
|
|
lib/src/HttpClientImpl.cc
|
2023-12-28 03:53:10 +00:00
|
|
|
lib/src/HttpConnectionLimit.cc
|
|
|
|
lib/src/HttpControllerBinder.cc
|
2021-03-24 02:32:55 +00:00
|
|
|
lib/src/HttpControllersRouter.cc
|
|
|
|
lib/src/HttpFileImpl.cc
|
|
|
|
lib/src/HttpFileUploadRequest.cc
|
|
|
|
lib/src/HttpRequestImpl.cc
|
|
|
|
lib/src/HttpRequestParser.cc
|
|
|
|
lib/src/HttpResponseImpl.cc
|
|
|
|
lib/src/HttpResponseParser.cc
|
|
|
|
lib/src/HttpServer.cc
|
|
|
|
lib/src/HttpUtils.cc
|
|
|
|
lib/src/HttpViewData.cc
|
|
|
|
lib/src/IntranetIpFilter.cc
|
2023-09-04 02:16:44 +00:00
|
|
|
lib/src/JsonConfigAdapter.cc
|
2021-03-24 02:32:55 +00:00
|
|
|
lib/src/ListenerManager.cc
|
|
|
|
lib/src/LocalHostFilter.cc
|
|
|
|
lib/src/MultiPart.cc
|
|
|
|
lib/src/NotFound.cc
|
|
|
|
lib/src/PluginsManager.cc
|
2023-09-04 02:16:44 +00:00
|
|
|
lib/src/PromExporter.cc
|
2021-10-28 13:53:58 +00:00
|
|
|
lib/src/RangeParser.cc
|
2023-09-04 02:16:44 +00:00
|
|
|
lib/src/RateLimiter.cc
|
2022-07-28 15:34:35 +00:00
|
|
|
lib/src/RealIpResolver.cc
|
2023-09-04 02:16:44 +00:00
|
|
|
lib/src/SecureSSLRedirector.cc
|
2023-09-16 09:33:38 +00:00
|
|
|
lib/src/Redirector.cc
|
2021-03-24 02:32:55 +00:00
|
|
|
lib/src/SessionManager.cc
|
2023-09-04 02:16:44 +00:00
|
|
|
lib/src/SlashRemover.cc
|
|
|
|
lib/src/SlidingWindowRateLimiter.cc
|
2021-03-24 02:32:55 +00:00
|
|
|
lib/src/StaticFileRouter.cc
|
2021-04-29 02:13:34 +00:00
|
|
|
lib/src/TaskTimeoutFlag.cc
|
2023-09-04 02:16:44 +00:00
|
|
|
lib/src/TokenBucketRateLimiter.cc
|
2021-03-24 02:32:55 +00:00
|
|
|
lib/src/Utilities.cc
|
|
|
|
lib/src/WebSocketClientImpl.cc
|
|
|
|
lib/src/WebSocketConnectionImpl.cc
|
2023-09-04 02:16:44 +00:00
|
|
|
lib/src/YamlConfigAdapter.cc
|
|
|
|
lib/src/drogon_test.cc)
|
2021-07-15 15:57:12 +00:00
|
|
|
set(private_headers
|
|
|
|
lib/src/AOPAdvice.h
|
|
|
|
lib/src/CacheFile.h
|
|
|
|
lib/src/ConfigLoader.h
|
2023-12-28 03:53:10 +00:00
|
|
|
lib/src/ControllerBinderBase.h
|
2024-05-10 02:03:20 +00:00
|
|
|
lib/src/MiddlewaresFunction.h
|
2021-07-15 15:57:12 +00:00
|
|
|
lib/src/HttpAppFrameworkImpl.h
|
|
|
|
lib/src/HttpClientImpl.h
|
2023-12-28 03:53:10 +00:00
|
|
|
lib/src/HttpConnectionLimit.h
|
|
|
|
lib/src/HttpControllerBinder.h
|
2021-07-15 15:57:12 +00:00
|
|
|
lib/src/HttpControllersRouter.h
|
|
|
|
lib/src/HttpFileImpl.h
|
|
|
|
lib/src/HttpFileUploadRequest.h
|
|
|
|
lib/src/HttpMessageBody.h
|
|
|
|
lib/src/HttpRequestImpl.h
|
|
|
|
lib/src/HttpRequestParser.h
|
|
|
|
lib/src/HttpResponseImpl.h
|
|
|
|
lib/src/HttpResponseParser.h
|
|
|
|
lib/src/HttpServer.h
|
|
|
|
lib/src/HttpUtils.h
|
|
|
|
lib/src/impl_forwards.h
|
|
|
|
lib/src/ListenerManager.h
|
|
|
|
lib/src/PluginsManager.h
|
|
|
|
lib/src/SessionManager.h
|
|
|
|
lib/src/SpinLock.h
|
|
|
|
lib/src/StaticFileRouter.h
|
|
|
|
lib/src/TaskTimeoutFlag.h
|
|
|
|
lib/src/WebSocketClientImpl.h
|
|
|
|
lib/src/WebSocketConnectionImpl.h
|
2022-10-27 14:49:16 +00:00
|
|
|
lib/src/FixedWindowRateLimiter.h
|
|
|
|
lib/src/SlidingWindowRateLimiter.h
|
2023-03-08 16:17:11 +00:00
|
|
|
lib/src/TokenBucketRateLimiter.h
|
|
|
|
lib/src/ConfigAdapterManager.h
|
|
|
|
lib/src/JsonConfigAdapter.h
|
|
|
|
lib/src/YamlConfigAdapter.h
|
|
|
|
lib/src/ConfigAdapter.h)
|
2021-03-13 11:13:54 +00:00
|
|
|
|
|
|
|
if (NOT WIN32)
|
2021-07-15 15:57:12 +00:00
|
|
|
set(DROGON_SOURCES
|
|
|
|
${DROGON_SOURCES}
|
|
|
|
lib/src/SharedLibManager.cc)
|
|
|
|
set(private_headers
|
|
|
|
${private_headers}
|
|
|
|
lib/src/SharedLibManager.h)
|
2021-03-13 11:13:54 +00:00
|
|
|
else (NOT WIN32)
|
2021-07-15 15:57:12 +00:00
|
|
|
set(DROGON_SOURCES
|
|
|
|
${DROGON_SOURCES}
|
|
|
|
third_party/mman-win32/mman.c)
|
|
|
|
set(private_headers
|
|
|
|
${private_headers}
|
|
|
|
third_party/mman-win32/mman.h)
|
2021-03-13 11:13:54 +00:00
|
|
|
endif (NOT WIN32)
|
|
|
|
|
2021-03-24 02:32:55 +00:00
|
|
|
if (BUILD_POSTGRESQL)
|
2021-03-13 11:13:54 +00:00
|
|
|
# find postgres
|
|
|
|
find_package(pg)
|
|
|
|
if (pg_FOUND)
|
|
|
|
message(STATUS "libpq inc path:" ${PG_INCLUDE_DIRS})
|
|
|
|
message(STATUS "libpq lib:" ${PG_LIBRARIES})
|
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE pg_lib)
|
2021-07-15 15:57:12 +00:00
|
|
|
set(DROGON_SOURCES
|
|
|
|
${DROGON_SOURCES}
|
2023-01-04 15:50:49 +00:00
|
|
|
orm_lib/src/postgresql_impl/PostgreSQLResultImpl.cc
|
|
|
|
orm_lib/src/postgresql_impl/PgListener.cc)
|
2021-07-15 15:57:12 +00:00
|
|
|
set(private_headers
|
|
|
|
${private_headers}
|
2023-01-04 15:50:49 +00:00
|
|
|
orm_lib/src/postgresql_impl/PostgreSQLResultImpl.h
|
|
|
|
orm_lib/src/postgresql_impl/PgListener.h)
|
2021-03-13 11:13:54 +00:00
|
|
|
if (LIBPQ_BATCH_MODE)
|
|
|
|
try_compile(libpq_supports_batch ${CMAKE_BINARY_DIR}/cmaketest
|
2021-03-24 02:32:55 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/cmake/tests/test_libpq_batch_mode.cc
|
|
|
|
LINK_LIBRARIES ${PostgreSQL_LIBRARIES}
|
|
|
|
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${PostgreSQL_INCLUDE_DIR}")
|
2021-03-13 11:13:54 +00:00
|
|
|
endif (LIBPQ_BATCH_MODE)
|
|
|
|
if (libpq_supports_batch)
|
|
|
|
message(STATUS "The libpq supports batch mode")
|
|
|
|
option(LIBPQ_SUPPORTS_BATCH_MODE "libpq batch mode" ON)
|
2021-07-15 15:57:12 +00:00
|
|
|
set(DROGON_SOURCES
|
|
|
|
${DROGON_SOURCES}
|
2021-03-24 02:32:55 +00:00
|
|
|
orm_lib/src/postgresql_impl/PgBatchConnection.cc)
|
2021-03-13 11:13:54 +00:00
|
|
|
else (libpq_supports_batch)
|
|
|
|
option(LIBPQ_SUPPORTS_BATCH_MODE "libpq batch mode" OFF)
|
2021-07-15 15:57:12 +00:00
|
|
|
set(DROGON_SOURCES
|
|
|
|
${DROGON_SOURCES}
|
2021-03-24 02:32:55 +00:00
|
|
|
orm_lib/src/postgresql_impl/PgConnection.cc)
|
2021-07-15 15:57:12 +00:00
|
|
|
set(private_headers
|
|
|
|
${private_headers}
|
|
|
|
orm_lib/src/postgresql_impl/PgConnection.h)
|
2021-03-13 11:13:54 +00:00
|
|
|
endif (libpq_supports_batch)
|
|
|
|
endif (pg_FOUND)
|
2021-03-24 02:32:55 +00:00
|
|
|
endif (BUILD_POSTGRESQL)
|
2021-03-13 11:13:54 +00:00
|
|
|
|
2021-03-24 02:32:55 +00:00
|
|
|
if (BUILD_MYSQL)
|
2022-01-25 13:00:56 +00:00
|
|
|
# Find mysql, only mariadb client library is supported
|
|
|
|
find_package(MySQL QUIET)
|
|
|
|
find_package(unofficial-libmariadb QUIET)
|
2021-03-13 11:13:54 +00:00
|
|
|
if (MySQL_FOUND)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE MySQL_lib)
|
2022-01-25 13:00:56 +00:00
|
|
|
set(DROGON_FOUND_MYSQL TRUE)
|
2022-05-29 07:17:15 +00:00
|
|
|
set(MYSQL_LIB_NAME MySQL_lib)
|
2022-01-25 13:00:56 +00:00
|
|
|
elseif (unofficial-libmariadb_FOUND)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE unofficial::libmariadb)
|
|
|
|
set(DROGON_FOUND_MYSQL TRUE)
|
2022-05-29 07:17:15 +00:00
|
|
|
set(MYSQL_LIB_NAME unofficial::libmariadb)
|
2022-01-25 13:00:56 +00:00
|
|
|
endif ()
|
|
|
|
|
|
|
|
if (DROGON_FOUND_MYSQL)
|
|
|
|
message(STATUS "Ok! We find mariadb!")
|
2022-05-29 07:17:15 +00:00
|
|
|
include(CheckLibraryExists)
|
|
|
|
check_library_exists(${MYSQL_LIB_NAME} mysql_optionsv "" HAS_MYSQL_OPTIONSV)
|
|
|
|
if (HAS_MYSQL_OPTIONSV)
|
|
|
|
message(STATUS "Mariadb support mysql_optionsv")
|
|
|
|
add_definitions(-DHAS_MYSQL_OPTIONSV)
|
|
|
|
endif(HAS_MYSQL_OPTIONSV)
|
|
|
|
|
2021-07-15 15:57:12 +00:00
|
|
|
set(DROGON_SOURCES
|
|
|
|
${DROGON_SOURCES}
|
2021-03-24 02:32:55 +00:00
|
|
|
orm_lib/src/mysql_impl/MysqlConnection.cc
|
|
|
|
orm_lib/src/mysql_impl/MysqlResultImpl.cc)
|
2021-07-15 15:57:12 +00:00
|
|
|
set(private_headers
|
|
|
|
${private_headers}
|
|
|
|
orm_lib/src/mysql_impl/MysqlConnection.h
|
|
|
|
orm_lib/src/mysql_impl/MysqlResultImpl.h)
|
2022-01-25 13:00:56 +00:00
|
|
|
else (DROGON_FOUND_MYSQL)
|
|
|
|
message(STATUS "MySql was not found.")
|
|
|
|
endif (DROGON_FOUND_MYSQL)
|
2021-03-24 02:32:55 +00:00
|
|
|
endif (BUILD_MYSQL)
|
2021-03-13 11:13:54 +00:00
|
|
|
|
2021-03-24 02:32:55 +00:00
|
|
|
if (BUILD_SQLITE)
|
2021-03-13 11:13:54 +00:00
|
|
|
# Find sqlite3.
|
2022-01-25 13:00:56 +00:00
|
|
|
find_package(SQLite3 QUIET)
|
|
|
|
find_package(unofficial-sqlite3 QUIET)
|
2021-03-13 11:13:54 +00:00
|
|
|
if (SQLite3_FOUND)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE SQLite3_lib)
|
2022-01-25 13:00:56 +00:00
|
|
|
set(DROGON_FOUND_SQLite3 TRUE)
|
|
|
|
elseif (unofficial-sqlite3_FOUND)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE unofficial::sqlite3::sqlite3)
|
|
|
|
set(DROGON_FOUND_SQLite3 TRUE)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
if (DROGON_FOUND_SQLite3)
|
|
|
|
message(STATUS "Ok! We find sqlite3!")
|
2021-07-15 15:57:12 +00:00
|
|
|
set(DROGON_SOURCES
|
|
|
|
${DROGON_SOURCES}
|
2021-03-24 02:32:55 +00:00
|
|
|
orm_lib/src/sqlite3_impl/Sqlite3Connection.cc
|
|
|
|
orm_lib/src/sqlite3_impl/Sqlite3ResultImpl.cc)
|
2021-07-15 15:57:12 +00:00
|
|
|
set(private_headers
|
|
|
|
${private_headers}
|
|
|
|
orm_lib/src/sqlite3_impl/Sqlite3Connection.h
|
|
|
|
orm_lib/src/sqlite3_impl/Sqlite3ResultImpl.h)
|
2022-01-25 13:00:56 +00:00
|
|
|
else (DROGON_FOUND_SQLite3)
|
|
|
|
message(STATUS "sqlite3 was not found.")
|
|
|
|
endif (DROGON_FOUND_SQLite3)
|
2021-03-24 02:32:55 +00:00
|
|
|
endif (BUILD_SQLITE)
|
2021-03-13 11:13:54 +00:00
|
|
|
|
|
|
|
if (BUILD_REDIS)
|
|
|
|
find_package(Hiredis)
|
|
|
|
if (Hiredis_FOUND)
|
|
|
|
add_definitions(-DUSE_REDIS)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE Hiredis_lib)
|
|
|
|
set(DROGON_SOURCES
|
2021-03-24 02:32:55 +00:00
|
|
|
${DROGON_SOURCES}
|
|
|
|
nosql_lib/redis/src/RedisClientImpl.cc
|
|
|
|
nosql_lib/redis/src/RedisClientLockFree.cc
|
|
|
|
nosql_lib/redis/src/RedisClientManager.cc
|
2021-07-15 15:57:12 +00:00
|
|
|
nosql_lib/redis/src/RedisConnection.cc
|
|
|
|
nosql_lib/redis/src/RedisResult.cc
|
2022-09-13 02:30:51 +00:00
|
|
|
nosql_lib/redis/src/RedisTransactionImpl.cc
|
|
|
|
nosql_lib/redis/src/SubscribeContext.cc
|
|
|
|
nosql_lib/redis/src/RedisSubscriberImpl.cc)
|
2021-07-15 15:57:12 +00:00
|
|
|
set(private_headers
|
|
|
|
${private_headers}
|
|
|
|
nosql_lib/redis/src/RedisClientImpl.h
|
|
|
|
nosql_lib/redis/src/RedisClientLockFree.h
|
|
|
|
nosql_lib/redis/src/RedisConnection.h
|
2022-09-13 02:30:51 +00:00
|
|
|
nosql_lib/redis/src/RedisTransactionImpl.h
|
|
|
|
nosql_lib/redis/src/SubscribeContext.h
|
|
|
|
nosql_lib/redis/src/RedisSubscriberImpl.h)
|
2021-03-13 11:13:54 +00:00
|
|
|
|
|
|
|
endif (Hiredis_FOUND)
|
|
|
|
endif (BUILD_REDIS)
|
2018-04-27 06:38:27 +00:00
|
|
|
|
2021-04-09 02:17:28 +00:00
|
|
|
if (NOT Hiredis_FOUND)
|
|
|
|
set(DROGON_SOURCES
|
2021-05-17 13:45:18 +00:00
|
|
|
${DROGON_SOURCES}
|
|
|
|
lib/src/RedisClientSkipped.cc
|
|
|
|
lib/src/RedisResultSkipped.cc
|
|
|
|
lib/src/RedisClientManagerSkipped.cc)
|
2021-07-15 15:57:12 +00:00
|
|
|
set(private_headers
|
|
|
|
${private_headers}
|
|
|
|
lib/src/RedisClientManager.h)
|
2021-04-09 02:17:28 +00:00
|
|
|
endif (NOT Hiredis_FOUND)
|
|
|
|
|
|
|
|
if (BUILD_TESTING)
|
|
|
|
add_subdirectory(nosql_lib/redis/tests)
|
|
|
|
endif (BUILD_TESTING)
|
|
|
|
|
2021-03-24 02:32:55 +00:00
|
|
|
find_package(ZLIB REQUIRED)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE ZLIB::ZLIB)
|
|
|
|
|
2020-02-06 14:13:50 +00:00
|
|
|
execute_process(COMMAND "git" rev-parse HEAD
|
2021-03-24 02:32:55 +00:00
|
|
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
|
|
|
OUTPUT_VARIABLE GIT_SHA1
|
|
|
|
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2020-02-06 14:13:50 +00:00
|
|
|
configure_file("${PROJECT_SOURCE_DIR}/cmake/templates/version.h.in"
|
2021-03-24 02:32:55 +00:00
|
|
|
"${PROJECT_SOURCE_DIR}/lib/inc/drogon/version.h" @ONLY)
|
2021-03-13 11:13:54 +00:00
|
|
|
|
|
|
|
if (DROGON_CXX_STANDARD EQUAL 20)
|
|
|
|
option(USE_COROUTINE "Enable C++20 coroutine support" ON)
|
|
|
|
else (DROGON_CXX_STANDARD EQUAL 20)
|
|
|
|
option(USE_COROUTINE "Enable C++20 coroutine support" OFF)
|
|
|
|
endif (DROGON_CXX_STANDARD EQUAL 20)
|
|
|
|
|
|
|
|
if (BUILD_EXAMPLES)
|
|
|
|
add_subdirectory(examples)
|
|
|
|
endif (BUILD_EXAMPLES)
|
|
|
|
|
|
|
|
if (BUILD_CTL)
|
|
|
|
add_subdirectory(drogon_ctl)
|
|
|
|
endif (BUILD_CTL)
|
|
|
|
|
|
|
|
if (COZ_PROFILING)
|
|
|
|
find_package(coz-profiler REQUIRED)
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE -DCOZ_PROFILING=1)
|
|
|
|
# If linked will not need to be ran with `coz run --- [executable]` to run the
|
|
|
|
# profiler, but drogon_ctl currently won't build because it doesn't find debug
|
|
|
|
# information while trying to generate it's own sources
|
|
|
|
# target_link_libraries(${PROJECT_NAME} PUBLIC coz::coz)
|
|
|
|
target_include_directories(${PROJECT_NAME} PUBLIC ${COZ_INCLUDE_DIRS})
|
|
|
|
endif (COZ_PROFILING)
|
|
|
|
|
2021-04-09 02:17:28 +00:00
|
|
|
set(DROGON_SOURCES
|
2021-05-17 13:45:18 +00:00
|
|
|
${DROGON_SOURCES}
|
|
|
|
orm_lib/src/ArrayParser.cc
|
|
|
|
orm_lib/src/Criteria.cc
|
|
|
|
orm_lib/src/DbClient.cc
|
|
|
|
orm_lib/src/DbClientImpl.cc
|
|
|
|
orm_lib/src/DbClientLockFree.cc
|
|
|
|
orm_lib/src/DbConnection.cc
|
2023-01-04 15:50:49 +00:00
|
|
|
orm_lib/src/DbListener.cc
|
2021-05-17 13:45:18 +00:00
|
|
|
orm_lib/src/Exception.cc
|
|
|
|
orm_lib/src/Field.cc
|
|
|
|
orm_lib/src/Result.cc
|
|
|
|
orm_lib/src/Row.cc
|
|
|
|
orm_lib/src/SqlBinder.cc
|
|
|
|
orm_lib/src/TransactionImpl.cc
|
|
|
|
orm_lib/src/RestfulController.cc)
|
2021-07-15 15:57:12 +00:00
|
|
|
set(DROGON_HEADERS
|
|
|
|
lib/inc/drogon/Attribute.h
|
|
|
|
lib/inc/drogon/CacheMap.h
|
|
|
|
lib/inc/drogon/Cookie.h
|
|
|
|
lib/inc/drogon/DrClassMap.h
|
|
|
|
lib/inc/drogon/DrObject.h
|
|
|
|
lib/inc/drogon/DrTemplate.h
|
|
|
|
lib/inc/drogon/DrTemplateBase.h
|
|
|
|
lib/inc/drogon/HttpAppFramework.h
|
|
|
|
lib/inc/drogon/HttpBinder.h
|
|
|
|
lib/inc/drogon/HttpClient.h
|
|
|
|
lib/inc/drogon/HttpController.h
|
|
|
|
lib/inc/drogon/HttpFilter.h
|
2024-05-10 02:03:20 +00:00
|
|
|
lib/inc/drogon/HttpMiddleware.h
|
2021-07-15 15:57:12 +00:00
|
|
|
lib/inc/drogon/HttpRequest.h
|
|
|
|
lib/inc/drogon/HttpResponse.h
|
|
|
|
lib/inc/drogon/HttpSimpleController.h
|
|
|
|
lib/inc/drogon/HttpTypes.h
|
|
|
|
lib/inc/drogon/HttpViewData.h
|
|
|
|
lib/inc/drogon/IntranetIpFilter.h
|
|
|
|
lib/inc/drogon/IOThreadStorage.h
|
|
|
|
lib/inc/drogon/LocalHostFilter.h
|
|
|
|
lib/inc/drogon/MultiPart.h
|
|
|
|
lib/inc/drogon/NotFound.h
|
|
|
|
lib/inc/drogon/Session.h
|
|
|
|
lib/inc/drogon/UploadFile.h
|
|
|
|
lib/inc/drogon/WebSocketClient.h
|
|
|
|
lib/inc/drogon/WebSocketConnection.h
|
|
|
|
lib/inc/drogon/WebSocketController.h
|
|
|
|
lib/inc/drogon/drogon.h
|
|
|
|
lib/inc/drogon/version.h
|
|
|
|
lib/inc/drogon/drogon_callbacks.h
|
|
|
|
lib/inc/drogon/PubSubService.h
|
|
|
|
lib/inc/drogon/drogon_test.h
|
2022-10-27 14:49:16 +00:00
|
|
|
lib/inc/drogon/RateLimiter.h
|
2021-07-15 15:57:12 +00:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/exports/drogon/exports.h)
|
|
|
|
set(private_headers
|
|
|
|
${private_headers}
|
|
|
|
lib/src/DbClientManager.h
|
|
|
|
orm_lib/src/DbClientImpl.h
|
|
|
|
orm_lib/src/DbConnection.h
|
|
|
|
orm_lib/src/ResultImpl.h
|
|
|
|
orm_lib/src/TransactionImpl.h)
|
2022-01-25 13:00:56 +00:00
|
|
|
if (pg_FOUND OR DROGON_FOUND_MYSQL OR DROGON_FOUND_SQLite3)
|
2021-04-09 02:17:28 +00:00
|
|
|
set(DROGON_SOURCES
|
2021-05-17 13:45:18 +00:00
|
|
|
${DROGON_SOURCES}
|
|
|
|
orm_lib/src/DbClientManager.cc)
|
2022-01-25 13:00:56 +00:00
|
|
|
else (pg_FOUND OR DROGON_FOUND_MYSQL OR DROGON_FOUND_SQLite3)
|
2021-07-15 15:57:12 +00:00
|
|
|
set(DROGON_SOURCES
|
|
|
|
${DROGON_SOURCES}
|
|
|
|
lib/src/DbClientManagerSkipped.cc)
|
2022-01-25 13:00:56 +00:00
|
|
|
endif (pg_FOUND OR DROGON_FOUND_MYSQL OR DROGON_FOUND_SQLite3)
|
2019-07-26 14:22:12 +00:00
|
|
|
|
2019-11-30 00:35:40 +00:00
|
|
|
set_target_properties(${PROJECT_NAME}
|
2021-03-24 02:32:55 +00:00
|
|
|
PROPERTIES CXX_STANDARD ${DROGON_CXX_STANDARD})
|
2019-08-31 00:27:57 +00:00
|
|
|
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD_REQUIRED ON)
|
|
|
|
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_EXTENSIONS OFF)
|
2019-10-04 14:24:34 +00:00
|
|
|
set_target_properties(${PROJECT_NAME} PROPERTIES EXPORT_NAME Drogon)
|
2019-07-26 14:22:12 +00:00
|
|
|
|
2022-01-25 13:00:56 +00:00
|
|
|
if (pg_FOUND OR DROGON_FOUND_MYSQL OR DROGON_FOUND_SQLite3)
|
2021-03-13 11:13:54 +00:00
|
|
|
if (pg_FOUND)
|
|
|
|
option(USE_POSTGRESQL "Enable PostgreSQL" ON)
|
|
|
|
else (pg_FOUND)
|
|
|
|
option(USE_POSTGRESQL "Disable PostgreSQL" OFF)
|
|
|
|
endif (pg_FOUND)
|
|
|
|
|
2022-01-25 13:00:56 +00:00
|
|
|
if (DROGON_FOUND_MYSQL)
|
2021-03-13 11:13:54 +00:00
|
|
|
option(USE_MYSQL "Enable Mysql" ON)
|
2022-01-25 13:00:56 +00:00
|
|
|
else (DROGON_FOUND_MYSQL)
|
2021-06-22 07:08:06 +00:00
|
|
|
option(USE_MYSQL "Disable Mysql" OFF)
|
2022-01-25 13:00:56 +00:00
|
|
|
endif (DROGON_FOUND_MYSQL)
|
2021-03-13 11:13:54 +00:00
|
|
|
|
2022-01-25 13:00:56 +00:00
|
|
|
if (DROGON_FOUND_SQLite3)
|
2021-03-13 11:13:54 +00:00
|
|
|
option(USE_SQLITE3 "Enable Sqlite3" ON)
|
2022-01-25 13:00:56 +00:00
|
|
|
else (DROGON_FOUND_SQLite3)
|
2021-03-13 11:13:54 +00:00
|
|
|
option(USE_SQLITE3 "Disable Sqlite3" OFF)
|
2022-01-25 13:00:56 +00:00
|
|
|
endif (DROGON_FOUND_SQLite3)
|
|
|
|
endif (pg_FOUND OR DROGON_FOUND_MYSQL OR DROGON_FOUND_SQLite3)
|
2019-07-26 14:22:12 +00:00
|
|
|
|
2023-05-09 11:24:00 +00:00
|
|
|
get_filename_component(COMPILER_COMMAND ${CMAKE_CXX_COMPILER} NAME)
|
2019-08-08 07:17:09 +00:00
|
|
|
set(COMPILER_ID ${CMAKE_CXX_COMPILER_ID})
|
2019-07-26 14:22:12 +00:00
|
|
|
|
2021-03-13 11:13:54 +00:00
|
|
|
if (CMAKE_BUILD_TYPE)
|
|
|
|
string(TOLOWER ${CMAKE_BUILD_TYPE} _type)
|
|
|
|
if (_type STREQUAL release)
|
|
|
|
set(COMPILATION_FLAGS "${CMAKE_CXX_FLAGS_RELEASE} -std=c++")
|
|
|
|
elseif (_type STREQUAL debug)
|
|
|
|
set(COMPILATION_FLAGS "${CMAKE_CXX_FLAGS_DEBUG} -std=c++")
|
|
|
|
else ()
|
|
|
|
set(COMPILATION_FLAGS "-std=c++")
|
|
|
|
endif ()
|
|
|
|
else (CMAKE_BUILD_TYPE)
|
2019-08-08 07:17:09 +00:00
|
|
|
set(COMPILATION_FLAGS "-std=c++")
|
2021-03-13 11:13:54 +00:00
|
|
|
endif (CMAKE_BUILD_TYPE)
|
2019-08-08 07:17:09 +00:00
|
|
|
|
2020-03-21 04:41:15 +00:00
|
|
|
list(APPEND INCLUDE_DIRS_FOR_DYNAMIC_VIEW
|
2021-03-24 02:32:55 +00:00
|
|
|
"${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
|
2019-08-31 00:27:57 +00:00
|
|
|
list(REMOVE_DUPLICATES INCLUDE_DIRS_FOR_DYNAMIC_VIEW)
|
2019-08-08 07:17:09 +00:00
|
|
|
set(INS_STRING "")
|
2021-03-13 11:13:54 +00:00
|
|
|
foreach (loop_var ${INCLUDE_DIRS_FOR_DYNAMIC_VIEW})
|
|
|
|
set(INS_STRING "${INS_STRING} -I${loop_var}")
|
|
|
|
endforeach (loop_var)
|
2019-08-08 07:17:09 +00:00
|
|
|
|
|
|
|
set(INCLUDING_DIRS ${INS_STRING})
|
|
|
|
|
2019-08-31 00:27:57 +00:00
|
|
|
configure_file(${PROJECT_SOURCE_DIR}/cmake/templates/config.h.in
|
2021-03-24 02:32:55 +00:00
|
|
|
${PROJECT_BINARY_DIR}/drogon/config.h @ONLY)
|
2021-03-13 11:13:54 +00:00
|
|
|
|
|
|
|
if (BUILD_TESTING)
|
2021-05-27 12:09:57 +00:00
|
|
|
message(STATUS "Building tests")
|
|
|
|
enable_testing()
|
2021-03-13 11:13:54 +00:00
|
|
|
add_subdirectory(lib/tests)
|
|
|
|
if (pg_FOUND)
|
|
|
|
add_subdirectory(${PROJECT_SOURCE_DIR}/orm_lib/src/postgresql_impl/test)
|
|
|
|
endif (pg_FOUND)
|
2022-01-25 13:00:56 +00:00
|
|
|
if (DROGON_FOUND_MYSQL)
|
2021-03-13 11:13:54 +00:00
|
|
|
add_subdirectory(${PROJECT_SOURCE_DIR}/orm_lib/src/mysql_impl/test)
|
2022-01-25 13:00:56 +00:00
|
|
|
endif (DROGON_FOUND_MYSQL)
|
|
|
|
if (DROGON_FOUND_SQLite3)
|
2021-03-13 11:13:54 +00:00
|
|
|
add_subdirectory(${PROJECT_SOURCE_DIR}/orm_lib/src/sqlite3_impl/test)
|
2022-01-25 13:00:56 +00:00
|
|
|
endif (DROGON_FOUND_SQLite3)
|
2021-04-09 02:17:28 +00:00
|
|
|
add_subdirectory(${PROJECT_SOURCE_DIR}/orm_lib/tests)
|
2021-03-13 11:13:54 +00:00
|
|
|
endif (BUILD_TESTING)
|
2018-05-04 01:51:12 +00:00
|
|
|
|
2019-08-31 00:27:57 +00:00
|
|
|
# Installation
|
2019-07-26 14:22:12 +00:00
|
|
|
|
2019-09-26 11:33:58 +00:00
|
|
|
install(TARGETS ${PROJECT_NAME}
|
2021-03-24 02:32:55 +00:00
|
|
|
EXPORT DrogonTargets
|
2021-04-09 02:17:28 +00:00
|
|
|
RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin
|
2021-03-24 02:32:55 +00:00
|
|
|
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib
|
|
|
|
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib)
|
2019-08-08 07:17:09 +00:00
|
|
|
|
|
|
|
install(FILES ${DROGON_HEADERS} DESTINATION ${INSTALL_INCLUDE_DIR}/drogon)
|
2019-07-26 14:22:12 +00:00
|
|
|
|
2019-08-31 00:27:57 +00:00
|
|
|
set(ORM_HEADERS
|
2021-03-24 02:32:55 +00:00
|
|
|
orm_lib/inc/drogon/orm/ArrayParser.h
|
2023-05-23 11:39:08 +00:00
|
|
|
orm_lib/inc/drogon/orm/BaseBuilder.h
|
2021-03-24 02:32:55 +00:00
|
|
|
orm_lib/inc/drogon/orm/Criteria.h
|
|
|
|
orm_lib/inc/drogon/orm/DbClient.h
|
2024-05-23 06:03:28 +00:00
|
|
|
orm_lib/inc/drogon/orm/DbConfig.h
|
2023-01-04 15:50:49 +00:00
|
|
|
orm_lib/inc/drogon/orm/DbListener.h
|
2021-03-24 02:32:55 +00:00
|
|
|
orm_lib/inc/drogon/orm/DbTypes.h
|
|
|
|
orm_lib/inc/drogon/orm/Exception.h
|
|
|
|
orm_lib/inc/drogon/orm/Field.h
|
|
|
|
orm_lib/inc/drogon/orm/FunctionTraits.h
|
|
|
|
orm_lib/inc/drogon/orm/Mapper.h
|
2021-04-16 07:48:19 +00:00
|
|
|
orm_lib/inc/drogon/orm/CoroMapper.h
|
2021-03-24 02:32:55 +00:00
|
|
|
orm_lib/inc/drogon/orm/Result.h
|
|
|
|
orm_lib/inc/drogon/orm/ResultIterator.h
|
|
|
|
orm_lib/inc/drogon/orm/Row.h
|
|
|
|
orm_lib/inc/drogon/orm/RowIterator.h
|
|
|
|
orm_lib/inc/drogon/orm/SqlBinder.h
|
|
|
|
orm_lib/inc/drogon/orm/RestfulController.h)
|
2019-08-08 07:17:09 +00:00
|
|
|
install(FILES ${ORM_HEADERS} DESTINATION ${INSTALL_INCLUDE_DIR}/drogon/orm)
|
2019-07-26 14:22:12 +00:00
|
|
|
|
2021-07-15 15:57:12 +00:00
|
|
|
set(NOSQL_HEADERS
|
|
|
|
nosql_lib/redis/inc/drogon/nosql/RedisClient.h
|
2021-03-24 02:32:55 +00:00
|
|
|
nosql_lib/redis/inc/drogon/nosql/RedisResult.h
|
2022-09-13 02:30:51 +00:00
|
|
|
nosql_lib/redis/inc/drogon/nosql/RedisSubscriber.h
|
2021-03-24 02:32:55 +00:00
|
|
|
nosql_lib/redis/inc/drogon/nosql/RedisException.h)
|
2021-03-13 11:13:54 +00:00
|
|
|
install(FILES ${NOSQL_HEADERS} DESTINATION ${INSTALL_INCLUDE_DIR}/drogon/nosql)
|
|
|
|
|
2019-08-31 00:27:57 +00:00
|
|
|
set(DROGON_UTIL_HEADERS
|
2021-03-24 02:32:55 +00:00
|
|
|
lib/inc/drogon/utils/coroutine.h
|
2022-05-29 10:57:18 +00:00
|
|
|
lib/inc/drogon/utils/FunctionTraits.h
|
2021-03-24 02:32:55 +00:00
|
|
|
lib/inc/drogon/utils/HttpConstraint.h
|
2022-05-29 10:57:18 +00:00
|
|
|
lib/inc/drogon/utils/OStringStream.h
|
2023-09-04 02:16:44 +00:00
|
|
|
lib/inc/drogon/utils/Utilities.h
|
|
|
|
lib/inc/drogon/utils/monitoring.h)
|
2019-08-08 07:17:09 +00:00
|
|
|
install(FILES ${DROGON_UTIL_HEADERS}
|
2021-03-24 02:32:55 +00:00
|
|
|
DESTINATION ${INSTALL_INCLUDE_DIR}/drogon/utils)
|
2019-08-08 07:17:09 +00:00
|
|
|
|
2023-09-04 02:16:44 +00:00
|
|
|
set(DROGON_MONITORING_HEADERS
|
|
|
|
lib/inc/drogon/utils/monitoring/Counter.h
|
|
|
|
lib/inc/drogon/utils/monitoring/Metric.h
|
|
|
|
lib/inc/drogon/utils/monitoring/Registry.h
|
|
|
|
lib/inc/drogon/utils/monitoring/Collector.h
|
|
|
|
lib/inc/drogon/utils/monitoring/Sample.h
|
|
|
|
lib/inc/drogon/utils/monitoring/Gauge.h
|
|
|
|
lib/inc/drogon/utils/monitoring/Histogram.h)
|
|
|
|
|
|
|
|
install(FILES ${DROGON_MONITORING_HEADERS}
|
|
|
|
DESTINATION ${INSTALL_INCLUDE_DIR}/drogon/utils/monitoring)
|
|
|
|
|
2021-07-15 15:57:12 +00:00
|
|
|
set(DROGON_PLUGIN_HEADERS
|
|
|
|
lib/inc/drogon/plugins/Plugin.h
|
2023-09-16 09:33:38 +00:00
|
|
|
lib/inc/drogon/plugins/Redirector.h
|
2021-05-17 13:45:18 +00:00
|
|
|
lib/inc/drogon/plugins/SecureSSLRedirector.h
|
2022-07-28 15:34:35 +00:00
|
|
|
lib/inc/drogon/plugins/AccessLogger.h
|
2022-10-27 14:49:16 +00:00
|
|
|
lib/inc/drogon/plugins/RealIpResolver.h
|
2023-04-16 03:55:00 +00:00
|
|
|
lib/inc/drogon/plugins/Hodor.h
|
2023-05-26 03:08:57 +00:00
|
|
|
lib/inc/drogon/plugins/SlashRemover.h
|
2023-09-04 02:16:44 +00:00
|
|
|
lib/inc/drogon/plugins/GlobalFilters.h
|
|
|
|
lib/inc/drogon/plugins/PromExporter.h)
|
2023-04-16 03:55:00 +00:00
|
|
|
|
2019-08-08 07:17:09 +00:00
|
|
|
install(FILES ${DROGON_PLUGIN_HEADERS}
|
2021-03-24 02:32:55 +00:00
|
|
|
DESTINATION ${INSTALL_INCLUDE_DIR}/drogon/plugins)
|
2019-08-08 07:17:09 +00:00
|
|
|
|
2021-07-15 15:57:12 +00:00
|
|
|
target_sources(${PROJECT_NAME} PRIVATE
|
|
|
|
${DROGON_SOURCES}
|
|
|
|
${private_headers}
|
|
|
|
${DROGON_HEADERS}
|
|
|
|
${ORM_HEADERS}
|
|
|
|
${DROGON_UTIL_HEADERS}
|
|
|
|
${DROGON_PLUGIN_HEADERS}
|
2023-09-04 02:16:44 +00:00
|
|
|
${NOSQL_HEADERS}
|
|
|
|
${DROGON_MONITORING_HEADERS})
|
2021-07-15 15:57:12 +00:00
|
|
|
|
2019-08-31 00:27:57 +00:00
|
|
|
source_group("Public API"
|
2021-03-24 02:32:55 +00:00
|
|
|
FILES
|
|
|
|
${DROGON_HEADERS}
|
|
|
|
${ORM_HEADERS}
|
|
|
|
${DROGON_UTIL_HEADERS}
|
|
|
|
${DROGON_PLUGIN_HEADERS}
|
2023-09-04 02:16:44 +00:00
|
|
|
${NOSQL_HEADERS}
|
|
|
|
${DROGON_MONITORING_HEADERS})
|
2021-07-15 15:57:12 +00:00
|
|
|
source_group("Private Headers"
|
|
|
|
FILES
|
|
|
|
${private_headers})
|
2019-08-08 07:17:09 +00:00
|
|
|
|
2019-08-31 00:27:57 +00:00
|
|
|
# Export the package for use from the build-tree (this registers the build-tree
|
|
|
|
# with a global cmake-registry) export(PACKAGE Drogon)
|
2019-08-08 07:17:09 +00:00
|
|
|
|
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
# ... for the install tree
|
2019-08-31 00:27:57 +00:00
|
|
|
configure_package_config_file(
|
2021-03-24 02:32:55 +00:00
|
|
|
cmake/templates/DrogonConfig.cmake.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DrogonConfig.cmake
|
|
|
|
INSTALL_DESTINATION
|
|
|
|
${INSTALL_DROGON_CMAKE_DIR})
|
2019-08-08 07:17:09 +00:00
|
|
|
|
|
|
|
# version
|
2019-08-31 00:27:57 +00:00
|
|
|
write_basic_package_version_file(
|
2021-03-24 02:32:55 +00:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/DrogonConfigVersion.cmake
|
|
|
|
VERSION ${DROGON_VERSION}
|
|
|
|
COMPATIBILITY SameMajorVersion)
|
2019-08-08 07:17:09 +00:00
|
|
|
|
|
|
|
# Install the DrogonConfig.cmake and DrogonConfigVersion.cmake
|
2021-03-24 02:32:55 +00:00
|
|
|
install(FILES
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DrogonConfig.cmake"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/DrogonConfigVersion.cmake"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/FindUUID.cmake"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/FindJsoncpp.cmake"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/FindSQLite3.cmake"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/FindMySQL.cmake"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/Findpg.cmake"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/FindBrotli.cmake"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/Findcoz-profiler.cmake"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/FindHiredis.cmake"
|
2021-08-24 08:34:07 +00:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/FindFilesystem.cmake"
|
2021-03-24 02:32:55 +00:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/DrogonUtilities.cmake"
|
2021-05-27 12:09:57 +00:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/ParseAndAddDrogonTests.cmake"
|
2021-03-24 02:32:55 +00:00
|
|
|
DESTINATION "${INSTALL_DROGON_CMAKE_DIR}"
|
|
|
|
COMPONENT dev)
|
2019-08-08 07:17:09 +00:00
|
|
|
|
|
|
|
# Install the export set for use with the install-tree
|
2019-08-31 00:27:57 +00:00
|
|
|
install(EXPORT DrogonTargets
|
2021-03-24 02:32:55 +00:00
|
|
|
DESTINATION "${INSTALL_DROGON_CMAKE_DIR}"
|
|
|
|
NAMESPACE Drogon::
|
|
|
|
COMPONENT dev)
|
2021-05-27 12:09:57 +00:00
|
|
|
|
2021-07-18 05:36:13 +00:00
|
|
|
# Doxygen documentation
|
|
|
|
find_package(Doxygen OPTIONAL_COMPONENTS dot dia)
|
|
|
|
if(DOXYGEN_FOUND)
|
|
|
|
set(DOXYGEN_PROJECT_BRIEF "C++14/17-based HTTP application framework")
|
|
|
|
set(DOXYGEN_OUTPUT_DIRECTORY docs/${PROJECT_NAME})
|
|
|
|
set(DOXYGEN_GENERATE_LATEX NO)
|
|
|
|
set(DOXYGEN_BUILTIN_STL_SUPPORT YES)
|
|
|
|
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE README.md)
|
|
|
|
set(DOXYGEN_STRIP_FROM_INC_PATH ${PROJECT_SOURCE_DIR}/lib/inc
|
|
|
|
${PROJECT_SOURCE_DIR}/orm_lib/inc
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/exports)
|
|
|
|
set(DOXYGEN_EXAMPLE_PATTERNS *)
|
|
|
|
if(WIN32)
|
|
|
|
set(DOXYGEN_PREDEFINED _WIN32)
|
|
|
|
endif(WIN32)
|
|
|
|
doxygen_add_docs(doc_${PROJECT_NAME}
|
|
|
|
README.md
|
|
|
|
README.zh-CN.md
|
|
|
|
README.zh-TW.md
|
|
|
|
ChangeLog.md
|
|
|
|
CONTRIBUTING.md
|
|
|
|
${DROGON_HEADERS}
|
|
|
|
${DROGON_UTIL_HEADERS}
|
|
|
|
${DROGON_PLUGIN_HEADERS}
|
|
|
|
${ORM_HEADERS}
|
|
|
|
COMMENT "Generate documentation")
|
|
|
|
if(NOT TARGET doc)
|
|
|
|
add_custom_target(doc)
|
|
|
|
endif()
|
|
|
|
add_dependencies(doc doc_${PROJECT_NAME})
|
|
|
|
if (BUILD_DOC)
|
|
|
|
add_dependencies(${PROJECT_NAME} doc_${PROJECT_NAME})
|
|
|
|
# Don't install twice, so limit to Debug (assume developer)
|
|
|
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/docs/${PROJECT_NAME}
|
|
|
|
TYPE DOC
|
|
|
|
CONFIGURATIONS Debug)
|
|
|
|
endif(BUILD_DOC)
|
|
|
|
endif(DOXYGEN_FOUND)
|
|
|
|
|
2021-08-18 14:31:32 +00:00
|
|
|
include(cmake/Packages.cmake)
|