summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Grunder <michael.grunder@gmail.com>2020-10-18 14:04:02 -0700
committerGitHub <noreply@github.com>2020-10-18 14:04:02 -0700
commitf44945a0af08b388854f0d7d2e1381e26c695ef7 (patch)
treee5cabc8c6f37a6314d1ceb2654f95fdcd8d82d72
parent74e78498cf90cd26fadd2264586fcb9c1e404b8a (diff)
parente35300a6687e1d8fa52c3596ae67ddca757e0e28 (diff)
Merge pull request #874 from masariello/position-independent-code
Enable position-independent code, and add PDB files to packages for MSVC builds
-rw-r--r--CMakeLists.txt28
1 files changed, 28 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8b2e89a..a8dfaa9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,6 +24,8 @@ PROJECT(hiredis VERSION "${VERSION}")
# Hiredis requires C99
SET(CMAKE_C_STANDARD 99)
+SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
+SET(CMAKE_DEBUG_POSTFIX d)
SET(ENABLE_EXAMPLES OFF CACHE BOOL "Enable building hiredis examples")
@@ -49,6 +51,10 @@ ADD_LIBRARY(hiredis_static STATIC ${hiredis_sources})
SET_TARGET_PROPERTIES(hiredis
PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE
VERSION "${HIREDIS_SONAME}")
+SET_TARGET_PROPERTIES(hiredis_static
+ PROPERTIES COMPILE_PDB_NAME hiredis_static)
+SET_TARGET_PROPERTIES(hiredis_static
+ PROPERTIES COMPILE_PDB_NAME_DEBUG hiredis_static${CMAKE_DEBUG_POSTFIX})
IF(WIN32 OR MINGW)
TARGET_LINK_LIBRARIES(hiredis PUBLIC ws2_32 crypt32)
TARGET_LINK_LIBRARIES(hiredis_static PUBLIC ws2_32 crypt32)
@@ -91,6 +97,15 @@ INSTALL(TARGETS hiredis hiredis_static
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+if (MSVC)
+ INSTALL(FILES $<TARGET_PDB_FILE:hiredis>
+ DESTINATION ${CMAKE_INSTALL_BINDIR}
+ CONFIGURATIONS Debug RelWithDebInfo)
+ INSTALL(FILES $<TARGET_FILE_DIR:hiredis_static>/$<TARGET_FILE_BASE_NAME:hiredis_static>.pdb
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ CONFIGURATIONS Debug RelWithDebInfo)
+endif()
+
# For NuGet packages
INSTALL(FILES hiredis.targets
DESTINATION build/native)
@@ -146,6 +161,10 @@ IF(ENABLE_SSL)
PROPERTIES
WINDOWS_EXPORT_ALL_SYMBOLS TRUE
VERSION "${HIREDIS_SONAME}")
+ SET_TARGET_PROPERTIES(hiredis_ssl_static
+ PROPERTIES COMPILE_PDB_NAME hiredis_ssl_static)
+ SET_TARGET_PROPERTIES(hiredis_ssl_static
+ PROPERTIES COMPILE_PDB_NAME_DEBUG hiredis_ssl_static${CMAKE_DEBUG_POSTFIX})
TARGET_INCLUDE_DIRECTORIES(hiredis_ssl PRIVATE "${OPENSSL_INCLUDE_DIR}")
TARGET_INCLUDE_DIRECTORIES(hiredis_ssl_static PRIVATE "${OPENSSL_INCLUDE_DIR}")
@@ -163,6 +182,15 @@ IF(ENABLE_SSL)
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ if (MSVC)
+ INSTALL(FILES $<TARGET_PDB_FILE:hiredis_ssl>
+ DESTINATION ${CMAKE_INSTALL_BINDIR}
+ CONFIGURATIONS Debug RelWithDebInfo)
+ INSTALL(FILES $<TARGET_FILE_DIR:hiredis_ssl_static>/$<TARGET_FILE_BASE_NAME:hiredis_ssl_static>.pdb
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ CONFIGURATIONS Debug RelWithDebInfo)
+ endif()
+
INSTALL(FILES hiredis_ssl.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hiredis)