2009-09-21 04:12:39 +04:00
|
|
|
# Locate and configure the Google Protocol Buffers library.
|
|
|
|
# Defines the following variables:
|
|
|
|
#
|
|
|
|
# PROTOBUF_FOUND - Found the Google Protocol Buffers library
|
|
|
|
# PROTOBUF_INCLUDE_DIRS - Include directories for Google Protocol Buffers
|
|
|
|
# PROTOBUF_LIBRARIES - The protobuf library
|
|
|
|
#
|
|
|
|
# The following cache variables are also defined:
|
|
|
|
# PROTOBUF_LIBRARY - The protobuf library
|
|
|
|
# PROTOBUF_PROTOC_LIBRARY - The protoc library
|
|
|
|
# PROTOBUF_INCLUDE_DIR - The include directory for protocol buffers
|
|
|
|
# PROTOBUF_PROTOC_EXECUTABLE - The protoc compiler
|
|
|
|
#
|
Fix module docs to be manpage (groff) friendly
Most problems are fixed (or rather worked-around) by making long '====='
separators pre-formatted (i.e. prefixed with two spaces). In order to
preserve visual view, the code examples themselves are prefixed with 3
spaces.
This commit fixes the following man warnings:
$ cmake --help-man - | LANG=C MANWIDTH=80 man --warnings -l - > /dev/null
<standard input>:6024: warning [p 105, 1.7i]: can't break line
<standard input>:6027: warning [p 105, 2.7i]: cannot adjust line
<standard input>:6027: warning [p 105, 2.8i]: can't break line
<standard input>:7142: warning [p 117, 7.8i]: can't break line
<standard input>:7171: warning [p 117, 11.8i]: can't break line
<standard input>:8878: warning [p 136, 9.0i]: can't break line
<standard input>:8887: warning [p 136, 11.5i]: cannot adjust line
<standard input>:8887: warning [p 136, 11.7i]: can't break line
<standard input>:8904: warning [p 136, 14.2i]: can't break line
Patch from Modestas Vainius. See issue #9659.
2009-10-05 18:28:05 +04:00
|
|
|
# ====================================================================
|
|
|
|
# Example:
|
2009-09-21 04:12:39 +04:00
|
|
|
#
|
Fix module docs to be manpage (groff) friendly
Most problems are fixed (or rather worked-around) by making long '====='
separators pre-formatted (i.e. prefixed with two spaces). In order to
preserve visual view, the code examples themselves are prefixed with 3
spaces.
This commit fixes the following man warnings:
$ cmake --help-man - | LANG=C MANWIDTH=80 man --warnings -l - > /dev/null
<standard input>:6024: warning [p 105, 1.7i]: can't break line
<standard input>:6027: warning [p 105, 2.7i]: cannot adjust line
<standard input>:6027: warning [p 105, 2.8i]: can't break line
<standard input>:7142: warning [p 117, 7.8i]: can't break line
<standard input>:7171: warning [p 117, 11.8i]: can't break line
<standard input>:8878: warning [p 136, 9.0i]: can't break line
<standard input>:8887: warning [p 136, 11.5i]: cannot adjust line
<standard input>:8887: warning [p 136, 11.7i]: can't break line
<standard input>:8904: warning [p 136, 14.2i]: can't break line
Patch from Modestas Vainius. See issue #9659.
2009-10-05 18:28:05 +04:00
|
|
|
# find_package(Protobuf REQUIRED)
|
|
|
|
# include_directories(${PROTOBUF_INCLUDE_DIRS})
|
2009-09-21 04:12:39 +04:00
|
|
|
#
|
Fix module docs to be manpage (groff) friendly
Most problems are fixed (or rather worked-around) by making long '====='
separators pre-formatted (i.e. prefixed with two spaces). In order to
preserve visual view, the code examples themselves are prefixed with 3
spaces.
This commit fixes the following man warnings:
$ cmake --help-man - | LANG=C MANWIDTH=80 man --warnings -l - > /dev/null
<standard input>:6024: warning [p 105, 1.7i]: can't break line
<standard input>:6027: warning [p 105, 2.7i]: cannot adjust line
<standard input>:6027: warning [p 105, 2.8i]: can't break line
<standard input>:7142: warning [p 117, 7.8i]: can't break line
<standard input>:7171: warning [p 117, 11.8i]: can't break line
<standard input>:8878: warning [p 136, 9.0i]: can't break line
<standard input>:8887: warning [p 136, 11.5i]: cannot adjust line
<standard input>:8887: warning [p 136, 11.7i]: can't break line
<standard input>:8904: warning [p 136, 14.2i]: can't break line
Patch from Modestas Vainius. See issue #9659.
2009-10-05 18:28:05 +04:00
|
|
|
# include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
# PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS foo.proto)
|
|
|
|
# add_executable(bar bar.cc ${PROTO_SRCS} ${PROTO_HDRS})
|
|
|
|
# target_link_libraries(bar ${PROTOBUF_LIBRARY})
|
2009-09-21 04:12:39 +04:00
|
|
|
#
|
2009-09-22 06:38:12 +04:00
|
|
|
# NOTE: You may need to link against pthreads, depending
|
2009-09-21 04:12:39 +04:00
|
|
|
# on the platform.
|
Fix module docs to be manpage (groff) friendly
Most problems are fixed (or rather worked-around) by making long '====='
separators pre-formatted (i.e. prefixed with two spaces). In order to
preserve visual view, the code examples themselves are prefixed with 3
spaces.
This commit fixes the following man warnings:
$ cmake --help-man - | LANG=C MANWIDTH=80 man --warnings -l - > /dev/null
<standard input>:6024: warning [p 105, 1.7i]: can't break line
<standard input>:6027: warning [p 105, 2.7i]: cannot adjust line
<standard input>:6027: warning [p 105, 2.8i]: can't break line
<standard input>:7142: warning [p 117, 7.8i]: can't break line
<standard input>:7171: warning [p 117, 11.8i]: can't break line
<standard input>:8878: warning [p 136, 9.0i]: can't break line
<standard input>:8887: warning [p 136, 11.5i]: cannot adjust line
<standard input>:8887: warning [p 136, 11.7i]: can't break line
<standard input>:8904: warning [p 136, 14.2i]: can't break line
Patch from Modestas Vainius. See issue #9659.
2009-10-05 18:28:05 +04:00
|
|
|
# ====================================================================
|
2009-09-22 06:38:12 +04:00
|
|
|
#
|
2009-09-21 04:12:39 +04:00
|
|
|
# PROTOBUF_GENERATE_CPP (public function)
|
|
|
|
# SRCS = Variable to define with autogenerated
|
|
|
|
# source files
|
|
|
|
# HDRS = Variable to define with autogenerated
|
|
|
|
# header files
|
|
|
|
# ARGN = proto files
|
2009-09-22 06:38:12 +04:00
|
|
|
#
|
Fix module docs to be manpage (groff) friendly
Most problems are fixed (or rather worked-around) by making long '====='
separators pre-formatted (i.e. prefixed with two spaces). In order to
preserve visual view, the code examples themselves are prefixed with 3
spaces.
This commit fixes the following man warnings:
$ cmake --help-man - | LANG=C MANWIDTH=80 man --warnings -l - > /dev/null
<standard input>:6024: warning [p 105, 1.7i]: can't break line
<standard input>:6027: warning [p 105, 2.7i]: cannot adjust line
<standard input>:6027: warning [p 105, 2.8i]: can't break line
<standard input>:7142: warning [p 117, 7.8i]: can't break line
<standard input>:7171: warning [p 117, 11.8i]: can't break line
<standard input>:8878: warning [p 136, 9.0i]: can't break line
<standard input>:8887: warning [p 136, 11.5i]: cannot adjust line
<standard input>:8887: warning [p 136, 11.7i]: can't break line
<standard input>:8904: warning [p 136, 14.2i]: can't break line
Patch from Modestas Vainius. See issue #9659.
2009-10-05 18:28:05 +04:00
|
|
|
# ====================================================================
|
2009-09-22 06:38:12 +04:00
|
|
|
|
2009-09-28 19:45:50 +04:00
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
# Copyright 2009 Kitware, Inc.
|
|
|
|
# Copyright 2009 Philip Lowman <philip@yhbt.com>
|
|
|
|
# Copyright 2008 Esben Mose Hansen, Ange Optimization ApS
|
|
|
|
#
|
|
|
|
# Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
# see accompanying file Copyright.txt for details.
|
|
|
|
#
|
|
|
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
# See the License for more information.
|
|
|
|
#=============================================================================
|
|
|
|
# (To distributed this file outside of CMake, substitute the full
|
|
|
|
# License text for the above reference.)
|
2009-09-22 06:38:12 +04:00
|
|
|
|
2009-09-21 04:12:39 +04:00
|
|
|
function(PROTOBUF_GENERATE_CPP SRCS HDRS)
|
|
|
|
if(NOT ARGN)
|
|
|
|
message(SEND_ERROR "Error: PROTOBUF_GENERATE_CPP() called without any proto files")
|
|
|
|
return()
|
|
|
|
endif(NOT ARGN)
|
|
|
|
|
|
|
|
set(${SRCS})
|
|
|
|
set(${HDRS})
|
|
|
|
foreach(FIL ${ARGN})
|
|
|
|
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
|
|
|
|
get_filename_component(FIL_WE ${FIL} NAME_WE)
|
|
|
|
|
|
|
|
list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc")
|
|
|
|
list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h")
|
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h"
|
|
|
|
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
|
|
|
|
ARGS --cpp_out ${CMAKE_CURRENT_BINARY_DIR} --proto_path ${CMAKE_CURRENT_SOURCE_DIR} ${ABS_FIL}
|
|
|
|
DEPENDS ${ABS_FIL}
|
|
|
|
COMMENT "Running C++ protocol buffer compiler on ${FIL}"
|
|
|
|
VERBATIM )
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE)
|
|
|
|
set(${SRCS} ${${SRCS}} PARENT_SCOPE)
|
|
|
|
set(${HDRS} ${${HDRS}} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
|
|
|
|
find_path(PROTOBUF_INCLUDE_DIR google/protobuf/service.h)
|
|
|
|
|
|
|
|
# Google's provided vcproj files generate libraries with a "lib"
|
|
|
|
# prefix on Windows
|
|
|
|
if(WIN32)
|
|
|
|
set(PROTOBUF_ORIG_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
|
|
|
|
set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
find_library(PROTOBUF_LIBRARY NAMES protobuf
|
|
|
|
DOC "The Google Protocol Buffers Library"
|
|
|
|
)
|
|
|
|
find_library(PROTOBUF_PROTOC_LIBRARY NAMES protoc
|
|
|
|
DOC "The Google Protocol Buffers Compiler Library"
|
|
|
|
)
|
|
|
|
find_program(PROTOBUF_PROTOC_EXECUTABLE NAMES protoc
|
|
|
|
DOC "The Google Protocol Buffers Compiler"
|
|
|
|
)
|
|
|
|
|
2009-09-21 05:15:33 +04:00
|
|
|
mark_as_advanced(PROTOBUF_INCLUDE_DIR
|
|
|
|
PROTOBUF_LIBRARY
|
|
|
|
PROTOBUF_PROTOC_LIBRARY
|
|
|
|
PROTOBUF_PROTOC_EXECUTABLE)
|
|
|
|
|
2009-09-21 04:12:39 +04:00
|
|
|
# Restore original find library prefixes
|
|
|
|
if(WIN32)
|
2009-09-21 07:55:47 +04:00
|
|
|
set(CMAKE_FIND_LIBRARY_PREFIXES "${PROTOBUF_ORIG_FIND_LIBRARY_PREFIXES}")
|
2009-09-21 04:12:39 +04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PROTOBUF DEFAULT_MSG
|
|
|
|
PROTOBUF_LIBRARY PROTOBUF_INCLUDE_DIR)
|
|
|
|
|
|
|
|
if(PROTOBUF_FOUND)
|
|
|
|
set(PROTOBUF_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIR})
|
|
|
|
set(PROTOBUF_LIBRARIES ${PROTOBUF_LIBRARY})
|
|
|
|
endif()
|