summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Grunder <michael.grunder@gmail.com>2020-04-13 09:32:32 -0700
committerGitHub <noreply@github.com>2020-04-13 09:32:32 -0700
commitb484021859c2b395f13163caaa9b877b5284ab07 (patch)
treeeea357f2bff16a9cb079b69b4fe8c8c5672c3613
parent0184caac9de25258b23156016b3528e9878f1dae (diff)
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.
-rw-r--r--.travis.yml14
-rw-r--r--CMakeLists.txt9
-rw-r--r--Makefile8
3 files changed, 25 insertions, 6 deletions
diff --git a/.travis.yml b/.travis.yml
index 727d112..09246f9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,7 +15,7 @@ branches:
- /^release\/.*$/
before_script:
- - if [ "$TRAVIS_OS_NAME" == "osx" ] ; then brew update; brew install redis; fi
+ - if [ "$TRAVIS_OS_NAME" == "osx" ] ; then brew update; brew install redis openssl; fi
addons:
apt:
@@ -27,6 +27,8 @@ addons:
- libc6-dbg:i386
- gcc-multilib
- g++-multilib
+ - libssl-dev
+ - libssl-dev:i386
- valgrind
env:
@@ -34,7 +36,7 @@ env:
- BITS="64"
script:
- - EXTRA_CMAKE_OPTS="-DENABLE_EXAMPLES:BOOL=ON -DHIREDIS_SSL:BOOL=ON";
+ - EXTRA_CMAKE_OPTS="-DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON";
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
if [ "$BITS" == "32" ]; then
CFLAGS="-m32 -Werror";
@@ -58,6 +60,14 @@ script:
fi;
fi;
export CFLAGS CXXFLAGS LDFLAGS TEST_PREFIX EXTRA_CMAKE_OPTS
+ - make && make clean;
+ if [ "$TRAVIS_OS_NAME" == "osx" ]; then
+ if [ "$BITS" == "64" ]; then
+ OPENSSL_PREFIX="$(ls -d /usr/local/Cellar/openssl@1.1/*)" USE_SSL=1 make;
+ fi;
+ else
+ USE_SSL=1 make;
+ fi;
- mkdir build/ && cd build/
- cmake .. ${EXTRA_CMAKE_OPTS}
- make VERBOSE=1
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b402b3d..7844575 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -98,11 +98,16 @@ IF(ENABLE_SSL)
ssl.c)
ADD_LIBRARY(hiredis_ssl SHARED
${hiredis_ssl_sources})
+
+ IF (APPLE)
+ SET_PROPERTY(TARGET hiredis_ssl PROPERTY LINK_FLAGS "-Wl,-undefined -Wl,dynamic_lookup")
+ ENDIF()
+
SET_TARGET_PROPERTIES(hiredis_ssl
- PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE
+ PROPERTIES
+ WINDOWS_EXPORT_ALL_SYMBOLS TRUE
VERSION "${HIREDIS_SONAME}")
-
TARGET_INCLUDE_DIRECTORIES(hiredis_ssl PRIVATE "${OPENSSL_INCLUDE_DIR}")
TARGET_LINK_LIBRARIES(hiredis_ssl PRIVATE ${OPENSSL_LIBRARIES})
IF (WIN32 OR MINGW)
diff --git a/Makefile b/Makefile
index 2e9f445..c11c9a9 100644
--- a/Makefile
+++ b/Makefile
@@ -87,6 +87,7 @@ ifeq ($(uname_S),Darwin)
DYLIBSUFFIX=dylib
DYLIB_MINOR_NAME=$(LIBNAME).$(HIREDIS_SONAME).$(DYLIBSUFFIX)
DYLIB_MAKE_CMD=$(CC) -dynamiclib -Wl,-install_name,$(PREFIX)/$(LIBRARY_PATH)/$(DYLIB_MINOR_NAME) -o $(DYLIBNAME) $(LDFLAGS)
+ DYLIB_PLUGIN=-Wl,-undefined -Wl,dynamic_lookup
endif
all: $(DYLIBNAME) $(STLIBNAME) hiredis-test $(PKGCONFNAME)
@@ -113,7 +114,7 @@ $(STLIBNAME): $(OBJ)
$(STLIB_MAKE_CMD) $(STLIBNAME) $(OBJ)
$(SSL_DYLIBNAME): $(SSL_OBJ)
- $(DYLIB_MAKE_CMD) -o $(SSL_DYLIBNAME) $(SSL_OBJ) $(REAL_LDFLAGS) $(SSL_LDFLAGS)
+ $(DYLIB_MAKE_CMD) $(DYLIB_PLUGIN) -o $(SSL_DYLIBNAME) $(SSL_OBJ) $(REAL_LDFLAGS) $(SSL_LDFLAGS)
$(SSL_STLIBNAME): $(SSL_OBJ)
$(STLIB_MAKE_CMD) $(SSL_STLIBNAME) $(SSL_OBJ)
@@ -185,9 +186,12 @@ examples: $(EXAMPLES)
TEST_LIBS = $(STLIBNAME)
ifeq ($(USE_SSL),1)
- TEST_LIBS += $(SSL_STLIBNAME) -lssl -lcrypto -lpthread
+ TEST_LIBS += $(SSL_STLIBNAME)
+ TEST_LDFLAGS = $(SSL_LDFLAGS) -lssl -lcrypto -lpthread
endif
+
hiredis-test: test.o $(TEST_LIBS)
+ $(CC) -o $@ $(REAL_CFLAGS) -I. $^ $(REAL_LDFLAGS) $(TEST_LDFLAGS)
hiredis-%: %.o $(STLIBNAME)
$(CC) $(REAL_CFLAGS) -o $@ $< $(TEST_LIBS) $(REAL_LDFLAGS)