Skip to content

Commit

Permalink
Revert "capture entire version"
Browse files Browse the repository at this point in the history
This reverts commit 7d830d5.
  • Loading branch information
uilianries committed Feb 13, 2024
1 parent 7d830d5 commit 88375e8
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0)

SET(VERSION_REGEX "^#define ${name} (.+)$")
FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/hiredis.h" PROJECT_VERSION REGEX ${VERSION_REGEX})

PROJECT(hiredis LANGUAGES "C" VERSION "${PROJECT_VERSION}")

OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON)
OPTION(ENABLE_SSL "Build hiredis_ssl for SSL support" OFF)
OPTION(DISABLE_TESTS "If tests should be compiled or not" OFF)
Expand All @@ -15,8 +10,21 @@ OPTION(ENABLE_ASYNC_TESTS "Should we run all asynchronous API tests" OFF)
# to ON for those who rely on that historical behaviour.
OPTION(ENABLE_NUGET "Install NuGET packaging details" ON)

MESSAGE("Detected version: ${hiredis_VERSION}")

MACRO(getVersionBit name)
SET(VERSION_REGEX "^#define ${name} (.+)$")
FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/hiredis.h"
VERSION_BIT REGEX ${VERSION_REGEX})
STRING(REGEX REPLACE ${VERSION_REGEX} "\\1" ${name} "${VERSION_BIT}")
ENDMACRO(getVersionBit)

getVersionBit(HIREDIS_MAJOR)
getVersionBit(HIREDIS_MINOR)
getVersionBit(HIREDIS_PATCH)
getVersionBit(HIREDIS_SONAME)
SET(VERSION "${HIREDIS_MAJOR}.${HIREDIS_MINOR}.${HIREDIS_PATCH}")
MESSAGE("Detected version: ${VERSION}")

PROJECT(hiredis LANGUAGES "C" VERSION "${VERSION}")
INCLUDE(GNUInstallDirs)

# Hiredis requires C99
Expand Down Expand Up @@ -45,7 +53,7 @@ set_target_properties(hiredis PROPERTIES EXPORT_NAME ${hiredis_export_name})

SET_TARGET_PROPERTIES(hiredis
PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE
VERSION "${hiredis_VERSION_TWEAK}")
VERSION "${HIREDIS_SONAME}")
IF(MSVC)
SET_TARGET_PROPERTIES(hiredis
PROPERTIES COMPILE_FLAGS /Z7)
Expand Down Expand Up @@ -161,7 +169,7 @@ IF(ENABLE_SSL)
SET_TARGET_PROPERTIES(hiredis_ssl
PROPERTIES
WINDOWS_EXPORT_ALL_SYMBOLS TRUE
VERSION "${hiredis_VERSION_TWEAK}")
VERSION "${HIREDIS_SONAME}")
IF(MSVC)
SET_TARGET_PROPERTIES(hiredis_ssl
PROPERTIES COMPILE_FLAGS /Z7)
Expand Down

0 comments on commit 88375e8

Please sign in to comment.