Split CMake components to libraries, import OpenSSL
FossilOrigin-Name: fc69966ec9877debf721b13592fe218090d57c92f967c4c0ec9f95f36aedfff5
This commit is contained in:
parent
c7825a6fa3
commit
2a06ffa86c
8 changed files with 72 additions and 20 deletions
|
@ -3,8 +3,11 @@ project(wormhole)
|
|||
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
include(Module)
|
||||
|
||||
# files
|
||||
add_executable(wormhole src/main.cpp
|
||||
# Main
|
||||
add_executable(wormhole src/main.cpp)
|
||||
|
||||
# Separated as a library
|
||||
add_library(wormhole_lib
|
||||
src/jsonhelper.cpp
|
||||
src/database/database.cpp
|
||||
src/database/sqlite/sqlite.cpp
|
||||
|
@ -21,15 +24,13 @@ add_executable(wormhole src/main.cpp
|
|||
src/config/config_instance.cpp
|
||||
src/logger.cpp)
|
||||
|
||||
target_compile_definitions(wormhole PRIVATE
|
||||
CONFIG_DIR="${CONFIG_DIR}"
|
||||
DATA_DIR="${DATA_DIR}")
|
||||
add_definitions(-DCONFIG_DIR="${CONFIG_DIR}"
|
||||
-DDATA_DIR="${DATA_DIR}")
|
||||
|
||||
# Modules
|
||||
# Features that can be excluded can be added here
|
||||
add_module(WEBFINGER)
|
||||
add_module(ACTIVITYPUB)
|
||||
add_subdirectory(src/protocol)
|
||||
|
||||
# General includes
|
||||
include(CTest)
|
||||
|
@ -38,6 +39,7 @@ find_package(RapidJSON)
|
|||
find_package(PkgConfig REQUIRED)
|
||||
find_package(Threads REQUIRED)
|
||||
find_package(SQLite3)
|
||||
find_package(OpenSSL)
|
||||
pkg_check_modules(LIBMICROHTTPD REQUIRED libmicrohttpd)
|
||||
pkg_check_modules(YAML_CPP REQUIRED yaml-cpp)
|
||||
|
||||
|
@ -45,13 +47,13 @@ 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)
|
||||
add_compile_options(-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")
|
||||
target_compile_options(wormhole PRIVATE -Wall -g)
|
||||
add_compile_options(-Wall -g)
|
||||
enable_testing()
|
||||
if(NOT DEFINED CONFIG_DIR)
|
||||
message("CONFIG_DIR not set: Setting to empty")
|
||||
|
@ -62,9 +64,9 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|||
set(DATA_DIR "data" CACHE PATH "Data directory e.g. SQLite3 database")
|
||||
endif()
|
||||
else()
|
||||
target_compile_options(wormhole PRIVATE -Wall -O2)
|
||||
# Some asserts are in the code...
|
||||
target_compile_definitions(wormhole PRIVATE NDEBUG)
|
||||
add_definitions(-DNDEBUG)
|
||||
add_compile_options(-Wall -Wno-used-function -Wno-reorder -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")
|
||||
|
@ -75,20 +77,26 @@ else()
|
|||
endif()
|
||||
endif()
|
||||
|
||||
include_directories(wormhole
|
||||
set(WORMHOLE_INCLUDE_DIRS
|
||||
${LIBMICROHTTPD_INCLUDE_DIRS}
|
||||
${YAML_CPP_INCLUDE_DIRS}
|
||||
${SQLite3_INCLUDE_DIRS}
|
||||
${RapidJSON_INCLUDE_DIRS}
|
||||
src/
|
||||
)
|
||||
${PROJECT_SOURCE_DIR}/src/
|
||||
CACHE INTERNAL "")
|
||||
|
||||
include_directories(wormhole ${WORMHOLE_INCLUDE_DIRS})
|
||||
add_subdirectory(src/protocol)
|
||||
|
||||
# automated tests
|
||||
if(BUILD_TESTING)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
target_link_libraries(wormhole ${CMAKE_DL_LIBS}
|
||||
target_link_libraries(wormhole wormhole_lib
|
||||
wormhole_webfinger_module
|
||||
wormhole_activitypub_module
|
||||
${CMAKE_DL_LIBS}
|
||||
${LIBMICROHTTPD_LIBRARIES}
|
||||
${YAML_CPP_LIBRARIES}
|
||||
${SQLite3_LIBRARIES}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
macro(add_module TheModule)
|
||||
message("-- Adding module ${TheModule}")
|
||||
set("MODULE_${TheModule}" ON)
|
||||
target_compile_definitions(wormhole PRIVATE
|
||||
MODULE_${TheModule})
|
||||
add_definitions(-DMODULE_${TheModule})
|
||||
endmacro()
|
||||
|
|
27
src/crypt/rsa.h
Normal file
27
src/crypt/rsa.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Wormhole - Federated social network
|
||||
* Copyright (C) 2022 Nekobit
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Crypt
|
||||
{
|
||||
namespace RSA
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -73,7 +73,7 @@ namespace HTTP
|
|||
* General usage is to compare against another request (with a function),
|
||||
* with call_if_match
|
||||
*/
|
||||
Request(Type type, const std::string req);
|
||||
Request(Type type, std::string req);
|
||||
~Request() = default;
|
||||
|
||||
/**
|
||||
|
@ -87,6 +87,7 @@ namespace HTTP
|
|||
* @param other To compare against
|
||||
*/
|
||||
bool operator==(const Request& other) const;
|
||||
inline bool operator!=(const Request& other) const { return !operator==(other); }
|
||||
|
||||
/**
|
||||
* Compares a request with another requests, and expands ':' to arguments
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
target_sources(wormhole PRIVATE
|
||||
add_library(wormhole_activitypub_module
|
||||
activitypub.cpp)
|
||||
include_directories(wormhole_webfinger_module ${WORMHOLE_INCLUDE_DIRS})
|
||||
target_link_libraries(wormhole_activitypub_module wormhole_lib)
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
target_sources(wormhole PRIVATE
|
||||
add_library(wormhole_webfinger_module
|
||||
webfinger.cpp)
|
||||
include_directories(wormhole_webfinger_module ${WORMHOLE_INCLUDE_DIRS})
|
||||
target_link_libraries(wormhole_webfinger_module wormhole_lib)
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
add_executable(request_test request_test.cpp)
|
||||
target_link_libraries(request_test wormhole_lib)
|
||||
add_test(NAME request_test COMMAND $<TARGET_FILE:request_test>)
|
||||
|
|
|
@ -1,8 +1,20 @@
|
|||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include "http/request.h"
|
||||
|
||||
using namespace HTTP;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "Test" << std::endl;
|
||||
Request request1{Request::Type::GET, "/test/:123/fast"};
|
||||
assert(( request1 == Request{Request::Type::GET, "/test/:123/fast"} ));
|
||||
assert(( request1 != Request{Request::Type::POST, "/test/:123/fast"} ));
|
||||
assert(( request1 != Request{Request::Type::GET, "/tes8203508/fast"} ));
|
||||
|
||||
Request request1_match1{Request::Type::GET, "/test/the_data123/fast"};
|
||||
Request request1_match2{Request::Type::GET, "/test/notthedata/fast"};
|
||||
assert(( (*request1.match_get_args(request1_match1))[0] == "the_data" ));
|
||||
assert(( request1.match_get_args(request1_match2) == std::nullopt ));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue