fileserver/CMakeLists.txt

128 lines
3.5 KiB
CMake
Raw Normal View History

cmake_minimum_required(VERSION 3.24)
project(fileserver)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
2024-04-15 09:25:42 +00:00
include(CPM.cmake)
CPMAddPackage("gh:richgel999/miniz#3.0.2")
CPMAddPackage("gh:gabime/spdlog#v1.13.0")
CPMAddPackage(
NAME restbed
VERSION 4.8
GITHUB_REPOSITORY Corvusoft/restbed
GIT_TAG 4.8
DOWNLOAD_ONLY YES
)
CPMAddPackage(
NAME asio
VERSION 1.29.0
GITHUB_REPOSITORY chriskohlhoff/asio
GIT_TAG asio-1-29-0
DOWNLOAD_ONLY YES
)
if(asio_ADDED AND restbed_ADDED)
file(GLOB_RECURSE restbed_SOURCE "${restbed_SOURCE_DIR}/source/corvusoft/restbed/*.cpp")
add_library(restbed-static STATIC ${restbed_SOURCE} "${asio_SOURCE_DIR}/asio/src/asio.cpp")
target_compile_definitions(restbed-static PUBLIC ASIO_SEPARATE_COMPILATION)
target_include_directories(restbed-static PUBLIC "${restbed_SOURCE_DIR}/source" "${asio_SOURCE_DIR}/asio/include")
endif()
set(BOTAN_MODULES argon2fmt hotp base32 auto_rng system_rng tls13 certstor_system certstor_flatfile md5)
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
--enable-modules=${BOTAN_MODULES_STR}
)
add_library(botan STATIC ${CMAKE_CURRENT_BINARY_DIR}/botan_all.cpp ${CMAKE_CURRENT_BINARY_DIR}/botan_all.h)
endif()
#FetchContent_Declare(botan GIT_REPOSITORY https://gitea.mattv.de/root/cmake-libraries.git GIT_TAG origin/botan)
#FetchContent_MakeAvailable(botan)
#add_subdirectory(lib EXCLUDE_FROM_ALL)
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/logging.hxx
src/util/crash.hxx
src/util/timed_mutex.hxx
src/util/stb.cxx
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_link_options(fileserver PRIVATE -static)
2024-04-15 09:25:42 +00:00
target_link_libraries(fileserver PRIVATE
spdlog::spdlog
restbed-static
#Botan::Botan
botan
miniz
Threads::Threads
)
install(TARGETS fileserver)