Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: third_party/protobuf/cmake/CMakeLists.txt

Issue 1842653006: Update //third_party/protobuf to version 3. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/protobuf/benchmarks/readme.txt ('k') | third_party/protobuf/cmake/README.md » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/protobuf/cmake/CMakeLists.txt
diff --git a/third_party/protobuf/cmake/CMakeLists.txt b/third_party/protobuf/cmake/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..15ae457aa2b35640e785759a19e888ce7e15066e
--- /dev/null
+++ b/third_party/protobuf/cmake/CMakeLists.txt
@@ -0,0 +1,151 @@
+# Minimum CMake required
+cmake_minimum_required(VERSION 2.8)
+
+# Project
+project(protobuf C CXX)
+
+# CMake policies
+cmake_policy(SET CMP0022 NEW)
+
+# Options
+option(protobuf_VERBOSE "Enable for verbose output" OFF)
+option(protobuf_BUILD_TESTS "Build tests" ON)
+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)
+if (MSVC)
+ set(protobuf_WITH_ZLIB_DEFAULT OFF)
+else (MSVC)
+ set(protobuf_WITH_ZLIB_DEFAULT ON)
+endif (MSVC)
+option(protobuf_WITH_ZLIB "Build with zlib support" ${protobuf_WITH_ZLIB_DEFAULT})
+set(protobuf_DEBUG_POSTFIX "d"
+ CACHE STRING "Default debug postfix")
+
+# Path to main configure script
+set(protobuf_CONFIGURE_SCRIPT "../configure.ac")
+
+# 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
+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}")
+# 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)
+if (CMAKE_USE_PTHREADS_INIT)
+ add_definitions(-DHAVE_PTHREAD)
+endif (CMAKE_USE_PTHREADS_INIT)
+
+if (protobuf_WITH_ZLIB)
+ find_package(ZLIB)
+ if (ZLIB_FOUND)
+ set(HAVE_ZLIB 1)
+ # FindZLIB module define ZLIB_INCLUDE_DIRS variable
+ # Set ZLIB_INCLUDE_DIRECTORIES for compatible
+ set(ZLIB_INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIRECTORIES} ${ZLIB_INCLUDE_DIRS})
+ # Using imported target if exists
+ if (TARGET ZLIB::ZLIB)
+ set(ZLIB_LIBRARIES ZLIB::ZLIB)
+ endif (TARGET ZLIB::ZLIB)
+ else (ZLIB_FOUND)
+ set(HAVE_ZLIB 0)
+ # Explicitly set these to empty (override NOT_FOUND) so cmake doesn't
+ # complain when we use them later.
+ set(ZLIB_INCLUDE_DIRECTORIES)
+ set(ZLIB_LIBRARIES)
+ endif (ZLIB_FOUND)
+endif (protobuf_WITH_ZLIB)
+
+if (HAVE_ZLIB)
+ add_definitions(-DHAVE_ZLIB)
+endif (HAVE_ZLIB)
+
+if (protobuf_BUILD_SHARED_LIBS)
+ set(protobuf_SHARED_OR_STATIC "SHARED")
+else (protobuf_BUILD_SHARED_LIBS)
+ set(protobuf_SHARED_OR_STATIC "STATIC")
+ # In case we are building static libraries, link also the runtime library statically
+ # so that MSVCR*.DLL is not required at runtime.
+ # https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
+ # This is achieved by replacing msvc option /MD with /MT and /MDd with /MTd
+ # http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F
+ if (MSVC AND protobuf_MSVC_STATIC_RUNTIME)
+ foreach(flag_var
+ CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
+ CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+ if(${flag_var} MATCHES "/MD")
+ string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
+ endif(${flag_var} MATCHES "/MD")
+ endforeach(flag_var)
+ endif (MSVC AND protobuf_MSVC_STATIC_RUNTIME)
+endif (protobuf_BUILD_SHARED_LIBS)
+
+if (MSVC)
+ # Build with multiple processes
+ add_definitions(/MP)
+ add_definitions(/wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305)
+ string(REPLACE "/" "\\" PROTOBUF_SOURCE_WIN32_PATH ${protobuf_SOURCE_DIR})
+ string(REPLACE "/" "\\" PROTOBUF_BINARY_WIN32_PATH ${protobuf_BINARY_DIR})
+ configure_file(extract_includes.bat.in extract_includes.bat)
+endif (MSVC)
+
+get_filename_component(protobuf_source_dir ${protobuf_SOURCE_DIR} PATH)
+
+include_directories(
+ ${ZLIB_INCLUDE_DIRECTORIES}
+ ${protobuf_BINARY_DIR}
+ ${protobuf_source_dir}/src)
+
+if (MSVC)
+ # Add the "lib" prefix for generated .lib outputs.
+ set(LIB_PREFIX lib)
+else (MSVC)
+ # When building with "make", "lib" prefix will be added automatically by
+ # the build tool.
+ set(LIB_PREFIX)
+endif (MSVC)
+
+include(libprotobuf-lite.cmake)
+include(libprotobuf.cmake)
+include(libprotoc.cmake)
+include(protoc.cmake)
+
+if (protobuf_BUILD_TESTS)
+ include(tests.cmake)
+endif (protobuf_BUILD_TESTS)
+
+include(install.cmake)
« no previous file with comments | « third_party/protobuf/benchmarks/readme.txt ('k') | third_party/protobuf/cmake/README.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698