fileserver/CMakeLists.txt
Mutzi 3b211d1af6
Some checks failed
/ Build the server (push) Failing after 1m33s
Replaced restbed with beast
2024-04-23 15:38:41 +02:00

138 lines
3.9 KiB
CMake

cmake_minimum_required(VERSION 3.24)
project(fileserver)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
include(CPM.cmake)
CPMAddPackage("gh:gabime/spdlog#v1.13.0")
set(BOOST_LIBS
beast asio assert bind config container core endian
intrusive logic mp11 optional smart_ptr static_assert static_string
system throw_exception type_traits utility winapi
align context coroutine date_time move container_hash detail predef
variant2 io preprocessor pool exception algorithm lexical_cast numeric_conversion
range tokenizer describe integer tuple array concept_check
function regex unordered iterator mpl conversion function_types fusion typeof functional
)
foreach(BOOST_LIB ${BOOST_LIBS})
CPMAddPackage("gh:boostorg/${BOOST_LIB}#boost-1.85.0")
endforeach()
CPMAddPackage(
NAME uring
VERSION 2.5
GITHUB_REPOSITORY axboe/liburing
GIT_TAG liburing-2.5
DOWNLOAD_ONLY YES
)
if(uring_ADDED)
add_library(uring STATIC
${uring_SOURCE_DIR}/src/setup.c
${uring_SOURCE_DIR}/src/queue.c
${uring_SOURCE_DIR}/src/register.c
${uring_SOURCE_DIR}/src/syscall.c
${uring_SOURCE_DIR}/src/version.c
)
target_include_directories(uring PUBLIC ${uring_SOURCE_DIR}/src/include)
target_compile_definitions(uring PUBLIC BOOST_ASIO_HAS_IO_URING PRIVATE LIBURING_INTERNAL _LARGEFILE_SOURCE _FILE_OFFSET_BITS=64 _GNU_SOURCE)
endif()
set(BOTAN_MODULES argon2fmt hotp base32 auto_rng system_rng tls13 certstor_system certstor_flatfile md5 asio)
CPMAddPackage(
NAME botan
VERSION 3.4.0
GITHUB_REPOSITORY randombit/botan
GIT_TAG 3.4.0
DOWNLOAD_ONLY YES
)
if(botan_ADDED)
list(JOIN BOTAN_MODULES , BOTAN_MODULES_STR)
add_custom_command(
OUTPUT botan_all.cpp botan_all.h
COMMAND ${botan_SOURCE_DIR}/configure.py
--disable-shared
--amalgamation
--minimized-build
--without-documentation
--with-boost
--enable-modules=${BOTAN_MODULES_STR}
)
add_library(botan STATIC ${CMAKE_CURRENT_BINARY_DIR}/botan_all.cpp ${CMAKE_CURRENT_BINARY_DIR}/botan_all.h)
endif()
find_package(Threads REQUIRED)
#add_custom_command(
# COMMAND ./mrpc ARGS -n src/server/mrpc/fileserver -s cpp fileserver.rs
# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
# MAIN_DEPENDENCY fileserver.rs
# OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/src/server/mrpc/fileserver.cxx ${CMAKE_CURRENT_SOURCE_DIR}/src/server/mrpc/fileserver.hxx
#)
add_custom_command(
COMMAND sh ARGS -c 'xxd -i -n index_html ${CMAKE_CURRENT_SOURCE_DIR}/frontend/dist/index.html > index_html.h'
MAIN_DEPENDENCY frontend/dist/index.html
OUTPUT index_html.h
)
add_custom_command(
COMMAND sh ARGS -c 'xxd -i -n favicon_svg ${CMAKE_CURRENT_SOURCE_DIR}/frontend/dist/favicon.svg > favicon_svg.h'
MAIN_DEPENDENCY frontend/dist/favicon.svg
OUTPUT favicon_svg.h
)
add_executable(fileserver
src/server/mrpc/fileserver.hxx
src/server/mrpc/fileserver.cxx
src/util/crash.hxx
src/util/stb.cxx
src/util/miniz.hxx
src/util/miniz.cxx
src/util/boost.hxx
src/util/botan.hxx
src/data/data.hxx
src/data/data_internal.hxx
src/data/data.cxx
src/data/data_load.cxx
src/data/data_save.cxx
src/data/data_validate.cxx
src/server/server.hxx
src/server/server_internal.hxx
src/server/server.cxx
src/server/admin.cxx
src/server/auth.cxx
src/server/mail.cxx
src/server/fs.cxx
src/server/download.cxx
src/server/upload.cxx
src/main.cxx
index_html.h
favicon_svg.h
)
target_include_directories(fileserver PRIVATE include ${CMAKE_CURRENT_BINARY_DIR})
target_compile_options(fileserver PRIVATE -msse2)
target_compile_definitions(fileserver PRIVATE BOOST_BEAST_FILE_BUFFER_SIZE=65535)
target_link_options(fileserver PRIVATE -static)
target_link_libraries(fileserver PRIVATE
spdlog::spdlog
Boost::beast
botan
uring
Threads::Threads
)
install(TARGETS fileserver)