Skip to content

Commit

Permalink
add version info to source code
Browse files Browse the repository at this point in the history
  • Loading branch information
sewenew committed Mar 17, 2024
1 parent b501af8 commit fe6e72f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
13 changes: 12 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
Expand Down
32 changes: 32 additions & 0 deletions src/sw/redis++/version.h
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit fe6e72f

Please sign in to comment.