diff --git a/CMakeLists.txt b/CMakeLists.txt index 44e8ca4..ae2507e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,17 @@ cmake_minimum_required(VERSION 3.1) -set(REDIS_PLUS_PLUS_VERSION "1.3.13") +function(GET_VERSION VERSION_PART VERSION_NUM) + set(VERSION_REGEX "^const int VERSION_${VERSION_PART} = (.+);$") + file(STRINGS "src/sw/redis++/version.h" VERSION_INFO REGEX "${VERSION_REGEX}") + string(REGEX REPLACE "${VERSION_REGEX}" "\\1" VERSION_RESULT ${VERSION_INFO}) + set(${VERSION_NUM} ${VERSION_RESULT} PARENT_SCOPE) +endfunction() + +GET_VERSION("MAJOR" REDIS_PLUS_PLUS_VERSION_MAJOR) +GET_VERSION("MINOR" REDIS_PLUS_PLUS_VERSION_MINOR) +GET_VERSION("PATCH" REDIS_PLUS_PLUS_VERSION_PATCH) + +set(REDIS_PLUS_PLUS_VERSION "${REDIS_PLUS_PLUS_VERSION_MAJOR}.${REDIS_PLUS_PLUS_VERSION_MINOR}.${REDIS_PLUS_PLUS_VERSION_PATCH}") message(STATUS "redis-plus-plus version: ${REDIS_PLUS_PLUS_VERSION}") project(redis++ LANGUAGES CXX VERSION ${REDIS_PLUS_PLUS_VERSION}) diff --git a/src/sw/redis++/version.h b/src/sw/redis++/version.h new file mode 100644 index 0000000..9edbd5c --- /dev/null +++ b/src/sw/redis++/version.h @@ -0,0 +1,32 @@ +/************************************************************************** + Copyright (c) 2024 sewenew + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + *************************************************************************/ + +#ifndef SEWENEW_REDISPLUSPLUS_VERSION_H +#define SEWENEW_REDISPLUSPLUS_VERSION_H + +namespace sw { + +namespace redis { + +const int VERSION_MAJOR = 1; +const int VERSION_MINOR = 3; +const int VERSION_PATCH = 13; + +} + +} + +#endif // end SEWENEW_REDISPLUSPLUS_VERSION_H