summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Brewer <jzb0012@auburn.edu>2019-01-21 13:57:11 -0600
committerMark Nunberg <mnunberg@haskalah.org>2019-02-20 05:01:09 -0500
commit7d38176bdbe55621dfb547d3d481c700dcdba721 (patch)
tree2faf33d5d45cf1dee98704b03adada4462a5b318
parent58d0e283331e778b11f4104d8cb4e8d5d7d9aa09 (diff)
Call project() with parsed version string
Signed-off-by: Justin Brewer <jzb0012@auburn.edu>
-rw-r--r--CMakeLists.txt19
-rw-r--r--hiredis.pc.in2
2 files changed, 9 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 51020ee..f40bbc3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,26 +1,23 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0)
INCLUDE(GNUInstallDirs)
-PROJECT(redisearch)
-SET(ENABLE_EXAMPLES OFF CACHE BOOL "Enable building hiredis examples")
-
-# Get the version numbers
MACRO(getVersionBit name)
-
-EXECUTE_PROCESS(
- WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
- COMMAND grep "${name}" hiredis.h COMMAND awk "{print $3}"
- OUTPUT_VARIABLE "${name}"
- OUTPUT_STRIP_TRAILING_WHITESPACE)
+ 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)
-
SET(VERSION "${HIREDIS_MAJOR}.${HIREDIS_MINOR}.${HIREDIS_PATCH}")
MESSAGE("Detected version: ${VERSION}")
+PROJECT(hiredis VERSION "${VERSION}")
+
+SET(ENABLE_EXAMPLES OFF CACHE BOOL "Enable building hiredis examples")
+
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
ADD_LIBRARY(hiredis SHARED
diff --git a/hiredis.pc.in b/hiredis.pc.in
index 22ec937..140b040 100644
--- a/hiredis.pc.in
+++ b/hiredis.pc.in
@@ -6,6 +6,6 @@ pkgincludedir=${includedir}/hiredis
Name: hiredis
Description: Minimalistic C client library for Redis.
-Version: @VERSION@
+Version: @PROJECT_VERSION@
Libs: -L${libdir} -lhiredis
Cflags: -I${pkgincludedir} -D_FILE_OFFSET_BITS=64