mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
add support for using system protoc instead of version in submodule (#698)
This commit is contained in:
parent
9f564f8d89
commit
f0884ec25b
34
dependencies/CMakeLists.txt
vendored
34
dependencies/CMakeLists.txt
vendored
@ -9,27 +9,35 @@ if(ENABLE_WS281XPWM)
|
|||||||
external/rpi_ws281x/mailbox.c external/rpi_ws281x/ws2811.c
|
external/rpi_ws281x/mailbox.c external/rpi_ws281x/ws2811.c
|
||||||
external/rpi_ws281x/pwm.c external/rpi_ws281x/dma.c
|
external/rpi_ws281x/pwm.c external/rpi_ws281x/dma.c
|
||||||
external/rpi_ws281x/rpihw.c)
|
external/rpi_ws281x/rpihw.c)
|
||||||
endif(ENABLE_WS281XPWM)
|
endif()
|
||||||
|
|
||||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared protobuf library")
|
set(USE_SYSTEM_PROTO_LIBS OFF CACHE BOOL "use protobuf library from system")
|
||||||
add_subdirectory(external/protobuf)
|
|
||||||
|
|
||||||
if(CMAKE_CROSSCOMPILING)
|
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)
|
||||||
|
|
||||||
|
if(CMAKE_CROSSCOMPILING)
|
||||||
# when crosscompiling import the protoc executable targets from a file generated by a native build
|
# when crosscompiling import the protoc executable targets from a file generated by a native build
|
||||||
option(IMPORT_PROTOC "Protoc export file (protoc_export.cmake) from a native build" "IMPORT_PROTOC-FILE_NOT_FOUND")
|
option(IMPORT_PROTOC "Protoc export file (protoc_export.cmake) from a native build" "IMPORT_PROTOC-FILE_NOT_FOUND")
|
||||||
include(${IMPORT_PROTOC})
|
include(${IMPORT_PROTOC})
|
||||||
else()
|
else()
|
||||||
# export the protoc compiler so it can be used when cross compiling
|
# export the protoc compiler so it can be used when cross compiling
|
||||||
export(TARGETS protoc_compiler FILE "${CMAKE_BINARY_DIR}/protoc_export.cmake")
|
export(TARGETS protoc_compiler FILE "${CMAKE_BINARY_DIR}/protoc_export.cmake")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# define the include for the protobuf library at the parent scope
|
||||||
|
set(PROTOBUF_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/external/protobuf/src")
|
||||||
|
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()
|
endif()
|
||||||
|
|
||||||
# define the include for the protobuf library at the parent scope
|
|
||||||
set(PROTOBUF_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/external/protobuf/src")
|
|
||||||
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)
|
|
||||||
message(STATUS "Using protobuf compiler: " ${PROTOBUF_PROTOC_EXECUTABLE})
|
message(STATUS "Using protobuf compiler: " ${PROTOBUF_PROTOC_EXECUTABLE})
|
||||||
|
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
@ -76,7 +84,7 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS)
|
|||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_CROSSCOMPILING)
|
if(CMAKE_CROSSCOMPILING OR USE_SYSTEM_PROTO_LIBS)
|
||||||
set(PROTOC_DEPENDENCY ${PROTOBUF_PROTOC_EXECUTABLE})
|
set(PROTOC_DEPENDENCY ${PROTOBUF_PROTOC_EXECUTABLE})
|
||||||
else()
|
else()
|
||||||
set(PROTOC_DEPENDENCY protoc_compiler)
|
set(PROTOC_DEPENDENCY protoc_compiler)
|
||||||
|
Loading…
Reference in New Issue
Block a user