2019-08-31 08:27:57 +08:00
|
|
|
cmake_minimum_required(VERSION 3.5)
|
2019-08-08 15:17:09 +08:00
|
|
|
|
2020-02-29 15:46:08 +08:00
|
|
|
project(drogon)
|
2020-01-25 11:58:20 +08:00
|
|
|
message(STATUS "compiler: " ${CMAKE_CXX_COMPILER_ID})
|
2019-12-11 18:39:10 +08:00
|
|
|
option(BUILD_CTL "Build drogon_ctl" ON)
|
|
|
|
option(BUILD_EXAMPLES "Build examples" ON)
|
|
|
|
option(BUILD_ORM "Build orm" ON)
|
|
|
|
option(LIBPQ_BATCH_MODE "Use batch mode for libpq" ON)
|
|
|
|
option(BUILD_DROGON_SHARED "Build drogon as a shared lib" OFF)
|
|
|
|
|
2019-08-08 15:17:09 +08:00
|
|
|
set(DROGON_MAJOR_VERSION 1)
|
|
|
|
set(DROGON_MINOR_VERSION 0)
|
|
|
|
set(DROGON_PATCH_VERSION 0)
|
|
|
|
set(DROGON_VERSION
|
2019-08-31 08:27:57 +08:00
|
|
|
${DROGON_MAJOR_VERSION}.${DROGON_MINOR_VERSION}.${DROGON_PATCH_VERSION})
|
2020-02-22 21:15:15 +08:00
|
|
|
set(DROGON_VERSION_STRING "${DROGON_VERSION}.beta14")
|
2019-08-08 15:17:09 +08:00
|
|
|
|
|
|
|
# Offer the user the choice of overriding the installation directories
|
|
|
|
set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
|
|
|
|
set(INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables")
|
2019-08-31 08:27:57 +08:00
|
|
|
set(INSTALL_INCLUDE_DIR
|
|
|
|
include
|
|
|
|
CACHE PATH "Installation directory for header files")
|
2020-02-29 15:46:08 +08:00
|
|
|
set(DEF_INSTALL_DROGON_CMAKE_DIR lib/cmake/Drogon)
|
2019-08-31 08:27:57 +08:00
|
|
|
set(INSTALL_DROGON_CMAKE_DIR
|
|
|
|
${DEF_INSTALL_DROGON_CMAKE_DIR}
|
|
|
|
CACHE PATH "Installation directory for cmake files")
|
2019-07-26 22:22:12 +08:00
|
|
|
|
2019-12-12 12:49:18 +08:00
|
|
|
if(BUILD_DROGON_SHARED)
|
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
2020-03-21 08:40:25 +08:00
|
|
|
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}"
|
2020-01-25 11:58:20 +08:00
|
|
|
isSystemDir)
|
2019-12-12 12:49:18 +08:00
|
|
|
if("${isSystemDir}" STREQUAL "-1")
|
2020-03-21 08:40:25 +08:00
|
|
|
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}")
|
2019-12-12 12:49:18 +08:00
|
|
|
endif("${isSystemDir}" STREQUAL "-1")
|
|
|
|
add_library(${PROJECT_NAME} SHARED)
|
2020-02-29 15:46:08 +08:00
|
|
|
else(BUILD_DROGON_SHARED)
|
2019-12-12 12:49:18 +08:00
|
|
|
add_library(${PROJECT_NAME} STATIC)
|
2020-02-29 15:46:08 +08:00
|
|
|
endif(BUILD_DROGON_SHARED)
|
2019-12-12 12:49:18 +08:00
|
|
|
|
2019-07-26 22:22:12 +08:00
|
|
|
include(CheckIncludeFileCXX)
|
|
|
|
|
2019-08-31 08:27:57 +08:00
|
|
|
check_include_file_cxx(any HAS_ANY)
|
|
|
|
check_include_file_cxx(string_view HAS_STRING_VIEW)
|
2019-08-08 15:17:09 +08:00
|
|
|
if(HAS_ANY AND HAS_STRING_VIEW)
|
2019-08-31 08:27:57 +08:00
|
|
|
set(DROGON_CXX_STANDARD 17)
|
2020-02-29 15:46:08 +08:00
|
|
|
else(HAS_ANY AND HAS_STRING_VIEW)
|
2019-08-31 08:27:57 +08:00
|
|
|
set(DROGON_CXX_STANDARD 14)
|
2020-02-29 15:46:08 +08:00
|
|
|
endif(HAS_ANY AND HAS_STRING_VIEW)
|
2019-08-08 15:17:09 +08:00
|
|
|
|
2019-08-31 08:27:57 +08:00
|
|
|
target_include_directories(
|
|
|
|
${PROJECT_NAME}
|
|
|
|
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/lib/inc>
|
|
|
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/orm_lib/inc>
|
2019-09-16 10:10:23 +08:00
|
|
|
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
|
2020-02-22 21:15:15 +08:00
|
|
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/trantor>
|
|
|
|
$<INSTALL_INTERFACE:${INSTALL_INCLUDE_DIR}>)
|
2019-08-31 08:27:57 +08:00
|
|
|
|
2020-01-25 11:58:20 +08:00
|
|
|
if(WIN32)
|
|
|
|
target_include_directories(
|
|
|
|
${PROJECT_NAME}
|
|
|
|
PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third_party/mman-win32>)
|
|
|
|
endif(WIN32)
|
|
|
|
|
2019-08-31 08:27:57 +08:00
|
|
|
# set the include list for dynamic view compiling
|
2020-03-18 19:54:48 +08:00
|
|
|
# list(APPEND INCLUDE_DIRS_FOR_DYNAMIC_VIEW
|
|
|
|
# ${PROJECT_SOURCE_DIR}/lib/inc
|
|
|
|
# ${PROJECT_SOURCE_DIR}/orm_lib/inc
|
|
|
|
# ${PROJECT_SOURCE_DIR}/trantor)
|
2020-01-25 11:58:20 +08:00
|
|
|
|
2019-08-08 15:17:09 +08:00
|
|
|
add_subdirectory(trantor)
|
2019-08-31 08:27:57 +08:00
|
|
|
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC trantor)
|
|
|
|
|
2020-02-29 15:46:08 +08:00
|
|
|
if(NOT WIN32)
|
2020-01-25 11:58:20 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE dl)
|
2020-03-18 19:54:48 +08:00
|
|
|
else(NOT WIN32)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE shlwapi)
|
2020-02-29 15:46:08 +08:00
|
|
|
endif(NOT WIN32)
|
2019-08-08 15:17:09 +08:00
|
|
|
|
|
|
|
if(DROGON_CXX_STANDARD LESS 17)
|
2019-08-31 08:27:57 +08:00
|
|
|
# With C++14, use boost to support any and string_view
|
|
|
|
message(STATUS "use c++14")
|
|
|
|
find_package(Boost 1.61.0 REQUIRED)
|
2020-03-18 19:54:48 +08:00
|
|
|
message(STATUS "boost include dir:" ${Boost_INCLUDE_DIR})
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC Boost::boost)
|
|
|
|
list(APPEND INCLUDE_DIRS_FOR_DYNAMIC_VIEW ${Boost_INCLUDE_DIR})
|
2020-02-29 15:46:08 +08:00
|
|
|
else(DROGON_CXX_STANDARD LESS 17)
|
2019-08-31 08:27:57 +08:00
|
|
|
message(STATUS "use c++17")
|
2020-02-29 15:46:08 +08:00
|
|
|
endif(DROGON_CXX_STANDARD LESS 17)
|
2019-07-26 22:22:12 +08:00
|
|
|
|
2019-08-08 15:17:09 +08:00
|
|
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules/)
|
2019-03-27 19:32:09 +08:00
|
|
|
|
2019-08-31 08:27:57 +08:00
|
|
|
# jsoncpp
|
|
|
|
find_package(Jsoncpp REQUIRED)
|
2020-03-18 19:54:48 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC Jsoncpp_lib)
|
2019-08-31 08:27:57 +08:00
|
|
|
list(APPEND INCLUDE_DIRS_FOR_DYNAMIC_VIEW ${JSONCPP_INCLUDE_DIRS})
|
2019-08-08 15:17:09 +08:00
|
|
|
|
2020-01-25 11:58:20 +08:00
|
|
|
if(NOT WIN32)
|
|
|
|
find_package(UUID REQUIRED)
|
2020-03-18 19:54:48 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE PkgConfig::libuuid)
|
2020-01-25 11:58:20 +08:00
|
|
|
|
|
|
|
try_compile(normal_uuid ${CMAKE_BINARY_DIR}/cmaketest
|
|
|
|
${PROJECT_SOURCE_DIR}/cmake/tests/normal_uuid_lib_test.cc
|
2020-03-18 19:54:48 +08:00
|
|
|
LINK_LIBRARIES PkgConfig::libuuid)
|
2020-01-25 11:58:20 +08:00
|
|
|
try_compile(ossp_uuid ${CMAKE_BINARY_DIR}/cmaketest
|
|
|
|
${PROJECT_SOURCE_DIR}/cmake/tests/ossp_uuid_lib_test.cc
|
2020-03-18 19:54:48 +08:00
|
|
|
LINK_LIBRARIES PkgConfig::libuuid)
|
2020-01-25 11:58:20 +08:00
|
|
|
if(normal_uuid)
|
2019-12-09 17:22:38 +08:00
|
|
|
add_definitions(-DUSE_OSSP_UUID=0)
|
2020-01-25 11:58:20 +08:00
|
|
|
elseif(ossp_uuid)
|
2019-12-09 17:22:38 +08:00
|
|
|
add_definitions(-DUSE_OSSP_UUID=1)
|
2020-01-25 11:58:20 +08:00
|
|
|
else()
|
2019-12-09 17:22:38 +08:00
|
|
|
message(FATAL_ERROR "uuid lib error")
|
2020-01-25 11:58:20 +08:00
|
|
|
endif()
|
|
|
|
endif(NOT WIN32)
|
2019-08-31 08:27:57 +08:00
|
|
|
|
|
|
|
set(DROGON_SOURCES
|
|
|
|
lib/src/AOPAdvice.cc
|
|
|
|
lib/src/CacheFile.cc
|
|
|
|
lib/src/ConfigLoader.cc
|
|
|
|
lib/src/Cookie.cc
|
|
|
|
lib/src/DrClassMap.cc
|
|
|
|
lib/src/DrTemplateBase.cc
|
|
|
|
lib/src/FiltersFunction.cc
|
|
|
|
lib/src/HttpAppFrameworkImpl.cc
|
|
|
|
lib/src/HttpClientImpl.cc
|
|
|
|
lib/src/HttpControllersRouter.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/HttpSimpleControllersRouter.cc
|
|
|
|
lib/src/HttpUtils.cc
|
|
|
|
lib/src/HttpViewData.cc
|
|
|
|
lib/src/IntranetIpFilter.cc
|
|
|
|
lib/src/ListenerManager.cc
|
|
|
|
lib/src/LocalHostFilter.cc
|
|
|
|
lib/src/MultiPart.cc
|
|
|
|
lib/src/NotFound.cc
|
|
|
|
lib/src/PluginsManager.cc
|
2019-11-30 08:35:40 +08:00
|
|
|
lib/src/SecureSSLRedirector.cc
|
2019-08-31 08:27:57 +08:00
|
|
|
lib/src/SessionManager.cc
|
|
|
|
lib/src/StaticFileRouter.cc
|
|
|
|
lib/src/Utilities.cc
|
|
|
|
lib/src/WebSocketClientImpl.cc
|
|
|
|
lib/src/WebSocketConnectionImpl.cc
|
|
|
|
lib/src/WebsocketControllersRouter.cc)
|
|
|
|
|
2020-01-25 11:58:20 +08:00
|
|
|
if(NOT WIN32)
|
|
|
|
set(DROGON_SOURCES ${DROGON_SOURCES} lib/src/SharedLibManager.cc)
|
2020-02-29 15:46:08 +08:00
|
|
|
else(NOT WIN32)
|
|
|
|
set(DROGON_SOURCES ${DROGON_SOURCES} third_party/mman-win32/mman.c)
|
2020-01-25 11:58:20 +08:00
|
|
|
endif(NOT WIN32)
|
|
|
|
|
2019-08-08 15:17:09 +08:00
|
|
|
if(BUILD_ORM)
|
2019-08-31 08:27:57 +08:00
|
|
|
# find postgres
|
2020-03-18 19:54:48 +08:00
|
|
|
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)
|
2019-08-31 08:27:57 +08:00
|
|
|
set(DROGON_SOURCES ${DROGON_SOURCES}
|
|
|
|
orm_lib/src/postgresql_impl/PostgreSQLResultImpl.cc)
|
|
|
|
if(LIBPQ_BATCH_MODE)
|
|
|
|
try_compile(libpq_supports_batch ${CMAKE_BINARY_DIR}/cmaketest
|
|
|
|
${PROJECT_SOURCE_DIR}/cmake/tests/test_libpq_batch_mode.cc
|
|
|
|
LINK_LIBRARIES ${PostgreSQL_LIBRARIES}
|
|
|
|
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${PostgreSQL_INCLUDE_DIR}")
|
2020-02-29 15:46:08 +08:00
|
|
|
endif(LIBPQ_BATCH_MODE)
|
2019-08-31 08:27:57 +08:00
|
|
|
if(libpq_supports_batch)
|
|
|
|
message(STATUS "The libpq supports batch mode")
|
|
|
|
option(LIBPQ_SUPPORTS_BATCH_MODE "libpq batch mode" ON)
|
|
|
|
set(DROGON_SOURCES ${DROGON_SOURCES}
|
|
|
|
orm_lib/src/postgresql_impl/PgBatchConnection.cc)
|
2020-02-29 15:46:08 +08:00
|
|
|
else(libpq_supports_batch)
|
2019-08-31 08:27:57 +08:00
|
|
|
option(LIBPQ_SUPPORTS_BATCH_MODE "libpq batch mode" OFF)
|
|
|
|
set(DROGON_SOURCES ${DROGON_SOURCES}
|
|
|
|
orm_lib/src/postgresql_impl/PgConnection.cc)
|
2020-02-29 15:46:08 +08:00
|
|
|
endif(libpq_supports_batch)
|
2020-03-18 19:54:48 +08:00
|
|
|
endif(pg_FOUND)
|
2019-05-28 15:26:43 +08:00
|
|
|
|
2019-08-31 08:27:57 +08:00
|
|
|
# Find mysql, only mariadb client liberary is supported
|
|
|
|
find_package(MySQL)
|
2020-03-18 19:54:48 +08:00
|
|
|
if(MySQL_FOUND)
|
2020-01-25 11:58:20 +08:00
|
|
|
message(STATUS "Ok! We find the mariadb!")
|
2020-03-18 19:54:48 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE MySQL_lib)
|
2020-01-25 11:58:20 +08:00
|
|
|
set(DROGON_SOURCES ${DROGON_SOURCES}
|
|
|
|
orm_lib/src/mysql_impl/MysqlConnection.cc
|
|
|
|
orm_lib/src/mysql_impl/MysqlResultImpl.cc)
|
2020-03-18 19:54:48 +08:00
|
|
|
else(MySQL_FOUND)
|
2020-01-25 11:58:20 +08:00
|
|
|
if(MSVC)
|
|
|
|
find_package(ZLIB REQUIRED)
|
2020-03-18 19:54:48 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE ZLIB::ZLIB)
|
2020-01-25 11:58:20 +08:00
|
|
|
endif(MSVC)
|
2020-03-18 19:54:48 +08:00
|
|
|
endif(MySQL_FOUND)
|
2019-08-31 08:27:57 +08:00
|
|
|
|
|
|
|
# Find sqlite3.
|
|
|
|
find_package(SQLite3)
|
2020-03-18 19:54:48 +08:00
|
|
|
if(SQLite3_FOUND)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE SQLite3_lib)
|
2019-08-31 08:27:57 +08:00
|
|
|
set(DROGON_SOURCES ${DROGON_SOURCES}
|
|
|
|
orm_lib/src/sqlite3_impl/Sqlite3Connection.cc
|
|
|
|
orm_lib/src/sqlite3_impl/Sqlite3ResultImpl.cc)
|
2020-03-18 19:54:48 +08:00
|
|
|
endif(SQLite3_FOUND)
|
2020-02-29 15:46:08 +08:00
|
|
|
endif(BUILD_ORM)
|
|
|
|
|
|
|
|
if((NOT MSVC) OR (NOT BUILD_ORM))
|
|
|
|
find_package(ZLIB REQUIRED)
|
2020-03-18 19:54:48 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE ZLIB::ZLIB)
|
2020-02-29 15:46:08 +08:00
|
|
|
endif((NOT MSVC) OR (NOT BUILD_ORM))
|
|
|
|
|
|
|
|
find_package(OpenSSL)
|
|
|
|
if(OpenSSL_FOUND)
|
2020-03-18 19:54:48 +08:00
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE OpenSSL::SSL OpenSSL::Crypto)
|
2020-02-29 15:46:08 +08:00
|
|
|
else(OpenSSL_FOUND)
|
|
|
|
set(DROGON_SOURCES ${DROGON_SOURCES} lib/src/ssl_funcs/Md5.cc
|
|
|
|
lib/src/ssl_funcs/Sha1.cc)
|
|
|
|
endif(OpenSSL_FOUND)
|
2018-04-27 14:38:27 +08:00
|
|
|
|
2020-02-06 22:13:50 +08:00
|
|
|
execute_process(COMMAND "git" rev-parse HEAD
|
|
|
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
|
|
|
OUTPUT_VARIABLE GIT_SHA1
|
|
|
|
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
configure_file("${PROJECT_SOURCE_DIR}/cmake/templates/version.h.in"
|
|
|
|
"${PROJECT_SOURCE_DIR}/lib/inc/drogon/version.h" @ONLY)
|
2018-05-28 14:34:47 +08:00
|
|
|
|
2019-08-08 15:17:09 +08:00
|
|
|
if(BUILD_EXAMPLES)
|
2019-08-31 08:27:57 +08:00
|
|
|
add_subdirectory(examples)
|
2020-02-29 15:46:08 +08:00
|
|
|
endif(BUILD_EXAMPLES)
|
2019-07-26 22:22:12 +08:00
|
|
|
|
2019-08-08 15:17:09 +08:00
|
|
|
if(BUILD_CTL)
|
2019-08-31 08:27:57 +08:00
|
|
|
add_subdirectory(drogon_ctl)
|
2020-02-29 15:46:08 +08:00
|
|
|
endif(BUILD_CTL)
|
2019-07-26 22:22:12 +08:00
|
|
|
|
2020-03-18 19:54:48 +08:00
|
|
|
if(pg_FOUND OR MySQL_FOUND OR SQLite3_FOUND)
|
2019-08-31 08:27:57 +08:00
|
|
|
set(DROGON_SOURCES
|
|
|
|
${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/DbClientManager.cc
|
|
|
|
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
|
2019-09-30 21:34:30 +08:00
|
|
|
orm_lib/src/TransactionImpl.cc
|
|
|
|
orm_lib/src/RestfulController.cc)
|
2020-03-18 19:54:48 +08:00
|
|
|
else(pg_FOUND OR MySQL_FOUND OR SQLite3_FOUND)
|
2019-08-31 08:27:57 +08:00
|
|
|
set(DROGON_SOURCES ${DROGON_SOURCES} lib/src/DbClientManagerSkipped.cc)
|
2020-03-18 19:54:48 +08:00
|
|
|
endif(pg_FOUND OR MySQL_FOUND OR SQLite3_FOUND)
|
2019-07-26 22:22:12 +08:00
|
|
|
|
2019-08-31 08:27:57 +08:00
|
|
|
target_sources(${PROJECT_NAME} PRIVATE ${DROGON_SOURCES})
|
2019-07-26 22:22:12 +08:00
|
|
|
|
2019-11-30 08:35:40 +08:00
|
|
|
set_target_properties(${PROJECT_NAME}
|
|
|
|
PROPERTIES CXX_STANDARD ${DROGON_CXX_STANDARD})
|
2019-08-31 08:27:57 +08:00
|
|
|
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD_REQUIRED ON)
|
|
|
|
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_EXTENSIONS OFF)
|
2019-10-04 22:24:34 +08:00
|
|
|
set_target_properties(${PROJECT_NAME} PROPERTIES EXPORT_NAME Drogon)
|
2019-07-26 22:22:12 +08:00
|
|
|
|
2020-03-18 19:54:48 +08:00
|
|
|
if(pg_FOUND OR MySQL_FOUND OR SQLite3_FOUND)
|
|
|
|
if(pg_FOUND)
|
2019-08-31 08:27:57 +08:00
|
|
|
option(USE_POSTGRESQL "Enable PostgreSQL" ON)
|
2020-03-18 19:54:48 +08:00
|
|
|
else(pg_FOUND)
|
2019-08-31 08:27:57 +08:00
|
|
|
option(USE_POSTGRESQL "Disable PostgreSQL" OFF)
|
2020-03-18 19:54:48 +08:00
|
|
|
endif(pg_FOUND)
|
2019-07-26 22:22:12 +08:00
|
|
|
|
2020-03-18 19:54:48 +08:00
|
|
|
if(MySQL_FOUND)
|
2019-08-31 08:27:57 +08:00
|
|
|
option(USE_MYSQL "Enable Mysql" ON)
|
2020-03-18 19:54:48 +08:00
|
|
|
else(MySQL_FOUND)
|
2019-08-31 08:27:57 +08:00
|
|
|
option(USE_MYSQL "DisableMysql" OFF)
|
2020-03-18 19:54:48 +08:00
|
|
|
endif(MySQL_FOUND)
|
2019-07-26 22:22:12 +08:00
|
|
|
|
2020-03-18 19:54:48 +08:00
|
|
|
if(SQLite3_FOUND)
|
2019-08-31 08:27:57 +08:00
|
|
|
option(USE_SQLITE3 "Enable Sqlite3" ON)
|
2020-03-18 19:54:48 +08:00
|
|
|
else(SQLite3_FOUND)
|
2019-08-31 08:27:57 +08:00
|
|
|
option(USE_SQLITE3 "Disable Sqlite3" OFF)
|
2020-03-18 19:54:48 +08:00
|
|
|
endif(SQLite3_FOUND)
|
|
|
|
endif(pg_FOUND OR MySQL_FOUND OR SQLite3_FOUND)
|
2019-07-26 22:22:12 +08:00
|
|
|
|
2019-08-08 15:17:09 +08:00
|
|
|
set(COMPILER_COMMAND ${CMAKE_CXX_COMPILER})
|
|
|
|
set(COMPILER_ID ${CMAKE_CXX_COMPILER_ID})
|
2019-07-26 22:22:12 +08:00
|
|
|
|
2019-08-08 15:17:09 +08:00
|
|
|
if(CMAKE_BUILD_TYPE)
|
2019-08-31 08:27:57 +08:00
|
|
|
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()
|
2019-08-08 15:17:09 +08:00
|
|
|
set(COMPILATION_FLAGS "-std=c++")
|
2019-08-31 08:27:57 +08:00
|
|
|
endif()
|
2020-02-29 15:46:08 +08:00
|
|
|
else(CMAKE_BUILD_TYPE)
|
2019-08-31 08:27:57 +08:00
|
|
|
set(COMPILATION_FLAGS "-std=c++")
|
2020-02-29 15:46:08 +08:00
|
|
|
endif(CMAKE_BUILD_TYPE)
|
2019-08-08 15:17:09 +08:00
|
|
|
|
2020-03-18 19:54:48 +08:00
|
|
|
list(APPEND INCLUDE_DIRS_FOR_DYNAMIC_VIEW "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
|
2019-08-31 08:27:57 +08:00
|
|
|
list(REMOVE_DUPLICATES INCLUDE_DIRS_FOR_DYNAMIC_VIEW)
|
2019-08-08 15:17:09 +08:00
|
|
|
set(INS_STRING "")
|
2019-08-31 08:27:57 +08:00
|
|
|
foreach(loop_var ${INCLUDE_DIRS_FOR_DYNAMIC_VIEW})
|
|
|
|
set(INS_STRING "${INS_STRING} -I${loop_var}")
|
2019-08-08 15:17:09 +08:00
|
|
|
endforeach(loop_var)
|
|
|
|
|
|
|
|
set(INCLUDING_DIRS ${INS_STRING})
|
|
|
|
|
2019-08-31 08:27:57 +08:00
|
|
|
configure_file(${PROJECT_SOURCE_DIR}/cmake/templates/config.h.in
|
2019-08-08 15:17:09 +08:00
|
|
|
${PROJECT_BINARY_DIR}/drogon/config.h @ONLY)
|
2018-06-14 14:25:57 +08:00
|
|
|
|
2019-12-07 17:43:00 +08:00
|
|
|
if(BUILD_TESTING)
|
2019-08-31 08:27:57 +08:00
|
|
|
add_subdirectory(lib/tests)
|
2020-03-18 19:54:48 +08:00
|
|
|
if(pg_FOUND)
|
2019-08-31 08:27:57 +08:00
|
|
|
add_subdirectory(${PROJECT_SOURCE_DIR}/orm_lib/src/postgresql_impl/test)
|
|
|
|
add_subdirectory(${PROJECT_SOURCE_DIR}/orm_lib/tests)
|
2020-03-18 19:54:48 +08:00
|
|
|
endif(pg_FOUND)
|
|
|
|
if(MySQL_FOUND)
|
2019-08-31 08:27:57 +08:00
|
|
|
add_subdirectory(${PROJECT_SOURCE_DIR}/orm_lib/src/mysql_impl/test)
|
2020-03-18 19:54:48 +08:00
|
|
|
endif(MySQL_FOUND)
|
|
|
|
if(SQLite3_FOUND)
|
2019-08-31 08:27:57 +08:00
|
|
|
add_subdirectory(${PROJECT_SOURCE_DIR}/orm_lib/src/sqlite3_impl/test)
|
2020-03-18 19:54:48 +08:00
|
|
|
endif(SQLite3_FOUND)
|
2020-01-25 11:58:20 +08:00
|
|
|
find_package(GTest)
|
|
|
|
if(GTest_FOUND)
|
|
|
|
message(STATUS "gtest found")
|
|
|
|
enable_testing()
|
|
|
|
add_subdirectory(unittest)
|
|
|
|
endif(GTest_FOUND)
|
|
|
|
endif(BUILD_TESTING)
|
2018-05-04 09:51:12 +08:00
|
|
|
|
2019-08-31 08:27:57 +08:00
|
|
|
# Installation
|
2019-07-26 22:22:12 +08:00
|
|
|
|
2019-09-26 19:33:58 +08:00
|
|
|
install(TARGETS ${PROJECT_NAME}
|
2019-08-31 08:27:57 +08:00
|
|
|
EXPORT DrogonTargets
|
2019-12-11 18:39:10 +08:00
|
|
|
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib
|
|
|
|
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib)
|
2019-08-08 15:17:09 +08:00
|
|
|
|
2019-08-31 08:27:57 +08:00
|
|
|
set(DROGON_HEADERS
|
2019-09-28 21:48:06 +08:00
|
|
|
lib/inc/drogon/Attribute.h
|
2019-07-26 22:22:12 +08:00
|
|
|
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
|
|
|
|
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
|
2019-10-02 22:29:25 +08:00
|
|
|
lib/inc/drogon/IOThreadStorage.h
|
2019-07-26 22:22:12 +08:00
|
|
|
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
|
2019-08-15 20:59:16 +08:00
|
|
|
lib/inc/drogon/version.h
|
|
|
|
lib/inc/drogon/drogon_callbacks.h)
|
2019-08-08 15:17:09 +08:00
|
|
|
install(FILES ${DROGON_HEADERS} DESTINATION ${INSTALL_INCLUDE_DIR}/drogon)
|
2019-07-26 22:22:12 +08:00
|
|
|
|
2019-08-31 08:27:57 +08:00
|
|
|
set(ORM_HEADERS
|
2019-07-26 22:22:12 +08:00
|
|
|
orm_lib/inc/drogon/orm/ArrayParser.h
|
|
|
|
orm_lib/inc/drogon/orm/Criteria.h
|
|
|
|
orm_lib/inc/drogon/orm/DbClient.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
|
|
|
|
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
|
2019-09-30 21:34:30 +08:00
|
|
|
orm_lib/inc/drogon/orm/SqlBinder.h
|
|
|
|
orm_lib/inc/drogon/orm/RestfulController.h)
|
2019-08-08 15:17:09 +08:00
|
|
|
install(FILES ${ORM_HEADERS} DESTINATION ${INSTALL_INCLUDE_DIR}/drogon/orm)
|
2019-07-26 22:22:12 +08:00
|
|
|
|
2019-08-31 08:27:57 +08:00
|
|
|
set(DROGON_UTIL_HEADERS
|
2019-07-26 22:22:12 +08:00
|
|
|
lib/inc/drogon/utils/FunctionTraits.h
|
|
|
|
lib/inc/drogon/utils/Utilities.h
|
|
|
|
lib/inc/drogon/utils/any.h
|
|
|
|
lib/inc/drogon/utils/string_view.h
|
2020-01-01 16:15:11 +08:00
|
|
|
lib/inc/drogon/utils/HttpConstraint.h
|
|
|
|
lib/inc/drogon/utils/OStringStream.h)
|
2019-08-08 15:17:09 +08:00
|
|
|
install(FILES ${DROGON_UTIL_HEADERS}
|
|
|
|
DESTINATION ${INSTALL_INCLUDE_DIR}/drogon/utils)
|
|
|
|
|
2019-11-30 08:35:40 +08:00
|
|
|
set(DROGON_PLUGIN_HEADERS lib/inc/drogon/plugins/Plugin.h
|
|
|
|
lib/inc/drogon/plugins/SecureSSLRedirector.h)
|
2019-08-08 15:17:09 +08:00
|
|
|
install(FILES ${DROGON_PLUGIN_HEADERS}
|
|
|
|
DESTINATION ${INSTALL_INCLUDE_DIR}/drogon/plugins)
|
|
|
|
|
2019-08-31 08:27:57 +08:00
|
|
|
source_group("Public API"
|
|
|
|
FILES
|
|
|
|
${DROGON_HEADERS}
|
|
|
|
${ORM_HEADERS}
|
|
|
|
${DROGON_UTIL_HEADERS}
|
|
|
|
${DROGON_PLUGIN_HEADERS})
|
2019-08-08 15:17:09 +08:00
|
|
|
|
2019-08-31 08:27:57 +08: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 15:17:09 +08:00
|
|
|
|
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
# ... for the install tree
|
2019-08-31 08:27:57 +08:00
|
|
|
configure_package_config_file(
|
|
|
|
cmake/templates/DrogonConfig.cmake.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DrogonConfig.cmake
|
|
|
|
INSTALL_DESTINATION
|
|
|
|
${INSTALL_DROGON_CMAKE_DIR})
|
2019-08-08 15:17:09 +08:00
|
|
|
|
|
|
|
# version
|
2019-08-31 08:27:57 +08:00
|
|
|
write_basic_package_version_file(
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/DrogonConfigVersion.cmake
|
|
|
|
VERSION ${DROGON_VERSION}
|
|
|
|
COMPATIBILITY SameMajorVersion)
|
2019-08-08 15:17:09 +08:00
|
|
|
|
|
|
|
# Install the DrogonConfig.cmake and DrogonConfigVersion.cmake
|
2019-08-31 08:27:57 +08:00
|
|
|
install(
|
|
|
|
FILES "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DrogonConfig.cmake"
|
2019-08-08 15:17:09 +08:00
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/DrogonConfigVersion.cmake"
|
2020-03-18 19:54:48 +08:00
|
|
|
"${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"
|
2019-08-31 08:27:57 +08:00
|
|
|
DESTINATION "${INSTALL_DROGON_CMAKE_DIR}"
|
|
|
|
COMPONENT dev)
|
2019-08-08 15:17:09 +08:00
|
|
|
|
|
|
|
# Install the export set for use with the install-tree
|
2019-08-31 08:27:57 +08:00
|
|
|
install(EXPORT DrogonTargets
|
|
|
|
DESTINATION "${INSTALL_DROGON_CMAKE_DIR}"
|
2019-09-26 19:33:58 +08:00
|
|
|
NAMESPACE Drogon::
|
2019-08-08 15:17:09 +08:00
|
|
|
COMPONENT dev)
|