cmake: read the version information from VERSION

The version inforamtion for CMake is extracted from the VERSION file not hardcoded in CMakeLists.txt

Reviewed-by: Roger Meier <r.meier@siemens.com>
This commit is contained in:
Pascal Bach 2014-06-24 12:23:50 +02:00
parent 5d7d1d3c07
commit 74397ccbe3

View File

@ -9,9 +9,13 @@ cmake_minimum_required(VERSION 2.8.0)
set(SHARED_LIBRARY_VERSION "22")
set(CPACK_PACKAGE_VERSION_MAJOR "1")
set(CPACK_PACKAGE_VERSION_MINOR "5")
set(CPACK_PACKAGE_VERSION_PATCH "2")
# Read the version information from the VERSION file
file (STRINGS "${CMAKE_SOURCE_DIR}/VERSION" PACKAGE_VERSION )
message(STATUS "Poco package version: ${PACKAGE_VERSION}")
string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" CPACK_PACKAGE_VERSION_MAJOR ${PACKAGE_VERSION})
string(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" CPACK_PACKAGE_VERSION_MINOR ${PACKAGE_VERSION})
string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" CPACK_PACKAGE_VERSION_PATCH ${PACKAGE_VERSION})
SET(COMPLETE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
SET(RELEASE_NAME "Unstable-trunk")
SET(PROJECT_VERSION ${COMPLETE_VERSION})