CMake: update for SSL

This commit is contained in:
Mark Nunberg 2019-02-06 14:14:46 -05:00
parent 847a20122f
commit 0bc2356ed5

View File

@ -1,5 +1,8 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0)
INCLUDE(GNUInstallDirs)
PROJECT(hiredis)
OPTION(HIREDIS_SSL "Link against OpenSSL" ON)
MACRO(getVersionBit name)
SET(VERSION_REGEX "^#define ${name} (.+)$")
@ -27,7 +30,8 @@ ADD_LIBRARY(hiredis SHARED
hiredis.c
net.c
read.c
sds.c)
sds.c
sslio.c)
SET_TARGET_PROPERTIES(hiredis
PROPERTIES
@ -44,9 +48,22 @@ INSTALL(FILES hiredis.h read.h sds.h async.h
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/hiredis.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
IF(HIREDIS_SSL)
IF (NOT OPENSSL_ROOT_DIR)
IF (APPLE)
SET(OPENSSL_ROOT_DIR "/usr/local/opt/openssl")
ENDIF()
ENDIF()
FIND_PACKAGE(OpenSSL REQUIRED)
ADD_DEFINITIONS(-DHIREDIS_SSL)
INCLUDE_DIRECTORIES("${OPENSSL_INCLUDE_DIR}")
TARGET_LINK_LIBRARIES(hiredis ${OPENSSL_LIBRARIES})
ENDIF()
ENABLE_TESTING()
ADD_EXECUTABLE(hiredis-test
test.c)
ADD_EXECUTABLE(hiredis-test test.c)
TARGET_LINK_LIBRARIES(hiredis-test hiredis)
ADD_TEST(NAME hiredis-test
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test.sh)