Skip to content

Commit 07c3618

Browse files
committedJul 22, 2020
Add static library target and cpack support
1 parent 3bb9853 commit 07c3618

File tree

2 files changed

+50
-3
lines changed

2 files changed

+50
-3
lines changed
 

‎CMakeLists.txt

+39-3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ IF(WIN32)
4040
ENDIF()
4141

4242
ADD_LIBRARY(hiredis SHARED ${hiredis_sources})
43+
ADD_LIBRARY(hiredis_static STATIC ${hiredis_sources})
4344

4445
SET_TARGET_PROPERTIES(hiredis
4546
PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE
@@ -48,16 +49,47 @@ IF(WIN32 OR MINGW)
4849
TARGET_LINK_LIBRARIES(hiredis PRIVATE ws2_32)
4950
ENDIF()
5051

51-
TARGET_INCLUDE_DIRECTORIES(hiredis PUBLIC $<INSTALL_INTERFACE:.> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
52+
TARGET_INCLUDE_DIRECTORIES(hiredis PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
53+
TARGET_INCLUDE_DIRECTORIES(hiredis_static PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
5254

5355
CONFIGURE_FILE(hiredis.pc.in hiredis.pc @ONLY)
5456

55-
INSTALL(TARGETS hiredis
57+
set(CPACK_PACKAGE_VENDOR "Redis")
58+
set(CPACK_PACKAGE_DESCRIPTION "\
59+
Hiredis is a minimalistic C client library for the Redis database.
60+
61+
It is minimalistic because it just adds minimal support for the protocol, \
62+
but at the same time it uses a high level printf-alike API in order to make \
63+
it much higher level than otherwise suggested by its minimal code base and the \
64+
lack of explicit bindings for every Redis command.
65+
66+
Apart from supporting sending commands and receiving replies, it comes with a \
67+
reply parser that is decoupled from the I/O layer. It is a stream parser designed \
68+
for easy reusability, which can for instance be used in higher level language bindings \
69+
for efficient reply parsing.
70+
71+
Hiredis only supports the binary-safe Redis protocol, so you can use it with any Redis \
72+
version >= 1.2.0.
73+
74+
The library comes with multiple APIs. There is the synchronous API, the asynchronous API \
75+
and the reply parsing API.")
76+
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/redis/hiredis")
77+
set(CPACK_PACKAGE_CONTACT "michael dot grunder at gmail dot com")
78+
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
79+
set(CPACK_RPM_PACKAGE_AUTOREQPROV ON)
80+
81+
include(CPack)
82+
83+
INSTALL(TARGETS hiredis hiredis_static
5684
EXPORT hiredis-targets
5785
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
5886
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
5987
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
6088

89+
# For NuGet packages
90+
INSTALL(FILES hiredis.targets
91+
DESTINATION build/native)
92+
6193
INSTALL(FILES hiredis.h read.h sds.h async.h alloc.h
6294
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hiredis)
6395

@@ -98,6 +130,8 @@ IF(ENABLE_SSL)
98130
ssl.c)
99131
ADD_LIBRARY(hiredis_ssl SHARED
100132
${hiredis_ssl_sources})
133+
ADD_LIBRARY(hiredis_ssl_static STATIC
134+
${hiredis_ssl_sources})
101135

102136
IF (APPLE)
103137
SET_PROPERTY(TARGET hiredis_ssl PROPERTY LINK_FLAGS "-Wl,-undefined -Wl,dynamic_lookup")
@@ -109,13 +143,15 @@ IF(ENABLE_SSL)
109143
VERSION "${HIREDIS_SONAME}")
110144

111145
TARGET_INCLUDE_DIRECTORIES(hiredis_ssl PRIVATE "${OPENSSL_INCLUDE_DIR}")
146+
TARGET_INCLUDE_DIRECTORIES(hiredis_ssl_static PRIVATE "${OPENSSL_INCLUDE_DIR}")
147+
112148
TARGET_LINK_LIBRARIES(hiredis_ssl PRIVATE ${OPENSSL_LIBRARIES})
113149
IF (WIN32 OR MINGW)
114150
TARGET_LINK_LIBRARIES(hiredis_ssl PRIVATE hiredis)
115151
ENDIF()
116152
CONFIGURE_FILE(hiredis_ssl.pc.in hiredis_ssl.pc @ONLY)
117153

118-
INSTALL(TARGETS hiredis_ssl
154+
INSTALL(TARGETS hiredis_ssl hiredis_ssl_static
119155
EXPORT hiredis_ssl-targets
120156
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
121157
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}

‎hiredis.targets

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemDefinitionGroup>
4+
<ClCompile>
5+
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
6+
</ClCompile>
7+
<Link>
8+
<AdditionalLibraryDirectories>$(MSBuildThisFileDirectory)\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
9+
</Link>
10+
</ItemDefinitionGroup>
11+
</Project>

0 commit comments

Comments
 (0)
Please sign in to comment.