add support for using system protoc instead of version in submodule (#698)

This commit is contained in:
redPanther 2016-06-13 08:11:57 +02:00 committed by brindosch
parent 9f564f8d89
commit f0884ec25b
1 changed files with 27 additions and 19 deletions

View File

@ -9,8 +9,14 @@ if(ENABLE_WS281XPWM)
external/rpi_ws281x/mailbox.c external/rpi_ws281x/ws2811.c
external/rpi_ws281x/pwm.c external/rpi_ws281x/dma.c
external/rpi_ws281x/rpihw.c)
endif(ENABLE_WS281XPWM)
endif()
set(USE_SYSTEM_PROTO_LIBS OFF CACHE BOOL "use protobuf library from system")
if (USE_SYSTEM_PROTO_LIBS)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIRS})
else ()
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared protobuf library")
add_subdirectory(external/protobuf)
@ -30,6 +36,8 @@ set(PROTOBUF_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIRS} PARENT_SCOPE)
# define the protoc executable at the parent scope
get_property(PROTOBUF_PROTOC_EXECUTABLE TARGET protoc_compiler PROPERTY LOCATION)
set(PROTOBUF_PROTOC_EXECUTABLE ${PROTOBUF_PROTOC_EXECUTABLE} PARENT_SCOPE)
endif()
message(STATUS "Using protobuf compiler: " ${PROTOBUF_PROTOC_EXECUTABLE})
#=============================================================================
@ -76,7 +84,7 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS)
endforeach()
endif()
if(CMAKE_CROSSCOMPILING)
if(CMAKE_CROSSCOMPILING OR USE_SYSTEM_PROTO_LIBS)
set(PROTOC_DEPENDENCY ${PROTOBUF_PROTOC_EXECUTABLE})
else()
set(PROTOC_DEPENDENCY protoc_compiler)