aboutsummaryrefslogtreecommitdiff
path: root/cmake/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/CMakeLists.txt')
-rw-r--r--cmake/CMakeLists.txt36
1 files changed, 30 insertions, 6 deletions
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index f32a0e4e..07b176d9 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -1,22 +1,28 @@
# Minimum CMake required
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 2.8.12)
-# Project
-project(protobuf C CXX)
+if(protobuf_VERBOSE)
+ message(STATUS "Protocol Buffers Configuring...")
+endif()
# CMake policies
cmake_policy(SET CMP0022 NEW)
+# Project
+project(protobuf C CXX)
+
# Options
-option(protobuf_VERBOSE "Enable for verbose output" OFF)
option(protobuf_BUILD_TESTS "Build tests" ON)
+option(protobuf_BUILD_EXAMPLES "Build examples" OFF)
if (BUILD_SHARED_LIBS)
set(protobuf_BUILD_SHARED_LIBS_DEFAULT ON)
else (BUILD_SHARED_LIBS)
set(protobuf_BUILD_SHARED_LIBS_DEFAULT OFF)
endif (BUILD_SHARED_LIBS)
option(protobuf_BUILD_SHARED_LIBS "Build Shared Libraries" ${protobuf_BUILD_SHARED_LIBS_DEFAULT})
-option(protobuf_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON)
+include(CMakeDependentOption)
+cmake_dependent_option(protobuf_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON
+ "NOT protobuf_BUILD_SHARED_LIBS" OFF)
if (MSVC)
set(protobuf_WITH_ZLIB_DEFAULT OFF)
else (MSVC)
@@ -25,6 +31,9 @@ endif (MSVC)
option(protobuf_WITH_ZLIB "Build with zlib support" ${protobuf_WITH_ZLIB_DEFAULT})
set(protobuf_DEBUG_POSTFIX "d"
CACHE STRING "Default debug postfix")
+mark_as_advanced(protobuf_DEBUG_POSTFIX)
+# User options
+include(protobuf-options.cmake)
# Path to main configure script
set(protobuf_CONFIGURE_SCRIPT "../configure.ac")
@@ -44,17 +53,24 @@ string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\2"
string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\3"
protobuf_CONTACT "${protobuf_AC_INIT_LINE}")
# Parse version tweaks
-set(protobuf_VERSION_REGEX "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*$")
+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 "${protobuf_VERSION_REGEX}" "\\2"
protobuf_VERSION_MINOR "${protobuf_VERSION_STRING}")
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\3"
protobuf_VERSION_PATCH "${protobuf_VERSION_STRING}")
+string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\4"
+ protobuf_VERSION_PRERELEASE "${protobuf_VERSION_STRING}")
+
# Package version
set(protobuf_VERSION
"${protobuf_VERSION_MAJOR}.${protobuf_VERSION_MINOR}.${protobuf_VERSION_PATCH}")
+if(protobuf_VERSION_PRERELEASE)
+ set(protobuf_VERSION "${protobuf_VERSION}-${protobuf_VERSION_PRERELEASE}")
+endif()
+
if(protobuf_VERBOSE)
message(STATUS "Configuration script parsing status [")
message(STATUS " Description : ${protobuf_DESCRIPTION}")
@@ -151,3 +167,11 @@ if (protobuf_BUILD_TESTS)
endif (protobuf_BUILD_TESTS)
include(install.cmake)
+
+if (protobuf_BUILD_EXAMPLES)
+ include(examples.cmake)
+endif (protobuf_BUILD_EXAMPLES)
+
+if(protobuf_VERBOSE)
+ message(STATUS "Protocol Buffers Configuring done")
+endif()