diff options
author | Konstantin Podsvirov <konstantin@podsvirov.pro> | 2015-08-31 15:20:18 +0300 |
---|---|---|
committer | Konstantin Podsvirov <konstantin@podsvirov.pro> | 2015-08-31 15:20:18 +0300 |
commit | db014600427ad3618625d20f4ad6b5a2e3b7bdd2 (patch) | |
tree | 046032de94e6ea00ec469920d5ed71fc438e1318 /cmake/CMakeLists.txt | |
parent | 0087da9d4775f79c67362cc89c653f3a33a9bae2 (diff) | |
download | protobuf-db014600427ad3618625d20f4ad6b5a2e3b7bdd2.tar.gz protobuf-db014600427ad3618625d20f4ad6b5a2e3b7bdd2.tar.bz2 protobuf-db014600427ad3618625d20f4ad6b5a2e3b7bdd2.zip |
Improved configure.ac parsing
Diffstat (limited to 'cmake/CMakeLists.txt')
-rw-r--r-- | cmake/CMakeLists.txt | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 33e069fe..aa76a16a 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -5,6 +5,7 @@ cmake_minimum_required(VERSION 2.8) project(protobuf C CXX) # Options +option(protobuf_VERBOSE "Enable for verbose output" OFF) option(BUILD_TESTING "Build tests" ON) option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF) if (MSVC) @@ -14,29 +15,40 @@ endif (MSVC) # Path to main configure script set(protobuf_CONFIGURE_SCRIPT "../configure.ac") -# Parse version from configure script -file(STRINGS "${protobuf_CONFIGURE_SCRIPT}" protobuf_VERSION_LINE - LIMIT_COUNT 1 - REGEX "^AC_INIT") -# Replace special characters -string(REPLACE "(" "_" protobuf_VERSION_LINE ${protobuf_VERSION_LINE}) -string(REPLACE ")" "_" protobuf_VERSION_LINE ${protobuf_VERSION_LINE}) -string(REPLACE "[" "_" protobuf_VERSION_LINE ${protobuf_VERSION_LINE}) -string(REPLACE "]" "_" protobuf_VERSION_LINE ${protobuf_VERSION_LINE}) -# Parse version string -string(REGEX REPLACE "^AC_INIT__Protocol Buffers_,_([^_]+).*$" "\\1" - protobuf_VERSION_STRING "${protobuf_VERSION_LINE}") +# Parse configure script +set(protobuf_AC_INIT_REGEX + "^AC_INIT\\(\\[([^]]+)\\],\\[([^]]+)\\],\\[([^]]+)\\],\\[([^]]+)\\]\\)$") +file(STRINGS "${protobuf_CONFIGURE_SCRIPT}" protobuf_AC_INIT_LINE + LIMIT_COUNT 1 REGEX "^AC_INIT") +# Description +string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\1" + protobuf_DESCRIPTION "${protobuf_AC_INIT_LINE}") +# Version +string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\2" + protobuf_VERSION_STRING "${protobuf_AC_INIT_LINE}") +# Contact +string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\3" + protobuf_CONTACT "${protobuf_AC_INIT_LINE}") # Parse version tweaks -string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*$" "\\1" +set(protobuf_VERSION_REGEX "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*$") +string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\1" protobuf_VERSION_MAJOR "${protobuf_VERSION_STRING}") -string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*$" "\\2" +string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\2" protobuf_VERSION_MINOR "${protobuf_VERSION_STRING}") -string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*$" "\\3" +string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\3" protobuf_VERSION_PATCH "${protobuf_VERSION_STRING}") # Package version set(protobuf_VERSION "${protobuf_VERSION_MAJOR}.${protobuf_VERSION_MINOR}.${protobuf_VERSION_PATCH}") +if(protobuf_VERBOSE) + message(STATUS "Configuration script parsing status [") + message(STATUS " Description : ${protobuf_DESCRIPTION}") + message(STATUS " Version : ${protobuf_VERSION} (${protobuf_VERSION_STRING})") + message(STATUS " Contact : ${protobuf_CONTACT}") + message(STATUS "]") +endif() + add_definitions(-DGOOGLE_PROTOBUF_CMAKE_BUILD) find_package(Threads REQUIRED) |