summaryrefslogtreecommitdiff
path: root/compiler/cpp/CMakeLists.txt
diff options
context:
space:
mode:
authorPascal Bach <pascal.bach@siemens.com>2014-04-23 18:19:06 +0200
committerone <one@dev.sbt.siemens.com>2014-06-10 13:33:58 +0200
commit42be4e818ada259080811a87fb239fa81222f581 (patch)
tree325f5c729aa074f6280c59f0023329dc078834b8 /compiler/cpp/CMakeLists.txt
parent6eb015aa555ba120c156e21a8a9ecff15589c7b0 (diff)
downloadthrift-42be4e818ada259080811a87fb239fa81222f581.tar.gz
Get thrift version from configure.ac for CMake build
Diffstat (limited to 'compiler/cpp/CMakeLists.txt')
-rw-r--r--compiler/cpp/CMakeLists.txt19
1 files changed, 13 insertions, 6 deletions
diff --git a/compiler/cpp/CMakeLists.txt b/compiler/cpp/CMakeLists.txt
index 5275a922a..5e07178ca 100644
--- a/compiler/cpp/CMakeLists.txt
+++ b/compiler/cpp/CMakeLists.txt
@@ -22,14 +22,19 @@ cmake_minimum_required(VERSION 2.8)
project(thrift-compiler)
-# TODO: Where to get correct version information
-set(thrift_VERSION_MAJOR 0)
-set(thrift_VERSION_MINOR 9)
-set(thrift_VERSION_PATCH 2)
-set(thrift_VERSION "${thrift_VERSION_MAJOR}.${thrift_VERSION_MINOR}.${thrift_VERSION_PATCH}")
+# Read the version information from the Autoconf file
+file (STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/../../configure.ac" CONFIGURE_AC REGEX "AC_INIT\\(.*\\)" )
# The following variable is used in the version.h.in file
-set(PACKAGE_VERSION ${thrift_VERSION})
+string(REGEX REPLACE "AC_INIT\\(\\[.*\\], \\[([0-9]+\\.[0-9]+\\.[0-9]+(-dev)?)\\]\\)" "\\1" PACKAGE_VERSION ${CONFIGURE_AC})
+message(STATUS "Thrift package version: ${PACKAGE_VERSION}")
+
+# These are internal to CMake
+string(REGEX REPLACE "([0-9]+\\.[0-9]+\\.[0-9]+)(-dev)?" "\\1" thrift_VERSION ${PACKAGE_VERSION})
+string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" thrift_VERSION_MAJOR ${thrift_VERSION})
+string(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" thrift_VERSION_MINOR ${thrift_VERSION})
+string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" thrift_VERSION_PATCH ${thrift_VERSION})
+message(STATUS "Thrift version: ${thrift_VERSION} (${thrift_VERSION_MAJOR}.${thrift_VERSION_MINOR}.${thrift_VERSION_PATCH})")
# Windows has a different header
if(WIN32)
@@ -139,6 +144,8 @@ THRIFT_ADD_COMPILER(lua "Enable compiler for Lua" ON)
include_directories(${CMAKE_CURRENT_BINARY_DIR} src)
add_executable(thrift ${thrift_SOURCES})
+set_target_properties(thrift PROPERTIES VERSION ${thrift_VERSION})
+
target_link_libraries(thrift libparse)
if(NOT WIN32)