Call project() with parsed version string

Signed-off-by: Justin Brewer <jzb0012@auburn.edu>
This commit is contained in:
Justin Brewer 2019-01-21 13:57:11 -06:00 committed by Mark Nunberg
parent 58d0e28333
commit 7d38176bdb
2 changed files with 9 additions and 12 deletions

View File

@ -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

View File

@ -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