From 8715ba5c82af165f783ef8bc90b4d8d5a8072175 Mon Sep 17 00:00:00 2001 From: Yossi Gottlieb Date: Thu, 29 Aug 2019 22:08:54 +0300 Subject: wip: SSL code reorganization, see #705. --- examples/example-libevent-ssl.c | 1 + examples/example-ssl.c | 1 + 2 files changed, 2 insertions(+) (limited to 'examples') diff --git a/examples/example-libevent-ssl.c b/examples/example-libevent-ssl.c index 562e1a1..1021113 100644 --- a/examples/example-libevent-ssl.c +++ b/examples/example-libevent-ssl.c @@ -4,6 +4,7 @@ #include #include +#include #include #include diff --git a/examples/example-ssl.c b/examples/example-ssl.c index 156f524..81f4648 100644 --- a/examples/example-ssl.c +++ b/examples/example-ssl.c @@ -3,6 +3,7 @@ #include #include +#include int main(int argc, char **argv) { unsigned int j; -- cgit v1.2.3 From dd408e8e3f90ab9de61a1d7fac711d2b5d7e1592 Mon Sep 17 00:00:00 2001 From: Yossi Gottlieb Date: Sun, 1 Sep 2019 13:47:25 +0300 Subject: Update CMakelists for hiredis/hiredis_ssl builds. Also rename the SSL option from `HIREDIS_SSL` to `ENABLE_SSL` to conform with CMake convnetions. --- CMakeLists.txt | 24 +++++++++++++++++------- examples/CMakeLists.txt | 6 +++--- hiredis_ssl.pc.in | 12 ++++++++++++ 3 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 hiredis_ssl.pc.in (limited to 'examples') diff --git a/CMakeLists.txt b/CMakeLists.txt index 03e7e7b..9e78894 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.4.0) INCLUDE(GNUInstallDirs) PROJECT(hiredis) -OPTION(HIREDIS_SSL "Link against OpenSSL" OFF) +OPTION(ENABLE_SSL "Build hiredis_ssl for SSL support" OFF) MACRO(getVersionBit name) SET(VERSION_REGEX "^#define ${name} (.+)$") @@ -29,8 +29,7 @@ ADD_LIBRARY(hiredis SHARED net.c read.c sds.c - sockcompat.c - ssl.c) + sockcompat.c) SET_TARGET_PROPERTIES(hiredis PROPERTIES @@ -54,16 +53,27 @@ INSTALL(DIRECTORY adapters INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/hiredis.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) -IF(HIREDIS_SSL) +IF(ENABLE_SSL) IF (NOT OPENSSL_ROOT_DIR) IF (APPLE) SET(OPENSSL_ROOT_DIR "/usr/local/opt/openssl") ENDIF() ENDIF() FIND_PACKAGE(OpenSSL REQUIRED) - TARGET_COMPILE_DEFINITIONS(hiredis PRIVATE HIREDIS_SSL) - TARGET_INCLUDE_DIRECTORIES(hiredis PRIVATE "${OPENSSL_INCLUDE_DIR}") - TARGET_LINK_LIBRARIES(hiredis PRIVATE ${OPENSSL_LIBRARIES}) + ADD_LIBRARY(hiredis_ssl SHARED + ssl.c) + TARGET_INCLUDE_DIRECTORIES(hiredis_ssl PRIVATE "${OPENSSL_INCLUDE_DIR}") + TARGET_LINK_LIBRARIES(hiredis_ssl PRIVATE ${OPENSSL_LIBRARIES}) + CONFIGURE_FILE(hiredis_ssl.pc.in hiredis_ssl.pc @ONLY) + + INSTALL(TARGETS hiredis_ssl + DESTINATION "${CMAKE_INSTALL_LIBDIR}") + + INSTALL(FILES hiredis_ssl.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hiredis) + + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/hiredis_ssl.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) ENDIF() IF(NOT (WIN32 OR MINGW)) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 8ab4b42..dd3a313 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -37,10 +37,10 @@ IF (APPLE) TARGET_LINK_LIBRARIES(example-macosx hiredis ${CF}) ENDIF() -IF (HIREDIS_SSL) +IF (ENABLE_SSL) ADD_EXECUTABLE(example-ssl example-ssl.c) - TARGET_LINK_LIBRARIES(example-ssl hiredis) + TARGET_LINK_LIBRARIES(example-ssl hiredis hiredis_ssl) ENDIF() ADD_EXECUTABLE(example example.c) -TARGET_LINK_LIBRARIES(example hiredis) \ No newline at end of file +TARGET_LINK_LIBRARIES(example hiredis) diff --git a/hiredis_ssl.pc.in b/hiredis_ssl.pc.in new file mode 100644 index 0000000..588a978 --- /dev/null +++ b/hiredis_ssl.pc.in @@ -0,0 +1,12 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include +pkgincludedir=${includedir}/hiredis + +Name: hiredis_ssl +Description: SSL Support for hiredis. +Version: @PROJECT_VERSION@ +Requires: hiredis +Libs: -L${libdir} -lhiredis_ssl +Libs.private: -lssl -lcrypto -- cgit v1.2.3