protobuf-cmake icon indicating copy to clipboard operation
protobuf-cmake copied to clipboard

CMake build support for Google Protobufs

protobuf-cmake: CMake build files for Protocol Buffers

Written by Jesper Eskilson ([email protected]) with contributions from several other people.

Requirements

  • CMake version 2.6
  • Protobuf version 2.5.0 or 2.6.1

Download links

http://www.cmake.org/cmake/resources/software.html http://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz

Instructions

The CMake variable PROTOBUF_ROOT needs to be set to the location of the Protocol Buffers sources. When running CMake on the command line, this can be set like this:

$ cd build $ cmake /path/to/protobuf-cmake -DPROTOBUF_ROOT=/path/to/protobufs

If you specify -DDOWNLOAD_PROTOBUF=1, the script will automatically download protobuf.

For windows users with Visual Studio, an example build script can be like this:

::put this "build-vs2013.bat" file under root folder of this repo
@echo off
set build_dir=build-vs2013
if not exist %build_dir% md %build_dir%
cd %build_dir%
cmake .. ^
    -G "Visual Studio 12 2013" ^
    -DCMAKE_INSTALL_PREFIX=%cd%/install ^
    -DPROTOBUF_ROOT=D:/lib/protobuf-2.6.1 ^
    -DCMAKE_BUILD_TYPE=Debug

cmake --build . --config Debug
cmake --build . --target install --config Debug

cmake --build . --config Release
cmake --build . --target install --config Release

cd ..