Commit Graph

47 Commits (61b5b299f0ac4f0efbe11a45716e06a9c35f37b7)

Author SHA1 Message Date
Tongliang Liao 35d398c903 Fix cmake config path on Linux.
CMake config files were installed to `/usr/local/share/hiredis`, which is not recognizable by `find_package()`.
I'm not sure why it was set that way.
Given the commit introducing it is for Windows, I keep that behavior consistent there, but fix the rest.
2022-09-01 10:43:36 -07:00
michael-grunder eaae7321c2 Polling adapter requires sockcompat.h
We need to install our socket compatibility header as the new polling
adapter needs it.
2022-09-01 00:50:23 -07:00
Lipraxde c57cad658d CMake: remove dict.c form hiredis_sources
Commit c6b8bd77c0 to make all functions in dict.c static. If a CMake project set warning unused functions, and include hiredis using add_subdirectory , this cause warnings / errors.
2022-08-29 14:31:51 -07:00
Michael Grunder 06be7ff312
Merge pull request #1050 from smmir-cent/fix-cmake-version
fix cmake version
2022-07-31 14:54:13 -07:00
Michael Grunder 8a15f4d657
Merge pull request #1057 from orgads/static-name
Use the same name for static and shared libraries
2022-06-26 16:49:19 -07:00
Orgad Shaneh dd4bf97836 Use the same name for static and shared libraries
On all system except MSVC, the targets are different.

Unix: libhiredis.so, libhiredis.a
MinGW: libhiredis.dll+libhiredis.dll.a, libhiredis.a
MSVC: hiredis.dll+hiredis.lib, hiredis_static.lib
2022-03-29 17:19:52 +03:00
Kristján Valur Jónsson ff57c18b9e Embed debug information in windows static lib, rather than create a .pdb file
Using .pdb files with .lib files on windows is very inconvenient, particularly if the .lib
file is then linked as part of a different .dll.  Chances are that the original .pdb
will not be picked up or distributed along with the tooling.
2022-03-24 14:41:22 +00:00
smmir-cent 8310ad4f5c fix cmake version 2022-03-18 20:27:01 +00:00
Dietmar Scheidl f2e8010d95 fix building on AIX and SunOS (#1031) 2022-01-24 12:12:19 -08:00
Fabrice Fontaine 24d5344934
CMakeLists.txt: allow building without a C++ compiler (#872)
Define hiredis as a C project (and use a single PROJECT statement) to
avoid the following build failure if a C++ compiler is not found:

CMake Error at CMakeLists.txt:3 (PROJECT):
  The CMAKE_CXX_COMPILER:

    /srv/storage/autobuild/run/instance-1/output-1/host/bin/arm-linux-g++

  is not a full path to an existing compiler tool.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.

The only cpp source file is examples/example-qt.cpp which is never
compiled with cmake buildsystem. This file is compiled only with the
Makefile buildsystem so perhaps it should be removed. If it is added to
the cmake buildsystem, a call to enable_language(CXX) will have to be
added.

Fixes:
 - http://autobuild.buildroot.org/results/830ec3398cd29b9fc5cde06a225ef531d7a9d850

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2022-01-08 18:57:13 -08:00
Eric Deng f347743b7d
Update CMakeLists.txt for more portability (#1005)
add alias hiredis::hiredis and hiredis::hiredis_static so when this project is FetchContent, it behave the same as find_package-ed.
e.g.
```
find_package(hiredis 1.0.2 QUIET)
if (NOT hiredis_FOUND)
    FetchContent_Declare(
            hiredis
            GIT_REPOSITORY https://github.com/redis/hiredis.git
            GIT_TAG v1.0.2
    )
    FetchContent_MakeAvailable(hiredis)
endif ()
# later
target_link_libraries(target **hiredis::hiredis**) #can always use hiredis::hiredis to ref to this project. no matter find_package or FetchContent
```
this is actually sort of best practice when making a CMake lib.
2021-12-22 10:47:03 -08:00
Michael Grunder e3a479e409
FreeBSD build fixes + CI (#1026)
* BSD linkage fix proposal

* Touch up the Makefile to fix BSD builds

Fixes #984

* Add a build in FreeBSD to GitHub Actions

Lots of people use hiredis in FreeBSD so this should reduce some pain
moving forward.

Co-authored-by: David Carlier <devnexen@gmail.com>
2021-12-16 12:36:05 -08:00
Björn Svensson 648763c36e Add build options for enabling async tests
Asynchronous testcases that requires the event library `libevent`
can be built and enabled by using the added build flags:
- ENABLE_ASYNC_TESTS when using CMake
- TEST_ASYNC when using Make

The async tests are disabled by default to avoid adding new requirements,
but the testcases are built and run in CI.
2021-10-26 09:54:44 +02:00
Tongliang Liao 51c740824b Remove extra comma from cmake var.
Or it'll be treated as part of the var name.
2021-10-09 13:19:39 -07:00
Alessio M e35300a668 add pdb files to packages for MSVC builds 2020-09-09 18:11:05 +01:00
Alessio M dde6916b42 Add d suffix to debug libraries so that can packaged together with optimized builds (Release, RelWithDebInfo, etc) 2020-09-09 17:27:28 +01:00
Alessio M 3b68b5018e Enable position-independent code 2020-09-09 11:55:42 +01:00
michael-grunder 2a5a57b90a Remove whitespace 2020-09-07 17:47:50 -07:00
Alessio M 1b40ec5096 fixed issue with unit test linking on windows with SSL 2020-09-07 23:27:45 +01:00
Alessio M d7b1d21e80 Merge branch 'master' of github.com:redis/hiredis 2020-09-04 09:31:47 +01:00
michael-grunder 13a35bdb64 Explicitly set c99 in CMake
See #869
2020-08-28 12:35:20 -07:00
Michael Grunder 8966a1fc2b
Remove extra whitespace (#858) 2020-07-30 16:55:48 -07:00
Michael Grunder d8ff72387d
Move SSL management to a distinct private pointer. (#855)
We need to allow our users to use redisContext->privdata as context
for any RESP3 PUSH messages, which means we can't use it for managing
SSL connections.

Bulletpoints:

* Create a secondary redisContext member for internal use only called
  privctx and rename the redisContextFuncs->free_privdata accordingly.

* Adds a `free_privdata` function pointer so the user can tie allocated
  memory to the lifetime of a redisContext (like they can already do
  with redisAsyncContext)

* Enables SSL tests in .travis.yml
2020-07-29 11:53:03 -07:00
masariello 07c3618ffe Add static library target and cpack support 2020-07-22 20:30:41 +01:00
Michael Grunder 8e0264cfd6
Allow users to replace allocator and handle OOM everywhere. (#800)
* Adds an indirection to every allocation/deallocation to allow users to 
  plug in ones of their choosing (use custom functions, jemalloc, etc).

* Gracefully handle OOM everywhere in hiredis.  This should make it possible
  for users of the library to have more flexibility in how they handle such situations.

* Changes `redisReaderTask->elements` from an `int` to a `long long` to prevent
  a possible overflow when transferring the task elements into a `redisReply`.

* Adds a configurable `max elements` member to `redisReader` that defaults to
  2^32 - 1.  This can be set to "unlimited" by setting the value to zero.
2020-05-22 09:27:49 -07:00
Michael Grunder b484021859
Fix USE_SSL=1 make/cmake on OSX and CMake tests (#789)
* Fix linker problems when building with SSL enabled on OSX
* Corrects `HIREDIS_SSL=ON` to `USE_SSL=ON` so we test building with
  SSL enabled on travis.
2020-04-13 09:32:32 -07:00
Michael Grunder ec08c2b94a
Added CMake package config and fixed hiredis_ssl on Windows (#783)
* Add CMake package configuration so hiredis can be more easily included in 
  other projects.

* Fixes hiredis_ssl such that it compiles and works in windows

Co-authored-by: nrivera <nrivera@blizzard.com>
Co-authored-by: Nick <heronr1@gmail.com>
2020-04-09 08:05:14 -07:00
Yossi Gottlieb 1b967bc947 CMake: Set hiredis_ssl shared object version. 2020-04-07 21:19:00 +03:00
Michael Grunder cc9d032971
Win32 tests and timeout fix (#776)
Unit tests in Windows and a Windows timeout fix

This commit gets our unit tests compiling and running on Windows as well as removes a duplicated `timeval` -> `DWORD` conversion logic in sockcompat.c 

There are minor differences in behavior between Linux and Windows to note:

1.  In Windows, opening a non-existent hangs forever in WSAPoll whereas
    it correctly returns with a "Connection refused" error on Linux.
    For that reason, I simply skip this test in Windows.

    It may be related to this known issue:
    https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/

2.  Timeouts are handled slightly differently in Windows and Linux.  
    In Linux, we intentionally set REDIS_ERR_IO for connection
    timeouts whereas in Windows we set REDIS_ERR_TIMEOUT.  It may be
    prudent to fix this discrepancy although there are almost certainly
    users relying on the current behavior.
2020-04-02 22:41:34 -07:00
Michael Grunder 38675d23cc
Housekeeping fixes (#764)
Housekeeping

* Check for C++ (#758, #750) 
* Include `alloc.h` in `make install` and `cmake`
* Add a `.def` file for Windows (#760)
* Include allocation wrappers referenced in adapter headers
* Fix minor syntax errors and typos in README
* Fix CI in Windows by properly escaping arguments (#761)
2020-02-27 21:29:05 -08:00
Michael Grunder 669ac9d0c8
Safe allocation wrappers (#754)
Create allocation wrappers with a configurable OOM handler (defaults to abort()).

See #752, #747
2020-01-28 12:13:05 -08:00
Paul Botros f052fd1add Adding an option to DISABLE_TESTS
Useful when hiredis is used as a CMake dependency in other projects and
added via add_subdirectory(). With DISABLE_TESTS on, `make test` in the
parent project won't run hiredis tests.
2019-11-03 22:01:28 -08:00
Yossi Gottlieb dd408e8e3f Update CMakelists for hiredis/hiredis_ssl builds.
Also rename the SSL option from `HIREDIS_SSL` to `ENABLE_SSL` to conform
with CMake convnetions.
2019-09-01 13:47:39 +03:00
Yossi Gottlieb 44ef4de9d9 Update CMakeLists with sslio.c rename. 2019-08-29 22:21:40 +03:00
kevin1018 8249e67355
Add install adapters header files 2019-07-17 19:05:06 +08:00
m e38cd75562 CMake: Minor modernization
Rely more on transitive dependencies, as provided by
TARGET_LINK_LIBRARIES. Avoid using ADD_DEFINITIONS and
INCLUDE_DIRECTORIES. This avoids leakage/pollution of defines and
includes.
2019-04-01 11:54:37 +02:00
m dc6d19b9ec Port network layer to Winsock
With this change, Hiredis builds with MinGW and runs on Windows.
2019-04-01 11:54:37 +02:00
Mark Nunberg 792bdbab7e cmake: ssl disabled by default 2019-02-21 12:04:53 -05:00
Mark Nunberg 0bc2356ed5 CMake: update for SSL 2019-02-20 09:11:10 -05:00
Justin Brewer ebe1657c8f Obey HIREDIS_SONAME for shared library
Signed-off-by: Justin Brewer <jzb0012@auburn.edu>
2019-02-20 05:01:09 -05:00
Justin Brewer 7d38176bdb Call project() with parsed version string
Signed-off-by: Justin Brewer <jzb0012@auburn.edu>
2019-02-20 05:01:09 -05:00
Justin Brewer 58d0e28333 Enable make test
Signed-off-by: Justin Brewer <jzb0012@auburn.edu>
2019-02-20 05:01:09 -05:00
Justin Brewer 9ea7ddec0c Generate and install hiredis.pc
Signed-off-by: Justin Brewer <jzb0012@auburn.edu>
2019-02-20 05:01:09 -05:00
Justin Brewer edfab35cdc Install async.h
Signed-off-by: Justin Brewer <jzb0012@auburn.edu>
2019-02-20 05:01:08 -05:00
Justin Brewer 0c57a083c7 Add ENABLE_EXAMPLES option, off by default
Signed-off-by: Justin Brewer <jzb0012@auburn.edu>
2019-02-20 05:01:08 -05:00
Mark Nunberg bbad21f5ca Add examples to CMakeLists 2019-02-20 05:01:08 -05:00
Mark Nunberg ead586a2cb Add CMake system. Initial commit
This provides a target to build a DSO, as well as the ability to install
it.
2019-02-20 05:01:08 -05:00