132 lines
No EOL
3.6 KiB
CMake
132 lines
No EOL
3.6 KiB
CMake
cmake_minimum_required(VERSION 3.20)
|
|
project(streaming-backend)
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
# Use pkg-config to find libraries
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
# Find dependencies
|
|
find_package(Drogon CONFIG REQUIRED)
|
|
find_package(PostgreSQL REQUIRED)
|
|
|
|
# Find Redis dependencies
|
|
pkg_check_modules(HIREDIS REQUIRED hiredis)
|
|
pkg_check_modules(REDIS_PLUS_PLUS redis++)
|
|
|
|
# Find libzip for EPUB cover extraction
|
|
pkg_check_modules(LIBZIP REQUIRED libzip)
|
|
|
|
# Find GPGME for PGP signature verification
|
|
pkg_check_modules(GPGME REQUIRED gpgme)
|
|
|
|
# Find OpenSSL for cryptographic operations (SECURITY FIX #4)
|
|
find_package(OpenSSL REQUIRED)
|
|
|
|
# Manual fallback for redis++
|
|
if(NOT REDIS_PLUS_PLUS_FOUND)
|
|
find_path(REDIS_PLUS_PLUS_INCLUDE_DIR sw/redis++/redis++.h
|
|
PATHS /usr/local/include /usr/include
|
|
)
|
|
find_library(REDIS_PLUS_PLUS_LIBRARY redis++
|
|
PATHS /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu
|
|
)
|
|
|
|
if(REDIS_PLUS_PLUS_INCLUDE_DIR AND REDIS_PLUS_PLUS_LIBRARY)
|
|
set(REDIS_PLUS_PLUS_FOUND TRUE)
|
|
set(REDIS_PLUS_PLUS_INCLUDE_DIRS ${REDIS_PLUS_PLUS_INCLUDE_DIR})
|
|
set(REDIS_PLUS_PLUS_LIBRARIES ${REDIS_PLUS_PLUS_LIBRARY})
|
|
else()
|
|
message(FATAL_ERROR "redis++ not found")
|
|
endif()
|
|
endif()
|
|
|
|
# Find bcrypt library
|
|
find_path(BCRYPT_INCLUDE_DIR bcrypt/BCrypt.hpp
|
|
PATHS /usr/local/include /usr/include
|
|
)
|
|
find_library(BCRYPT_LIBRARY bcrypt
|
|
PATHS /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu
|
|
)
|
|
|
|
if(NOT BCRYPT_INCLUDE_DIR OR NOT BCRYPT_LIBRARY)
|
|
message(FATAL_ERROR "bcrypt not found")
|
|
endif()
|
|
|
|
# Find jwt-cpp (header-only)
|
|
find_path(JWT_CPP_INCLUDE_DIR jwt-cpp/jwt.h
|
|
PATHS /usr/local/include /usr/include
|
|
)
|
|
|
|
if(NOT JWT_CPP_INCLUDE_DIR)
|
|
message(FATAL_ERROR "jwt-cpp not found")
|
|
endif()
|
|
|
|
# Source files
|
|
set(SOURCES
|
|
src/main.cpp
|
|
src/controllers/StreamController.cpp
|
|
src/controllers/UserController.cpp
|
|
src/controllers/AdminController.cpp
|
|
src/controllers/RealmController.cpp
|
|
src/controllers/RestreamController.cpp
|
|
src/controllers/VideoController.cpp
|
|
src/controllers/AudioController.cpp
|
|
src/controllers/EbookController.cpp
|
|
src/controllers/ForumController.cpp
|
|
src/controllers/WatchController.cpp
|
|
src/services/DatabaseService.cpp
|
|
src/services/StatsService.cpp
|
|
src/services/RedisHelper.cpp
|
|
src/services/AuthService.cpp
|
|
src/services/RestreamService.cpp
|
|
src/services/CensorService.cpp
|
|
src/services/TreasuryService.cpp
|
|
)
|
|
|
|
# Create executable
|
|
add_executable(${PROJECT_NAME} ${SOURCES})
|
|
|
|
# Include directories
|
|
target_include_directories(${PROJECT_NAME}
|
|
PRIVATE
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src
|
|
${BCRYPT_INCLUDE_DIR}
|
|
${JWT_CPP_INCLUDE_DIR}
|
|
SYSTEM PRIVATE
|
|
${HIREDIS_INCLUDE_DIRS}
|
|
${REDIS_PLUS_PLUS_INCLUDE_DIRS}
|
|
${LIBZIP_INCLUDE_DIRS}
|
|
${GPGME_INCLUDE_DIRS}
|
|
)
|
|
|
|
# Link libraries
|
|
target_link_libraries(${PROJECT_NAME}
|
|
PRIVATE
|
|
Drogon::Drogon
|
|
PostgreSQL::PostgreSQL
|
|
${REDIS_PLUS_PLUS_LIBRARIES}
|
|
${HIREDIS_LIBRARIES}
|
|
${BCRYPT_LIBRARY}
|
|
${LIBZIP_LIBRARIES}
|
|
${GPGME_LIBRARIES}
|
|
OpenSSL::SSL
|
|
OpenSSL::Crypto
|
|
pthread
|
|
)
|
|
|
|
# Compile options
|
|
target_compile_options(${PROJECT_NAME}
|
|
PRIVATE
|
|
${HIREDIS_CFLAGS_OTHER}
|
|
${REDIS_PLUS_PLUS_CFLAGS_OTHER}
|
|
${GPGME_CFLAGS_OTHER}
|
|
-Wall
|
|
-Wextra
|
|
-Wpedantic
|
|
-Wno-pedantic # Suppress pedantic warnings from third-party headers
|
|
)
|
|
# Build admin tool
|
|
add_executable(admin-tool src/admin_tool.cpp)
|
|
target_link_libraries(admin-tool PRIVATE Drogon::Drogon PostgreSQL::PostgreSQL) |