wormhole/CMakeLists.txt
nekobit a45c13f4b5 Fix response constructors
FossilOrigin-Name: c77f391407ef1d875a3c5c1c6fe54291b5fc14b3109f192350f8f7760abbb1ba
2022-10-07 00:54:49 +00:00

92 lines
2.6 KiB
CMake

cmake_minimum_required(VERSION 3.14)
project(wormhole)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(Module)
# files
add_executable(wormhole src/main.cpp
src/database/database.cpp
src/database/sqlite/sqlite.cpp
src/http/httpserver.cpp
src/http/microhttpd_server.cpp
src/http/request.cpp
src/http/response.cpp
src/http/mime.cpp
src/config/config_http.cpp
src/config/config_db.cpp
src/config/config_loader.cpp
src/config/config_helpers.cpp
src/logger.cpp)
target_compile_definitions(wormhole PRIVATE
CONFIG_DIR="${CONFIG_DIR}"
DATA_DIR="${DATA_DIR}")
# Modules
# Features that can be excluded can be added here
add_module(WEBFINGER)
add_subdirectory(src/protocol)
# General includes
include(CTest)
find_package(RapidJSON)
find_package(PkgConfig REQUIRED)
find_package(Threads REQUIRED)
find_package(SQLite3)
pkg_check_modules(LIBMICROHTTPD REQUIRED libmicrohttpd)
pkg_check_modules(YAML_CPP REQUIRED yaml-cpp)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# C++ settings
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
target_compile_options(wormhole PRIVATE -Wall -Wno-unused-function -Wno-reorder)
# Config directories definition
# TODO customizing
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message("Warning: Building in Debug mode... This is for development purposes only!\n")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
target_compile_options(wormhole PRIVATE -Wall -g)
enable_testing()
if(NOT DEFINED CONFIG_DIR)
message("CONFIG_DIR not set: Setting to empty")
set(CONFIG_DIR "." CACHE PATH "Config directory e.g. YAML files")
endif()
if(NOT DEFINED DATA_DIR)
message("DATA_DIR not set: Setting to \"data\"")
set(DATA_DIR "data" CACHE PATH "Data directory e.g. SQLite3 database")
endif()
else()
target_compile_options(wormhole PRIVATE -Wall -O2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
if(NOT DEFINED CONFIG_DIR)
message("CONFIG_DIR not set: Setting to \"/etc/wormhole/\"")
set(CONFIG_DIR "/etc/wormhole" CACHE PATH "Config directory e.g. YAML files")
endif()
if(NOT DEFINED DATA_DIR)
message("DATA_DIR not set: Setting to \"/usr/share/wormhole\"")
set(DATA_DIR "/usr/share/wormhole" CACHE PATH "Data directory e.g. SQLite3 database")
endif()
endif()
include_directories(wormhole
${LIBMICROHTTPD_INCLUDE_DIRS}
${YAML_CPP_INCLUDE_DIRS}
${SQLite3_INCLUDE_DIRS}
${RapidJSON_INCLUDE_DIRS}
src/
)
# automated tests
if(BUILD_TESTING)
add_subdirectory(test)
endif()
target_link_libraries(wormhole ${CMAKE_DL_LIBS}
${LIBMICROHTTPD_LIBRARIES}
${YAML_CPP_LIBRARIES}
${SQLite3_LIBRARIES}
${RapidJSON_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT})