Index: third_party/protobuf/cmake/CMakeLists.txt |
diff --git a/third_party/protobuf/cmake/CMakeLists.txt b/third_party/protobuf/cmake/CMakeLists.txt |
index f32a0e4e65e538a91e47cfa09900721e4f3954c4..df3b20126d4b22e492b75a835c2b72cf2df72bf5 100644 |
--- a/third_party/protobuf/cmake/CMakeLists.txt |
+++ b/third_party/protobuf/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}") |
@@ -70,6 +86,7 @@ if (CMAKE_USE_PTHREADS_INIT) |
add_definitions(-DHAVE_PTHREAD) |
endif (CMAKE_USE_PTHREADS_INIT) |
+set(_protobuf_FIND_ZLIB) |
if (protobuf_WITH_ZLIB) |
find_package(ZLIB) |
if (ZLIB_FOUND) |
@@ -80,6 +97,7 @@ if (protobuf_WITH_ZLIB) |
# Using imported target if exists |
if (TARGET ZLIB::ZLIB) |
set(ZLIB_LIBRARIES ZLIB::ZLIB) |
+ set(_protobuf_FIND_ZLIB "if(NOT ZLIB_FOUND)\n find_package(ZLIB)\nendif()") |
endif (TARGET ZLIB::ZLIB) |
else (ZLIB_FOUND) |
set(HAVE_ZLIB 0) |
@@ -141,6 +159,10 @@ else (MSVC) |
set(LIB_PREFIX) |
endif (MSVC) |
+if (protobuf_UNICODE) |
+ add_definitions(-DUNICODE -D_UNICODE) |
+endif (protobuf_UNICODE) |
+ |
include(libprotobuf-lite.cmake) |
include(libprotobuf.cmake) |
include(libprotoc.cmake) |
@@ -151,3 +173,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() |