blob: 139d13f4cbb5582a2f028c746a3eb153682d8615 [file] [log] [blame]
Andrew Geissler69721092021-07-23 12:57:00 -04001From 2dc0c7e4a3fa7ecc92ee5e22f1d8ee48c2b333a8 Mon Sep 17 00:00:00 2001
2From: Thomas Lee <debian@tomlee.co>
3Date: Sun, 4 Nov 2018 22:59:09 +0000
4Subject: [PATCH] CMake configuration for hiredis
5
6Last-Update: 2018-09-26
7
8Upstream-Status: Backport [Ubuntu 20.04]
9---
10 HiredisConfig.cmake.in | 5 +++++
11 HiredisConfigVersion.cmake.in | 22 ++++++++++++++++++++++
12 Makefile | 17 ++++++++++++++++-
13 3 files changed, 43 insertions(+), 1 deletion(-)
14 create mode 100644 HiredisConfig.cmake.in
15 create mode 100644 HiredisConfigVersion.cmake.in
16
17diff --git a/HiredisConfig.cmake.in b/HiredisConfig.cmake.in
18new file mode 100644
19index 0000000..2cce290
20--- /dev/null
21+++ b/HiredisConfig.cmake.in
22@@ -0,0 +1,5 @@
23+find_path(HIREDIS_INCLUDE_DIRS hiredis/hiredis.h HINTS "/usr/include")
24+find_library(HIREDIS_LIB_HIREDIS NAMES hiredis HINTS "/usr/lib")
25+
26+set(HIREDIS_LIBRARIES ${HIREDIS_LIB_HIREDIS})
27+
28diff --git a/HiredisConfigVersion.cmake.in b/HiredisConfigVersion.cmake.in
29new file mode 100644
30index 0000000..584144a
31--- /dev/null
32+++ b/HiredisConfigVersion.cmake.in
33@@ -0,0 +1,22 @@
34+set(PACKAGE_VERSION "@HIREDIS_VERSION@")
35+
36+string(REPLACE "." ";" HIREDIS_VERSION_COMPONENTS ${PACKAGE_VERSION})
37+string(REPLACE "." ";" REQUESTED_VERSION_COMPONENTS ${PACKAGE_FIND_VERSION})
38+
39+list(GET HIREDIS_VERSION_COMPONENTS 0 HIREDIS_VERSION_MAJOR)
40+list(GET HIREDIS_VERSION_COMPONENTS 1 HIREDIS_VERSION_MINOR)
41+
42+list(GET REQUESTED_VERSION_COMPONENTS 0 REQUESTED_VERSION_MAJOR)
43+list(GET REQUESTED_VERSION_COMPONENTS 1 REQUESTED_VERSION_MINOR)
44+
45+if(("${HIREDIS_VERSION_MAJOR}" EQUAL "${REQUESTED_VERSION_MAJOR}") AND
46+ (("${HIREDIS_VERSION_MINOR}" EQUAL "${REQUESTED_VERSION_MINOR}") OR
47+ ("${HIREDIS_VERSION_MINOR}" GREATER "${REQUESTED_VERSION_MINOR}")))
48+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
49+ if("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
50+ set(PACKAGE_VERSION_EXACT TRUE)
51+ endif()
52+else()
53+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
54+endif()
55+
56diff --git a/Makefile b/Makefile
57index 339727f..43704cd 100644
58--- a/Makefile
59+++ b/Makefile
60@@ -8,6 +8,8 @@ EXAMPLES=hiredis-example hiredis-example-libevent hiredis-example-libev hiredis-
61 TESTS=hiredis-test
62 LIBNAME=libhiredis
63 PKGCONFNAME=hiredis.pc
64+CMAKECONFNAME=HiredisConfig.cmake
65+CMAKEVERSNAME=HiredisConfigVersion.cmake
66
67 HIREDIS_MAJOR=$(shell grep HIREDIS_MAJOR hiredis.h | awk '{print $$3}')
68 HIREDIS_MINOR=$(shell grep HIREDIS_MINOR hiredis.h | awk '{print $$3}')
69@@ -19,9 +21,11 @@ PREFIX?=/usr/local
70 INCLUDE_PATH?=include/hiredis
71 LIBRARY_PATH?=lib
72 PKGCONF_PATH?=pkgconfig
73+CMAKE_PATH?=cmake/Hiredis
74 INSTALL_INCLUDE_PATH= $(DESTDIR)$(PREFIX)/$(INCLUDE_PATH)
75 INSTALL_LIBRARY_PATH= $(DESTDIR)$(PREFIX)/$(LIBRARY_PATH)
76 INSTALL_PKGCONF_PATH= $(INSTALL_LIBRARY_PATH)/$(PKGCONF_PATH)
77+INSTALL_CMAKE_PATH= $(INSTALL_LIBRARY_PATH)/$(CMAKE_PATH)
78
79 # redis-server configuration used for testing
80 REDIS_PORT=56379
81@@ -150,6 +154,7 @@ check: hiredis-test
82
83 clean:
84 rm -rf $(DYLIBNAME) $(STLIBNAME) $(TESTS) $(PKGCONFNAME) examples/hiredis-example* *.o *.gcda *.gcno *.gcov
85+ rm -f $(CMAKECONFNAME) $(CMAKEVERSNAME)
86
87 dep:
88 $(CC) -MM *.c
89@@ -169,7 +174,14 @@ $(PKGCONFNAME): hiredis.h
90 @echo Libs: -L\$${libdir} -lhiredis >> $@
91 @echo Cflags: -I\$${includedir} -D_FILE_OFFSET_BITS=64 >> $@
92
93-install: $(DYLIBNAME) $(STLIBNAME) $(PKGCONFNAME)
94+$(CMAKECONFNAME): $(CMAKECONFNAME).in
95+ cp $(CMAKECONFNAME).in $(CMAKECONFNAME)
96+
97+$(CMAKEVERSNAME): $(CMAKEVERSNAME).in
98+ sed -e "s,@HIREDIS_VERSION@,$(HIREDIS_MAJOR).$(HIREDIS_MINOR).$(HIREDIS_PATCH),g" \
99+ $(CMAKEVERSNAME).in >$(CMAKEVERSNAME)
100+
101+install: $(DYLIBNAME) $(STLIBNAME) $(PKGCONFNAME) $(CMAKECONFNAME) $(CMAKEVERSNAME)
102 mkdir -p $(INSTALL_INCLUDE_PATH) $(INSTALL_INCLUDE_PATH)/adapters $(INSTALL_LIBRARY_PATH)
103 $(INSTALL) hiredis.h async.h read.h sds.h $(INSTALL_INCLUDE_PATH)
104 $(INSTALL) adapters/*.h $(INSTALL_INCLUDE_PATH)/adapters
105@@ -178,6 +190,9 @@ install: $(DYLIBNAME) $(STLIBNAME) $(PKGCONFNAME)
106 $(INSTALL) $(STLIBNAME) $(INSTALL_LIBRARY_PATH)
107 mkdir -p $(INSTALL_PKGCONF_PATH)
108 $(INSTALL) $(PKGCONFNAME) $(INSTALL_PKGCONF_PATH)
109+ mkdir -p $(INSTALL_CMAKE_PATH)
110+ $(INSTALL) $(CMAKECONFNAME) $(INSTALL_CMAKE_PATH)
111+ $(INSTALL) $(CMAKEVERSNAME) $(INSTALL_CMAKE_PATH)
112
113 32bit:
114 @echo ""
115--
1162.27.0
117