From e6761a1b2e80e170d7bfdbc756a64b0c82a8794d Mon Sep 17 00:00:00 2001 From: "Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)" Date: Tue, 4 Jan 2022 15:36:05 +0000 Subject: [PATCH] Add restinio --- cmake/configs/default.cmake | 1 + cmake/projects/restinio/ci/matrix.json | 21 ++++++++++++++++ cmake/projects/restinio/hunter.cmake | 24 +++++++++++++++++++ docs/packages/pkg/restinio.rst | 33 ++++++++++++++++++++++++++ examples/restinio/CMakeLists.txt | 26 ++++++++++++++++++++ examples/restinio/foo.cpp | 12 ++++++++++ 6 files changed, 117 insertions(+) create mode 100644 cmake/projects/restinio/ci/matrix.json create mode 100644 cmake/projects/restinio/hunter.cmake create mode 100644 docs/packages/pkg/restinio.rst create mode 100644 examples/restinio/CMakeLists.txt create mode 100644 examples/restinio/foo.cpp diff --git a/cmake/configs/default.cmake b/cmake/configs/default.cmake index 6d730eee1b..3bcc40d82a 100644 --- a/cmake/configs/default.cmake +++ b/cmake/configs/default.cmake @@ -478,6 +478,7 @@ hunter_default_version(re2 VERSION 2020.08.01) hunter_default_version(readline VERSION 6.3) hunter_default_version(recastnavigation VERSION 1.4-p0) hunter_default_version(renderproto VERSION 0.11.1) +hunter_default_version(restinio VERSION 0.6.14) hunter_default_version(rocksdb VERSION 6.15.2) hunter_default_version(ros VERSION 1.14.6-p0) hunter_default_version(ros_comm VERSION 1.14.3-p1) diff --git a/cmake/projects/restinio/ci/matrix.json b/cmake/projects/restinio/ci/matrix.json new file mode 100644 index 0000000000..7758ba7e5e --- /dev/null +++ b/cmake/projects/restinio/ci/matrix.json @@ -0,0 +1,21 @@ +[ +{ "example": "foo", "toolchain": "clang-cxx17", "os": "ubuntu-20.04", "python": "3.8", "script": "build.sh" }, +{ "example": "foo", "toolchain": "gcc-7-cxx17", "os": "ubuntu-20.04", "python": "3.8", "script": "build.sh" }, +{ "example": "foo", "toolchain": "gcc-8-cxx17-fpic", "os": "ubuntu-20.04", "python": "3.8", "script": "build.sh" }, +{ "example": "foo", "toolchain": "gcc-9-cxx17-fpic", "os": "ubuntu-20.04", "python": "3.8", "script": "build.sh" }, +{ "example": "foo", "toolchain": "android-ndk-r17-api-24-arm64-v8a-clang-libcxx14", "os": "ubuntu-20.04", "python": "3.8", "script": "build.sh" }, +{ "example": "foo", "toolchain": "analyze-cxx17", "os": "ubuntu-20.04", "python": "3.8", "script": "build.sh" }, +{ "example": "foo", "toolchain": "sanitize-address-cxx17", "os": "ubuntu-20.04", "python": "3.8", "script": "build.sh" }, +{ "example": "foo", "toolchain": "sanitize-leak-cxx17", "os": "ubuntu-20.04", "python": "3.8", "script": "build.sh" }, +{ "example": "foo", "toolchain": "sanitize-thread-cxx17", "os": "ubuntu-20.04", "python": "3.8", "script": "build.sh" }, +{ "example": "foo", "toolchain": "osx-10-15-make-cxx14", "os": "macos-10.15", "python": "3.8", "script": "build.sh" }, +{ "example": "foo", "toolchain": "osx-11-1-arch-universal2-cxx17", "os": "macos-10.15", "python": "3.8", "script": "build.sh" }, +{ "example": "foo", "toolchain": "ios-nocodesign-14-4-dep-10-0-arm64", "os": "macos-10.15", "python": "3.8", "script": "build.sh" }, +{ "example": "foo", "toolchain": "ninja-vs-15-2017-win64-cxx17", "os": "windows-2016", "python": "3.8", "script": "build.cmd" }, +{ "example": "foo", "toolchain": "nmake-vs-15-2017-win64-cxx17", "os": "windows-2016", "python": "3.8", "script": "build.cmd" }, +{ "example": "foo", "toolchain": "vs-16-2019-win64-sdk-10-0-18362-0-cxx17", "os": "windows-2019", "python": "3.8", "script": "build.cmd" }, +{ "example": "foo", "toolchain": "vs-15-2017-win64-cxx17", "os": "windows-2016", "python": "3.8", "script": "build.cmd" }, +// { "example": "foo", "toolchain": "vs-14-2015-sdk-8-1", "os": "windows-2016", "python": "3.8", "script": "build.cmd" }, +{ "example": "foo", "toolchain": "mingw-cxx17", "os": "windows-2016", "python": "3.8", "script": "build.cmd" }, +{ "example": "foo", "toolchain": "msys-cxx17", "os": "windows-2016", "python": "3.8", "script": "build.cmd" } +] \ No newline at end of file diff --git a/cmake/projects/restinio/hunter.cmake b/cmake/projects/restinio/hunter.cmake new file mode 100644 index 0000000000..ff46588ecf --- /dev/null +++ b/cmake/projects/restinio/hunter.cmake @@ -0,0 +1,24 @@ +# Copyright (c) 2021 Niall Douglas https://www.nedproductions.biz/ +# All rights reserved. + +# !!! DO NOT PLACE HEADER GUARDS HERE !!! + +include(hunter_add_version) +include(hunter_cacheable) +include(hunter_download) +include(hunter_pick_scheme) + +hunter_add_version( + PACKAGE_NAME + restinio + VERSION + 0.6.14 + URL + "https://github.com/cpp-pm/restinio/archive/0.6.14-hunter.tar.gz" + SHA1 + 9d74b30969162a4506a7f516105a9404cafd6fc5 +) + +hunter_pick_scheme(DEFAULT url_sha1_cmake) +hunter_cacheable(restinio) +hunter_download(PACKAGE_NAME restinio) diff --git a/docs/packages/pkg/restinio.rst b/docs/packages/pkg/restinio.rst new file mode 100644 index 0000000000..df39d6304a --- /dev/null +++ b/docs/packages/pkg/restinio.rst @@ -0,0 +1,33 @@ +.. spelling:: + + restinio + +.. index:: networking ; restinio + +.. _pkg.restinio: + +restinio +======== + +- `Official `__ +- `Example `__ + +.. code-block:: cmake + + find_package(Threads REQUIRED) + + hunter_add_package(asio) + find_package(asio CONFIG REQUIRED) + + hunter_add_package(http-parser) + find_package(http-parser CONFIG REQUIRED) + + hunter_add_package(fmt) + find_package(fmt CONFIG REQUIRED) + + hunter_add_package(restinio) + find_package(restinio CONFIG REQUIRED) + target_link_libraries(... restinio::restinio) + +The reason you must manually bring in restinio's dependencies is because +it is a header only library defined as an INTERFACE cmake target. diff --git a/examples/restinio/CMakeLists.txt b/examples/restinio/CMakeLists.txt new file mode 100644 index 0000000000..3759923459 --- /dev/null +++ b/examples/restinio/CMakeLists.txt @@ -0,0 +1,26 @@ +# Copyright (c) 2021 Niall Douglas +# All rights reserved. + +cmake_minimum_required(VERSION 3.0) + +# Emulate HunterGate: +# * https://github.com/cpp-pm/gate +include("../common.cmake") + +project(download-restinio) +find_package(Threads REQUIRED) + +hunter_add_package(asio) +find_package(asio CONFIG REQUIRED) + +hunter_add_package(http-parser) +find_package(http-parser CONFIG REQUIRED) + +hunter_add_package(fmt) +find_package(fmt CONFIG REQUIRED) + +hunter_add_package(restinio) +find_package(restinio CONFIG REQUIRED) + +add_executable(foo foo.cpp) +target_link_libraries(foo PUBLIC restinio::restinio) diff --git a/examples/restinio/foo.cpp b/examples/restinio/foo.cpp new file mode 100644 index 0000000000..83f1dfd62c --- /dev/null +++ b/examples/restinio/foo.cpp @@ -0,0 +1,12 @@ +#include +int main() +{ + restinio::run( + restinio::on_this_thread() + .port(8080) + .address("localhost") + .request_handler([](auto req) { + return req->create_response().set_body("Hello, World!").done(); + })); + return 0; +}