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 new package redis++ including hiredis #641

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
4 changes: 3 additions & 1 deletion cmake/configs/default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ endif()

hunter_default_version(HalideIR VERSION 0.0-32057b5-p0)
hunter_default_version(HastyNoise VERSION 0.8.3)
hunter_default_version(HiRedis VERSION 1.1.0)
hunter_default_version(ICU VERSION 63.1-p5)
hunter_default_version(IF97 VERSION 2.1.2)
hunter_default_version(Igloo VERSION 1.1.1-hunter)
Expand Down Expand Up @@ -142,6 +143,7 @@ hunter_default_version(QtQmlManager VERSION 1.0.0)
hunter_default_version(Qwt VERSION 6.1-p3)
hunter_default_version(RapidJSON VERSION 1.1.0-b557259-p0)
hunter_default_version(RapidXML VERSION 1.13)
hunter_default_version(Redis++ VERSION 1.3.6)
hunter_default_version(RedisClient VERSION 0.6.1-p1)
hunter_default_version(SDL2 VERSION 2.24.0)
hunter_default_version(SDL_image VERSION 2.0.5-p0)
Expand Down Expand Up @@ -374,7 +376,7 @@ hunter_default_version(libscrypt VERSION 1.21-p1)
hunter_default_version(libsodium VERSION 1.0.16-p0)
hunter_default_version(libunibreak VERSION 4.0)
hunter_default_version(libusb VERSION 1.0.23)
hunter_default_version(libuv VERSION 1.42.0-p0)
hunter_default_version(libuv VERSION 1.44.2)
hunter_default_version(libxdg-basedir VERSION 1.2.3)
hunter_default_version(libxml2 VERSION 2.9.7-p0)
hunter_default_version(libyuv VERSION 1514-p3)
Expand Down
17 changes: 17 additions & 0 deletions cmake/projects/HiRedis/ci/matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[

Choose a reason for hiding this comment

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

needed? if not please remove

{ "example": "HiRedis", "toolchain": "clang-cxx17", "os": "ubuntu-20.04", "python": "3.8", "script": "build.sh" },
{ "example": "HiRedis", "toolchain": "gcc-7-cxx17", "os": "ubuntu-20.04", "python": "3.8", "script": "build.sh" },
{ "example": "HiRedis", "toolchain": "gcc-8-cxx17-fpic", "os": "ubuntu-20.04", "python": "3.8", "script": "build.sh" },
{ "example": "HiRedis", "toolchain": "gcc-9-cxx17-fpic", "os": "ubuntu-20.04", "python": "3.8", "script": "build.sh" },
{ "example": "HiRedis", "toolchain": "sanitize-address-cxx17", "os": "ubuntu-20.04", "python": "3.8", "script": "build.sh" },
{ "example": "HiRedis", "toolchain": "sanitize-leak-cxx17", "os": "ubuntu-20.04", "python": "3.8", "script": "build.sh" },
{ "example": "HiRedis", "toolchain": "sanitize-thread-cxx17", "os": "ubuntu-20.04", "python": "3.8", "script": "build.sh" },
{ "example": "HiRedis", "toolchain": "osx-10-15-make-cxx14", "os": "macos-10.15", "python": "3.8", "script": "build.sh" },
{ "example": "HiRedis", "toolchain": "osx-12-3-arch-universal2-cxx17", "os": "macos-12", "python": "3.8", "script": "build.sh" },
{ "example": "HiRedis", "toolchain": "ninja-vs-16-2019-win64-cxx17", "os": "windows-2019", "python": "3.8", "script": "build.cmd" },
{ "example": "HiRedis", "toolchain": "nmake-vs-16-2019-win64-cxx17", "os": "windows-2019", "python": "3.8", "script": "build.cmd" },
{ "example": "HiRedis", "toolchain": "vs-16-2019-win64-sdk-10-0-18362-0-cxx17", "os": "windows-2019", "python": "3.8", "script": "build.cmd" },
{ "example": "HiRedis", "toolchain": "mingw-cxx17", "os": "windows-2019", "python": "3.8", "script": "build.cmd" },
{ "example": "HiRedis", "toolchain": "msys-cxx17", "os": "windows-2019", "python": "3.8", "script": "build.cmd" }
]

26 changes: 26 additions & 0 deletions cmake/projects/HiRedis/hunter.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# !!! DO NOT PLACE HEADER GUARDS HERE !!!

include(hunter_add_version)
include(hunter_cacheable)
include(hunter_cmake_args)
include(hunter_download)
include(hunter_pick_scheme)
include(hunter_report_broken_package)

hunter_add_version(
PACKAGE_NAME
HiRedis
VERSION
1.1.0
URL
"https://github.com/redis/hiredis/archive/refs/tags/v1.1.0.tar.gz"
SHA1
6b3bae35134d2c0b3b1d884e157cfb03c90412da
)

hunter_pick_scheme(DEFAULT url_sha1_cmake)

hunter_cmake_args(HiRedis CMAKE_ARGS DISABLE_TESTS=ON)

hunter_cacheable(HiRedis)
hunter_download(PACKAGE_NAME HiRedis)
16 changes: 16 additions & 0 deletions cmake/projects/Redis++/ci/matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[

Choose a reason for hiding this comment

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

needed? if not please remove

{ "example": "Redis++", "toolchain": "clang-cxx17", "os": "ubuntu-20.04", "python": "3.8", "script": "build.sh" },
{ "example": "Redis++", "toolchain": "gcc-7-cxx17", "os": "ubuntu-20.04", "python": "3.8", "script": "build.sh" },
{ "example": "Redis++", "toolchain": "gcc-8-cxx17-fpic", "os": "ubuntu-20.04", "python": "3.8", "script": "build.sh" },
{ "example": "Redis++", "toolchain": "gcc-9-cxx17-fpic", "os": "ubuntu-20.04", "python": "3.8", "script": "build.sh" },
{ "example": "Redis++", "toolchain": "sanitize-address-cxx17", "os": "ubuntu-20.04", "python": "3.8", "script": "build.sh" },
{ "example": "Redis++", "toolchain": "sanitize-leak-cxx17", "os": "ubuntu-20.04", "python": "3.8", "script": "build.sh" },
{ "example": "Redis++", "toolchain": "sanitize-thread-cxx17", "os": "ubuntu-20.04", "python": "3.8", "script": "build.sh" },
{ "example": "Redis++", "toolchain": "osx-10-15-cxx17", "os": "macos-10.15", "python": "3.8", "script": "build.sh" },
{ "example": "Redis++", "toolchain": "osx-12-3-arch-universal2-cxx17", "os": "macos-12", "python": "3.8", "script": "build.sh" },
{ "example": "Redis++", "toolchain": "ninja-vs-16-2019-win64-cxx17", "os": "windows-2019", "python": "3.8", "script": "build.cmd" },
{ "example": "Redis++", "toolchain": "nmake-vs-16-2019-win64-cxx17", "os": "windows-2019", "python": "3.8", "script": "build.cmd" },
{ "example": "Redis++", "toolchain": "vs-16-2019-win64-sdk-10-0-18362-0-cxx17", "os": "windows-2019", "python": "3.8", "script": "build.cmd" },
{ "example": "Redis++", "toolchain": "mingw-cxx17", "os": "windows-2019", "python": "3.8", "script": "build.cmd" },
{ "example": "Redis++", "toolchain": "msys-cxx17", "os": "windows-2019", "python": "3.8", "script": "build.cmd" }
]
26 changes: 26 additions & 0 deletions cmake/projects/Redis++/hunter.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# !!! DO NOT PLACE HEADER GUARDS HERE !!!

include(hunter_add_version)
include(hunter_cacheable)
include(hunter_cmake_args)
include(hunter_download)
include(hunter_pick_scheme)

hunter_add_version(
PACKAGE_NAME
Redis++
VERSION
1.3.6
URL
"https://github.com/sewenew/redis-plus-plus/archive/refs/tags/1.3.6.tar.gz"
SHA1
650a9fc65c958119f5360ae7dc2341487a29ac6d
)

hunter_pick_scheme(DEFAULT url_sha1_cmake)

hunter_cmake_args(Redis++ CMAKE_ARGS REDIS_PLUS_PLUS_BUILD_ASYNC=libuv
REDIS_PLUS_PLUS_BUILD_TEST=OFF CMAKE_PREFIX_PATH=${HUNTER_INSTALL_PREFIX})

hunter_cacheable(Redis++)
hunter_download(PACKAGE_NAME Redis++)
11 changes: 11 additions & 0 deletions cmake/projects/libuv/hunter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ hunter_add_version(
4b334b174f4abf4a7f41656e1cfe3c60ad9382ca
)

hunter_add_version(
PACKAGE_NAME
libuv
VERSION
1.44.2
URL
"https://github.com/libuv/libuv/archive/refs/tags/v1.44.2.tar.gz"
SHA1
0ea9726936755088e9c01d30caacfca1a384f3bb
)

hunter_pick_scheme(DEFAULT url_sha1_cmake)

hunter_cmake_args(libuv CMAKE_ARGS BUILD_TESTING=OFF)
Expand Down
22 changes: 22 additions & 0 deletions docs/packages/pkg/HiRedis.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.. spelling::

HiRedis
hiredis

.. index:: HiRedis

Choose a reason for hiding this comment

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

please add the package to at least one of the already listed index-groups

https://hunter.readthedocs.io/en/latest/genindex.html


.. _pkg.HiRedis:

HiRedis
=======

- `Official <https://github.com/redis/hiredis/>`__
- `Example
CMakeLists.txt <https://github.com/cpp-pm/hunter/blob/master/examples/HiRedis/CMakeLists.txt>`__
- Added by `Ronny Nowak <https://github.com/Dargun>`__

.. code-block:: cmake

hunter_add_package(HiRedis)
find_package(HiRedis CONFIG REQUIRED)
target_link_libraries(... hiredis::hiredis_static)
29 changes: 29 additions & 0 deletions docs/packages/pkg/Redis++.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.. spelling::

Redis++
redis

.. index:: Redis++

Choose a reason for hiding this comment

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

please add the package to at least one of the already listed index-groups

https://hunter.readthedocs.io/en/latest/genindex.html


.. _pkg.Redis++:

Redis++
=======

- `Official <https://github.com/sewenew/redis-plus-plus/>`__
- `Example
CMakeLists.txt <https://github.com/cpp-pm/hunter/blob/master/examples/Redis++/CMakeLists.txt>`__
- Added by `Ronny Nowak <https://github.com/Dargun>`__

.. code-block:: cmake

hunter_add_package(HiRedis)

Choose a reason for hiding this comment

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

is it really needed to add and find the packages to build and use redis++? The dependencies should be found by Redis++ itself

Copy link
Author

Choose a reason for hiding this comment

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

no redis++ is not managing that so we need to install libuv and hiredis first and then we can tell rediss++
with CMAKE_PREFIX_PATH=${HUNTER_INSTALL_PREFIX} where he can find installed packages.

find_package(HiRedis CONFIG REQUIRED)

hunter_add_package(libuv)
find_package(libuv CONFIG REQUIRED)

hunter_add_package(Redis++)
find_package(Redis++ CONFIG REQUIRED)

target_link_libraries(... redis++::redis++_static uv)
2 changes: 1 addition & 1 deletion docs/packages/pkg/libuv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ libuv

hunter_add_package(libuv)
find_package(libuv CONFIG REQUIRED)
target_link_libraries(... libuv::uv)
target_link_libraries(... uv)

Choose a reason for hiding this comment

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

where did the imported namespace go?

Copy link
Author

Choose a reason for hiding this comment

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

yea offical libuv repro is not defining namespace libuv:: but the hunter repro was doing it.


uv_ssize_t
~~~~~~~~~~
Expand Down
21 changes: 21 additions & 0 deletions examples/HiRedis/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) 2022, Ronny Nowak
# All rights reserved.

cmake_minimum_required(VERSION 3.0)

# Emulate HunterGate:
# * https://github.com/hunter-packages/gate
include("../common.cmake")

project(download-hiredis)

# DOCUMENTATION_START {
hunter_add_package(HiRedis)
find_package(HiRedis CONFIG REQUIRED)
Dargun marked this conversation as resolved.
Show resolved Hide resolved

add_executable(example main.cpp)
target_link_libraries(example PUBLIC hiredis::hiredis_static)
# DOCUMENTATION_END }

# Test double library creation
find_package(HiRedis CONFIG REQUIRED)
9 changes: 9 additions & 0 deletions examples/HiRedis/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <hiredis/hiredis.h>

int main(int argc, char** argv) {
redisContext *c = nullptr;
redisReply *reply = nullptr;
redisOptions options = { 0 };
REDIS_OPTIONS_SET_TCP(&options, "127.0.0.1", 6379);
return 0;
}
27 changes: 27 additions & 0 deletions examples/Redis++/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (c) 2022, Ronny Nowak
# All rights reserved.

cmake_minimum_required(VERSION 3.0)

# Emulate HunterGate:
# * https://github.com/hunter-packages/gate
include("../common.cmake")

project(download-redis++)

# DOCUMENTATION_START {
hunter_add_package(HiRedis)
find_package(HiRedis CONFIG REQUIRED)

hunter_add_package(libuv)
find_package(libuv CONFIG REQUIRED)

hunter_add_package(Redis++)
find_package(Redis++ CONFIG REQUIRED)

add_executable(example main.cpp)
target_link_libraries(example PUBLIC redis++::redis++_static uv)
# DOCUMENTATION_END }

# Test double library creation
find_package(Redis++ CONFIG REQUIRED)
20 changes: 20 additions & 0 deletions examples/Redis++/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <sw/redis++/redis++.h>
#include <sw/redis++/async_redis++.h>

using namespace sw::redis;

int main(int argc, char** argv) {
{
auto r = Redis("tcp://127.0.0.1");
auto v = r.command<std::unordered_map<std::string, std::string>>("config", "get", "*");
}
{
ConnectionOptions opts;
opts.host = "127.0.0.1";
opts.port = 6379;
ConnectionPoolOptions pool_opts;
pool_opts.size = 3;
auto async_redis = AsyncRedis(opts, pool_opts);
}
return 0;
}
2 changes: 1 addition & 1 deletion examples/libuv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ message("CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
find_package(libuv CONFIG REQUIRED)
add_executable(example example.c)

target_link_libraries(example libuv::uv)
target_link_libraries(example uv)

enable_testing()

Expand Down