Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add restinio package #503

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/configs/default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 21 additions & 0 deletions cmake/projects/restinio/ci/matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this file is needed. I thought there is a default matrix.json and this override is only needed if you need to change toolchains

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

restinio is not compatible with VS2015, hence me commenting it out. If there is a better way to do this, I'd be glad to hear.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it should not be needed

{ "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" }
]
24 changes: 24 additions & 0 deletions cmake/projects/restinio/hunter.cmake
Original file line number Diff line number Diff line change
@@ -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)
33 changes: 33 additions & 0 deletions docs/packages/pkg/restinio.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.. spelling::

restinio

.. index:: networking ; restinio

.. _pkg.restinio:

restinio
========

- `Official <https://github.com/Stiffstream/restinio>`__
- `Example <https://github.com/cpp-pm/hunter/blob/master/examples/restinio/CMakeLists.txt>`__

.. 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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dependencies are normally done by the hunterized package. The user of the package shouldn't need to specify dependencies by hand. Please hunterize restinio package instead following the documentation

https://hunter.readthedocs.io/en/latest/creating-new/create/cmake-dependencies.html

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As my comment in the docs notes, restinio is an INTERFACE library. Therefore, its cmake dependencies get exported with the target.

restinio is fully hunterised, see https://github.com/ned14/restinio/blob/master/CMakeLists.txt. This isn't the problem here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can still add dependencies through the Config.cmake.in template methods that we generally use, no? https://github.com/cpp-pm/basis_universal/blob/hunter-1.15-c4c0db7/cmake/Config.cmake.in for example

it is a header only library defined as an INTERFACE cmake target.
26 changes: 26 additions & 0 deletions examples/restinio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see remark above about hunter dependencies, please hnunterize the restinio package

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is fully hunterised.


hunter_add_package(restinio)
find_package(restinio CONFIG REQUIRED)

add_executable(foo foo.cpp)
target_link_libraries(foo PUBLIC restinio::restinio)
12 changes: 12 additions & 0 deletions examples/restinio/foo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <restinio/all.hpp>
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;
}