diff options
author | Feng Xiao <xfxyjwf@gmail.com> | 2015-08-12 23:07:54 -0700 |
---|---|---|
committer | Feng Xiao <xfxyjwf@gmail.com> | 2015-08-12 23:07:54 -0700 |
commit | f818183f9b0c0c8838dd99c54923d8dd6c11d4ed (patch) | |
tree | 92013c28ab035d8bc8c8d7ca8a8a885b34fc9dc2 /cmake/CMakeLists.txt | |
parent | 38a56ee4b19d72c2e9d81a08b018704d1addf561 (diff) | |
parent | 61e078e803241dc9487544ba3d5d377e16d2838b (diff) | |
download | protobuf-f818183f9b0c0c8838dd99c54923d8dd6c11d4ed.tar.gz protobuf-f818183f9b0c0c8838dd99c54923d8dd6c11d4ed.tar.bz2 protobuf-f818183f9b0c0c8838dd99c54923d8dd6c11d4ed.zip |
Merge pull request #673 from podsvirov/topic-cmake-install
Install protobuf from cmake project
Diffstat (limited to 'cmake/CMakeLists.txt')
-rw-r--r-- | cmake/CMakeLists.txt | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 6c91e137..33e069fe 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -1,13 +1,42 @@ +# Minimum CMake required cmake_minimum_required(VERSION 2.8) +# Project project(protobuf C CXX) +# Options option(BUILD_TESTING "Build tests" ON) option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF) if (MSVC) option(ZLIB "Build with zlib support" OFF) 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 version tweaks +string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*$" "\\1" + protobuf_VERSION_MAJOR "${protobuf_VERSION_STRING}") +string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*$" "\\2" + protobuf_VERSION_MINOR "${protobuf_VERSION_STRING}") +string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*$" "\\3" + protobuf_VERSION_PATCH "${protobuf_VERSION_STRING}") +# Package version +set(protobuf_VERSION + "${protobuf_VERSION_MAJOR}.${protobuf_VERSION_MINOR}.${protobuf_VERSION_PATCH}") + add_definitions(-DGOOGLE_PROTOBUF_CMAKE_BUILD) find_package(Threads REQUIRED) @@ -86,6 +115,9 @@ include(libprotobuf-lite.cmake) include(libprotobuf.cmake) include(libprotoc.cmake) include(protoc.cmake) + if (BUILD_TESTING) include(tests.cmake) endif (BUILD_TESTING) + +include(install.cmake) |