From 21aff33f4f194148f768cce28a7ef9c827af29e9 Mon Sep 17 00:00:00 2001 From: Michael Jurkoic Date: Tue, 23 Apr 2024 10:25:27 -0500 Subject: Begin switching to FetchContent for deps --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index 4445cee..07ef788 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,16 @@ # NostrSDK + C++ System Development Kit for Nostr + +## Building the SDK + +### Prerequisites + +- CMake 3.14 or later +- C++17 compiler +- OpenSSL 1.1.1 or later +- Boost 1.85 or later + +### Standalone Build + +When building this library as a standalone project, the `Boost_INCLUDE_DIR` and `OPENSSL_ROOT_DIR` variables must be set at the CMake configuration step. -- cgit From 047a45bd2e3bda3456c1365115d67847d43dd9f1 Mon Sep 17 00:00:00 2001 From: Michael Jurkoic Date: Sun, 28 Apr 2024 09:56:06 -0500 Subject: Configure for Linux builds - Use vcpkg for most dependency management. - Manually include uuid_v4. - Update README with prerequisites and build instructions. - Support subproject and standalone builds. --- .gitignore | 5 ++++- CMakeLists.txt | 56 +++++++++++++++++---------------------------------- CMakePresets.json | 8 ++++---- README.md | 20 +++++++++++++----- include/nostr.hpp | 7 +++++-- src/nostr_service.cpp | 9 --------- 6 files changed, 46 insertions(+), 59 deletions(-) (limited to 'README.md') diff --git a/.gitignore b/.gitignore index efb998a..6623964 100644 --- a/.gitignore +++ b/.gitignore @@ -40,8 +40,11 @@ build/ # CMake outputs _deps/ CMakeFiles/ +out/ Makefile CTestTestfile.cmake CMakeCache.txt cmake_install.cmake -OpenSSL-prefix + +# vcpkg +vcpkg_installed/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 208265a..4c521c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.19) cmake_policy(SET CMP0135 NEW) -project(NostrSDK VERSION 0.0.1) +project(NostrSDK VERSION 0.1.0) include(ExternalProject) include(FetchContent) @@ -9,8 +9,6 @@ include(FetchContent) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -list(APPEND CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/_deps) - get_directory_property(HAS_PARENT PARENT_DIRECTORY) if(HAS_PARENT) message(STATUS "Configuring as a subproject.") @@ -20,52 +18,36 @@ if(HAS_PARENT) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../out/${CMAKE_BUILD_TYPE}/lib/) set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/../env/) - set(Boost_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/../env/boost/include) + if(DEFINED ENV{WORKSPACE}) + list(APPEND CMAKE_PREFIX_PATH $ENV{WORKSPACE}/env) + else() + list(APPEND CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/../env) + endif() else() message(STATUS "Configuring as a standalone project.") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}/bin/) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}/lib/) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}/lib/) - - set(OPENSSL_INCLUDE_DIR ${OPENSSL_ROOT_DIR}/include/) - set(OPENSSL_LIBRARIES ${OPENSSL_ROOT_DIR}/lib/) -endif() - -if(DEFINED ENV{WORKSPACE}) - list(APPEND CMAKE_PREFIX_PATH $ENV{WORKSPACE}/env) -else() - list(APPEND CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/../env) endif() -#======== Find unmanaged dependencies ========# +#======== Find dependencies ========# +find_package(nlohmann_json CONFIG REQUIRED) find_package(OpenSSL REQUIRED) -find_package(Boost REQUIRED COMPONENTS filesystem system thread regex) +find_package(plog CONFIG REQUIRED) +find_package(websocketpp CONFIG REQUIRED) -#======== Fetch header-only dependencies ========# -FetchContent_Declare( - nlohmann_json - URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz - URL_HASH SHA256=d6c65aca6b1ed68e7a182f4757257b107ae403032760ed6ef121c9d55e81757d - USES_TERMINAL_DOWNLOAD TRUE -) -FetchContent_Declare( - plog - URL https://github.com/SergiusTheBest/plog/archive/refs/tags/1.1.10.tar.gz - USES_TERMINAL_DOWNLOAD TRUE -) -FetchContent_Declare( - websocketpp - GIT_REPOSITORY git@github.com:zaphoyd/websocketpp.git - GIT_TAG 0.8.2 -) +#======== Configure uuid_v4 ========# FetchContent_Declare( uuid_v4 - URL https://github.com/crashoz/uuid_v4/archive/refs/tags/v1.0.0.tar.gz - USES_TERMINAL_DOWNLOAD TRUE + GIT_REPOSITORY git@github.com:crashoz/uuid_v4.git + GIT_TAG v1.0.0 ) +FetchContent_Populate(uuid_v4) +set(uuid_v4_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/_deps/uuid_v4-src/) -FetchContent_MakeAvailable(nlohmann_json plog uuid_v4 websocketpp) +find_path(uuid_v4_INCLUDE_DIR uuid_v4.h) +include_directories(${uuid_v4_INCLUDE_DIR}) #======== Build the project ========# set(INCLUDE_DIR ./include) @@ -93,7 +75,6 @@ target_link_libraries(NostrSDK PRIVATE OpenSSL::SSL OpenSSL::Crypto plog::plog - uuid_v4::uuid_v4 websocketpp::websocketpp ) set_target_properties(NostrSDK PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS YES) @@ -124,7 +105,6 @@ target_link_libraries(NostrSDKTest PRIVATE GTest::gtest_main NostrSDK plog::plog - uuid_v4::uuid_v4 websocketpp::websocketpp ) set_target_properties(NostrSDKTest PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS YES) diff --git a/CMakePresets.json b/CMakePresets.json index 8c57178..3e327f5 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -2,12 +2,12 @@ "version": 2, "configurePresets": [ { - "name": "default", - "generator": "Ninja", - "binaryDir": "${sourceDir}/build", + "name": "linux", + "generator": "Unix Makefiles", + "binaryDir": "${sourceDir}/build/linux", "cacheVariables": { "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" } } ] - } \ No newline at end of file + } diff --git a/README.md b/README.md index 07ef788..b38e83f 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,21 @@ C++ System Development Kit for Nostr ### Prerequisites -- CMake 3.14 or later +This project uses CMake as its build system, and vcpkg as its dependency manager. Thus, to build the SDK, you will need the following: + +- CMake 3.19 or later - C++17 compiler -- OpenSSL 1.1.1 or later -- Boost 1.85 or later +- vcpkg + +### Build Targets + +The SDK aims to support Linux, Windows, and macOS build targets. CMake presets are provided for each target. + +#### Linux -### Standalone Build +To build the SDK on Linux, run the following commands from the project root: -When building this library as a standalone project, the `Boost_INCLUDE_DIR` and `OPENSSL_ROOT_DIR` variables must be set at the CMake configuration step. +```bash +cmake --preset=linux . +cmake --build ./build/linux +``` diff --git a/include/nostr.hpp b/include/nostr.hpp index d6d5de1..dab4d71 100644 --- a/include/nostr.hpp +++ b/include/nostr.hpp @@ -1,18 +1,21 @@ #pragma once +#include #include #include #include #include +#include #include +#include #include #include - -#include +#include #include #include #include +#include #include "client/web_socket_client.hpp" diff --git a/src/nostr_service.cpp b/src/nostr_service.cpp index de40180..f8565cc 100644 --- a/src/nostr_service.cpp +++ b/src/nostr_service.cpp @@ -1,12 +1,3 @@ -#include - -#include -#include -#include -#include -#include -#include - #include "nostr.hpp" #include "client/web_socket_client.hpp" -- cgit From 2f5c62d0ef2c31366fd2295184aa97e6f07e4ddd Mon Sep 17 00:00:00 2001 From: buttercat1791 Date: Sun, 28 Apr 2024 12:39:35 -0500 Subject: README instructions for testing --- .gitignore | 1 + README.md | 8 +++++++- vcpkg-configuration.json | 28 ++++++++++++++-------------- 3 files changed, 22 insertions(+), 15 deletions(-) (limited to 'README.md') diff --git a/.gitignore b/.gitignore index 6623964..5cf2f9a 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,7 @@ build/ _deps/ CMakeFiles/ out/ +Testing/ Makefile CTestTestfile.cmake CMakeCache.txt diff --git a/README.md b/README.md index b38e83f..de4d3ad 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ This project uses CMake as its build system, and vcpkg as its dependency manager - C++17 compiler - vcpkg -### Build Targets +### Building and Testing The SDK aims to support Linux, Windows, and macOS build targets. CMake presets are provided for each target. @@ -24,3 +24,9 @@ To build the SDK on Linux, run the following commands from the project root: cmake --preset=linux . cmake --build ./build/linux ``` + +To run unit tests, use the following command: + +```bash +ctest ./build/linux +``` diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json index 850abfe..4b6ae85 100644 --- a/vcpkg-configuration.json +++ b/vcpkg-configuration.json @@ -1,14 +1,14 @@ -{ - "default-registry": { - "kind": "git", - "baseline": "582a4de14bef91df217f4f49624cf5b2b04bd7ca", - "repository": "https://github.com/microsoft/vcpkg" - }, - "registries": [ - { - "kind": "artifact", - "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", - "name": "microsoft" - } - ] -} +{ + "default-registry": { + "kind": "git", + "baseline": "582a4de14bef91df217f4f49624cf5b2b04bd7ca", + "repository": "https://github.com/microsoft/vcpkg" + }, + "registries": [ + { + "kind": "artifact", + "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", + "name": "microsoft" + } + ] +} -- cgit From b05e6adca19038f2d4efdd41df030a890344ef5a Mon Sep 17 00:00:00 2001 From: Michael Jurkoic Date: Tue, 30 Apr 2024 00:19:21 -0500 Subject: Rename project to 'aedile' --- CMakeLists.txt | 18 +++++++++--------- README.md | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'README.md') diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c521c8..2ed34df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.19) cmake_policy(SET CMP0135 NEW) -project(NostrSDK VERSION 0.1.0) +project(aedile VERSION 0.0.2) include(ExternalProject) include(FetchContent) @@ -69,15 +69,15 @@ set(SOURCES ${CLIENT_SOURCE_DIR}/websocketpp_client.cpp ) -add_library(NostrSDK ${SOURCES} ${HEADERS}) -target_link_libraries(NostrSDK PRIVATE +add_library(aedile ${SOURCES} ${HEADERS}) +target_link_libraries(aedile PRIVATE nlohmann_json::nlohmann_json OpenSSL::SSL OpenSSL::Crypto plog::plog websocketpp::websocketpp ) -set_target_properties(NostrSDK PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS YES) +set_target_properties(aedile PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS YES) #======== Build the tests ========# enable_testing() @@ -98,15 +98,15 @@ set(TEST_SOURCES ${TEST_DIR}/nostr_service_test.cpp ) -add_executable(NostrSDKTest ${TEST_SOURCES} ${HEADERS}) -target_link_libraries(NostrSDKTest PRIVATE +add_executable(aedile_test ${TEST_SOURCES} ${HEADERS}) +target_link_libraries(aedile_test PRIVATE GTest::gmock GTest::gtest GTest::gtest_main - NostrSDK + aedile plog::plog websocketpp::websocketpp ) -set_target_properties(NostrSDKTest PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS YES) +set_target_properties(aedile_test PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS YES) -gtest_add_tests(TARGET NostrSDKTest) +gtest_add_tests(TARGET aedile_test) diff --git a/README.md b/README.md index de4d3ad..8388da6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# NostrSDK +# Aedile C++ System Development Kit for Nostr -- cgit From 1291f9b045adfea3279cc26531b5d13164ca1bd8 Mon Sep 17 00:00:00 2001 From: Michael Jurkoic Date: Tue, 30 Apr 2024 00:20:33 -0500 Subject: Give example commands for build and test --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 8388da6..f186fe2 100644 --- a/README.md +++ b/README.md @@ -21,12 +21,12 @@ The SDK aims to support Linux, Windows, and macOS build targets. CMake presets To build the SDK on Linux, run the following commands from the project root: ```bash -cmake --preset=linux . -cmake --build ./build/linux +cmake --preset linux +cmake --build --preset linux ``` To run unit tests, use the following command: ```bash -ctest ./build/linux +ctest --preset linux ``` -- cgit From 80885e4f6b83a3a63b9a74640a13a66cc27d7933 Mon Sep 17 00:00:00 2001 From: buttercat1791 Date: Mon, 6 May 2024 09:04:57 -0500 Subject: Add details to README --- README.md | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index f186fe2..e9189dc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,16 @@ # Aedile -C++ System Development Kit for Nostr +A Nostr System Development Kit written in C++. + +## Behind the Name + +In the ancient Roman Republic, the aediles were officials elected from among the plebians and charged with caring for Rome's public infrastructure and ensuring an accurate system of weights and measures. + +The aim of the Aedile SDK is in the spirit of that ancient office: + +- Provide a fast and efficient service for interacting with Nostr relays via WebSocket connections. +- Offer stable, well-tested implementations of commonly-used [Nostr Implementation Possibilities (NIPs)](https://github.com/nostr-protocol/nips/tree/master). +- Open up Nostr development by taking care of the basics so developers can focus on solving problems, rather than reimplementing the protocol. ## Building the SDK @@ -9,19 +19,20 @@ C++ System Development Kit for Nostr This project uses CMake as its build system, and vcpkg as its dependency manager. Thus, to build the SDK, you will need the following: - CMake 3.19 or later -- C++17 compiler +- A C++17 compiler - vcpkg +CMake invokes vcpkg at the start of the configure process to install some of the project's dependencies. For this step to succeed, ensure that the `VCPKG_ROOT` environment variable is set to the path of your vcpkg installation. + ### Building and Testing -The SDK aims to support Linux, Windows, and macOS build targets. CMake presets are provided for each target. +The SDK aims to support Linux, Windows, and macOS build targets. It currently supplies a CMake preset for Linux. #### Linux To build the SDK on Linux, run the following commands from the project root: ```bash -cmake --preset linux cmake --build --preset linux ``` -- cgit