From 69faddb32e76146218f2da28b1af496a21b7cbba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 19 Apr 2018 17:39:30 -0700 Subject: [PATCH] CMake: Read rocksdb version from version.h header file Summary: This replaces reading the rocksdb version by external shell script. This does not work reliably on Windows (I wander how it works on AppVeyor). Closes https://github.com/facebook/rocksdb/pull/3737 Differential Revision: D7703106 Pulled By: ajkr fbshipit-source-id: 4079c7c77431757e9ddc801363ed896b18fdbf23 --- CMakeLists.txt | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d9dfd7a5..e5ff0d9bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -132,19 +132,17 @@ endif() string(REGEX REPLACE "[^0-9a-f]+" "" GIT_SHA "${GIT_SHA}") -set(SH_CMD "sh") -execute_process(COMMAND - ${SH_CMD} -c "build_tools/version.sh full" - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - OUTPUT_VARIABLE ROCKSDB_VERSION -) -string(STRIP "${ROCKSDB_VERSION}" ROCKSDB_VERSION) -execute_process(COMMAND - ${SH_CMD} -c "build_tools/version.sh major" - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - OUTPUT_VARIABLE ROCKSDB_VERSION_MAJOR -) -string(STRIP "${ROCKSDB_VERSION_MAJOR}" ROCKSDB_VERSION_MAJOR) + +# Read rocksdb version from version.h header file. +file(READ include/rocksdb/version.h version_header_file) +string(REGEX MATCH "#define ROCKSDB_MAJOR ([0-9]+)" _ ${version_header_file}) +set(ROCKSDB_VERSION_MAJOR ${CMAKE_MATCH_1}) +string(REGEX MATCH "#define ROCKSDB_MINOR ([0-9]+)" _ ${version_header_file}) +set(ROCKSDB_VERSION_MINOR ${CMAKE_MATCH_1}) +string(REGEX MATCH "#define ROCKSDB_PATCH ([0-9]+)" _ ${version_header_file}) +set(ROCKSDB_VERSION_PATCH ${CMAKE_MATCH_1}) +set(ROCKSDB_VERSION ${ROCKSDB_VERSION_MAJOR}.${ROCKSDB_VERSION_MINOR}.${ROCKSDB_VERSION_PATCH}) + option(WITH_MD_LIBRARY "build with MD" ON) if(WIN32 AND MSVC)