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
This commit is contained in:
Paweł Bylica 2018-04-19 17:39:30 -07:00 committed by Facebook Github Bot
parent e1e826b980
commit 69faddb32e

View File

@ -132,19 +132,17 @@ endif()
string(REGEX REPLACE "[^0-9a-f]+" "" GIT_SHA "${GIT_SHA}") string(REGEX REPLACE "[^0-9a-f]+" "" GIT_SHA "${GIT_SHA}")
set(SH_CMD "sh")
execute_process(COMMAND # Read rocksdb version from version.h header file.
${SH_CMD} -c "build_tools/version.sh full" file(READ include/rocksdb/version.h version_header_file)
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} string(REGEX MATCH "#define ROCKSDB_MAJOR ([0-9]+)" _ ${version_header_file})
OUTPUT_VARIABLE ROCKSDB_VERSION set(ROCKSDB_VERSION_MAJOR ${CMAKE_MATCH_1})
) string(REGEX MATCH "#define ROCKSDB_MINOR ([0-9]+)" _ ${version_header_file})
string(STRIP "${ROCKSDB_VERSION}" ROCKSDB_VERSION) set(ROCKSDB_VERSION_MINOR ${CMAKE_MATCH_1})
execute_process(COMMAND string(REGEX MATCH "#define ROCKSDB_PATCH ([0-9]+)" _ ${version_header_file})
${SH_CMD} -c "build_tools/version.sh major" set(ROCKSDB_VERSION_PATCH ${CMAKE_MATCH_1})
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} set(ROCKSDB_VERSION ${ROCKSDB_VERSION_MAJOR}.${ROCKSDB_VERSION_MINOR}.${ROCKSDB_VERSION_PATCH})
OUTPUT_VARIABLE ROCKSDB_VERSION_MAJOR
)
string(STRIP "${ROCKSDB_VERSION_MAJOR}" ROCKSDB_VERSION_MAJOR)
option(WITH_MD_LIBRARY "build with MD" ON) option(WITH_MD_LIBRARY "build with MD" ON)
if(WIN32 AND MSVC) if(WIN32 AND MSVC)