f57708a0c9
FossilOrigin-Name: 4fde441d7ec8011e697a949b4e24b9e2f22abdfe44732e55411bd927abd62979
117 lines
3.4 KiB
CMake
117 lines
3.4 KiB
CMake
# Invocations
|
|
# cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ..
|
|
# cmake -DCMAKE_BUILD_TYPE=Debug ..
|
|
# cmake -DCMAKE_BUILD_TYPE=Release ..
|
|
|
|
cmake_minimum_required(VERSION 3.14)
|
|
project(wormhole
|
|
VERSION 0.0
|
|
DESCRIPTION "A lightweight federated social media server"
|
|
LANGUAGES CXX)
|
|
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
|
include(Module)
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
# C++ settings
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
add_compile_options(-Wall -Wno-reorder)
|
|
|
|
# Main executable of Wormhole
|
|
add_executable(wormhole ${PROJECT_SOURCE_DIR}/src/main.cpp)
|
|
|
|
# Separated as a library
|
|
set(SRC_FILES
|
|
${PROJECT_SOURCE_DIR}/src/jsonhelper.cpp
|
|
${PROJECT_SOURCE_DIR}/src/database/database_config.cpp
|
|
${PROJECT_SOURCE_DIR}/src/database/sqlite/sqlite.cpp
|
|
${PROJECT_SOURCE_DIR}/src/instance/instance.cpp
|
|
${PROJECT_SOURCE_DIR}/src/http/httpserver.cpp
|
|
${PROJECT_SOURCE_DIR}/src/http/microhttpd_server.cpp
|
|
${PROJECT_SOURCE_DIR}/src/http/request.cpp
|
|
${PROJECT_SOURCE_DIR}/src/http/response.cpp
|
|
${PROJECT_SOURCE_DIR}/src/http/mime.cpp
|
|
${PROJECT_SOURCE_DIR}/src/http/error_response.cpp
|
|
${PROJECT_SOURCE_DIR}/src/http/request_sender.cpp
|
|
${PROJECT_SOURCE_DIR}/src/crypt/rsa.cpp
|
|
${PROJECT_SOURCE_DIR}/src/config/config_http.cpp
|
|
${PROJECT_SOURCE_DIR}/src/config/config_db.cpp
|
|
${PROJECT_SOURCE_DIR}/src/config/config_loader.cpp
|
|
${PROJECT_SOURCE_DIR}/src/config/config_instance.cpp
|
|
${PROJECT_SOURCE_DIR}/src/config/config_frontend.cpp
|
|
${PROJECT_SOURCE_DIR}/src/types/user.cpp
|
|
${PROJECT_SOURCE_DIR}/src/types/app.cpp
|
|
${PROJECT_SOURCE_DIR}/src/thread_pool.cpp
|
|
${PROJECT_SOURCE_DIR}/src/random.cpp
|
|
${PROJECT_SOURCE_DIR}/src/control.cpp
|
|
${PROJECT_SOURCE_DIR}/src/logger.cpp)
|
|
|
|
add_library(wormhole_lib ${SRC_FILES})
|
|
|
|
# Modules
|
|
# Features that can be excluded can be added here
|
|
add_module(HOST_META)
|
|
add_module(WEBFINGER)
|
|
add_module(ACTIVITYPUB)
|
|
add_module(OAUTH)
|
|
add_module(MASTO_API)
|
|
add_module(FCGI)
|
|
|
|
# General includes
|
|
include(CTest)
|
|
|
|
find_package(RapidJSON)
|
|
find_package(CURL)
|
|
find_package(PkgConfig REQUIRED)
|
|
find_package(Threads REQUIRED)
|
|
find_package(SQLite3)
|
|
find_package(OpenSSL REQUIRED)
|
|
pkg_check_modules(LIBMICROHTTPD REQUIRED libmicrohttpd)
|
|
pkg_check_modules(YAML_CPP REQUIRED yaml-cpp)
|
|
|
|
# Config directories definition
|
|
# TODO customizing
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
message("Warning: Building in Debug mode... This is for development purposes only!\n")
|
|
add_compile_options(-Wall -g)
|
|
enable_testing()
|
|
else()
|
|
# Some asserts are in the code...
|
|
add_definitions(-DNDEBUG)
|
|
add_compile_options(-Wall -Wno-unused-function -Wno-reorder -O2)
|
|
endif()
|
|
|
|
set(WORMHOLE_INCLUDE_DIRS
|
|
${LIBMICROHTTPD_INCLUDE_DIRS}
|
|
${YAML_CPP_INCLUDE_DIRS}
|
|
${SQLite3_INCLUDE_DIRS}
|
|
${CURL_INCLUDE_DIRS}
|
|
${OPENSSL_INCLUDE_DIR}
|
|
${RAPIDJSON_INCLUDE_DIRS}
|
|
${PROJECT_SOURCE_DIR}/src/
|
|
CACHE INTERNAL "")
|
|
|
|
include_directories(wormhole ${WORMHOLE_INCLUDE_DIRS})
|
|
add_subdirectory(src/protocol)
|
|
add_subdirectory(src/frontends)
|
|
|
|
# automated tests
|
|
if(BUILD_TESTING)
|
|
add_subdirectory(test)
|
|
endif()
|
|
|
|
target_link_libraries(wormhole wormhole_lib
|
|
wormhole_webfinger_module
|
|
wormhole_activitypub_module
|
|
wormhole_host_meta_module
|
|
wormhole_oauth_module
|
|
wormhole_masto_api_module
|
|
wormhole_fcgi_module
|
|
${CMAKE_DL_LIBS}
|
|
${LIBMICROHTTPD_LIBRARIES}
|
|
${SQLite3_LIBRARIES}
|
|
${YAML_CPP_LIBRARIES}
|
|
${CURL_LIBRARIES}
|
|
${OPENSSL_CRYPTO_LIBRARIES}
|
|
${CMAKE_THREAD_LIBS_INIT}
|
|
)
|