Fix buid against flat-+/protobuf system libs (#934)

This commit is contained in:
Mirko Vogt 2020-08-30 14:47:12 +02:00 committed by GitHub
parent 4971a07f26
commit 5a684e2056
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,12 +19,8 @@ endif()
set(USE_SYSTEM_FLATBUFFERS_LIBS ${DEFAULT_USE_SYSTEM_FLATBUFFERS_LIBS} CACHE BOOL "use flatbuffers library from system") set(USE_SYSTEM_FLATBUFFERS_LIBS ${DEFAULT_USE_SYSTEM_FLATBUFFERS_LIBS} CACHE BOOL "use flatbuffers library from system")
if (USE_SYSTEM_FLATBUFFERS_LIBS) if (USE_SYSTEM_FLATBUFFERS_LIBS)
if (ENABLE_AMLOGIC) find_program(FLATBUFFERS_FLATC_EXECUTABLE NAMES flatc REQUIRED)
find_program(FLATBUFFERS_FLATC_EXECUTABLE NAMES flatc REQUIRED) find_package(Flatbuffers REQUIRED)
else ()
find_package(flatbuffers REQUIRED)
endif()
include_directories(${FLATBUFFERS_INCLUDE_DIRS})
else () else ()
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared flatbuffers library") set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared flatbuffers library")
set(FLATBUFFERS_BUILD_TESTS OFF CACHE BOOL "Build Flatbuffers with tests") set(FLATBUFFERS_BUILD_TESTS OFF CACHE BOOL "Build Flatbuffers with tests")
@ -41,7 +37,6 @@ else ()
# define the include for the flatbuffers library at the parent scope # define the include for the flatbuffers library at the parent scope
set(FLATBUFFERS_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/external/flatbuffers/include") set(FLATBUFFERS_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/external/flatbuffers/include")
set(FLATBUFFERS_INCLUDE_DIRS ${FLATBUFFERS_INCLUDE_DIRS} PARENT_SCOPE)
IF (NOT CMAKE_CROSSCOMPILING) IF (NOT CMAKE_CROSSCOMPILING)
# define the flatc executable at the parent scope # define the flatc executable at the parent scope
@ -51,10 +46,11 @@ else ()
#Includ of flatc_export.cmake detects that flatc target is defined aand returns before using the definitions written by export #Includ of flatc_export.cmake detects that flatc target is defined aand returns before using the definitions written by export
set ( FLATBUFFERS_FLATC_EXECUTABLE "${CMAKE_BINARY_DIR}/../build-x86x64/bin/flatc") set ( FLATBUFFERS_FLATC_EXECUTABLE "${CMAKE_BINARY_DIR}/../build-x86x64/bin/flatc")
endif() endif()
set(FLATBUFFERS_FLATC_EXECUTABLE ${FLATBUFFERS_FLATC_EXECUTABLE} PARENT_SCOPE)
endif() endif()
set(FLATBUFFERS_FLATC_EXECUTABLE ${FLATBUFFERS_FLATC_EXECUTABLE} PARENT_SCOPE)
set(FLATBUFFERS_INCLUDE_DIRS ${FLATBUFFERS_INCLUDE_DIRS} PARENT_SCOPE)
include_directories(${FLATBUFFERS_INCLUDE_DIRS})
message(STATUS "Using flatbuffers compiler: " ${FLATBUFFERS_FLATC_EXECUTABLE}) message(STATUS "Using flatbuffers compiler: " ${FLATBUFFERS_FLATC_EXECUTABLE})
@ -62,23 +58,13 @@ function(compile_flattbuffer_schema SRC_FBS OUTPUT_DIR)
string(REGEX REPLACE "\\.fbs$" "_generated.h" GEN_HEADER ${SRC_FBS}) string(REGEX REPLACE "\\.fbs$" "_generated.h" GEN_HEADER ${SRC_FBS})
set_property(SOURCE ${GEN_HEADER} PROPERTY SKIP_AUTOMOC ON) set_property(SOURCE ${GEN_HEADER} PROPERTY SKIP_AUTOMOC ON)
if (ENABLE_AMLOGIC) add_custom_command(
add_custom_command( OUTPUT ${GEN_HEADER}
OUTPUT ${GEN_HEADER} COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" -c --no-includes --gen-mutable
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" -c --no-includes --gen-mutable --gen-object-api
--gen-object-api -o "${OUTPUT_DIR}"
-o "${OUTPUT_DIR}" "${SRC_FBS}"
"${SRC_FBS}" DEPENDS "${FLATBUFFERS_FLATC_EXECUTABLE}" ${SRC_FBS})
DEPENDS ${SRC_FBS})
else()
add_custom_command(
OUTPUT ${GEN_HEADER}
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" -c --no-includes --gen-mutable
--gen-object-api
-o "${OUTPUT_DIR}"
"${SRC_FBS}"
DEPENDS flatc ${SRC_FBS})
endif()
endfunction() endfunction()
#============================================================================= #=============================================================================
@ -89,11 +75,6 @@ set(USE_SYSTEM_PROTO_LIBS ${DEFAULT_USE_SYSTEM_PROTO_LIBS} CACHE BOOL "use proto
if (USE_SYSTEM_PROTO_LIBS) if (USE_SYSTEM_PROTO_LIBS)
find_package(Protobuf REQUIRED) find_package(Protobuf REQUIRED)
if (ENABLE_AMLOGIC)
set(PROTOBUF_INCLUDE_DIRS "${Protobuf_INCLUDE_DIRS}" PARENT_SCOPE)
set(PROTOBUF_PROTOC_EXECUTABLE "${Protobuf_PROTOC_EXECUTABLE}" PARENT_SCOPE)
endif()
include_directories(${PROTOBUF_INCLUDE_DIRS})
else () else ()
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared protobuf library") set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared protobuf library")
add_subdirectory(external/protobuf) add_subdirectory(external/protobuf)
@ -108,13 +89,14 @@ else ()
endif() endif()
# define the include for the protobuf library at the parent scope # 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 "${CMAKE_CURRENT_SOURCE_DIR}/external/protobuf/src")
set(PROTOBUF_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIRS} PARENT_SCOPE)
# define the protoc executable at the parent scope # define the protoc executable at the parent scope
get_property(PROTOBUF_PROTOC_EXECUTABLE TARGET protoc_compiler PROPERTY LOCATION) get_property(PROTOBUF_PROTOC_EXECUTABLE TARGET protoc_compiler PROPERTY LOCATION)
set(PROTOBUF_PROTOC_EXECUTABLE ${PROTOBUF_PROTOC_EXECUTABLE} PARENT_SCOPE)
endif() endif()
set(PROTOBUF_PROTOC_EXECUTABLE ${PROTOBUF_PROTOC_EXECUTABLE} PARENT_SCOPE)
set(PROTOBUF_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIRS} PARENT_SCOPE)
include_directories(${PROTOBUF_INCLUDE_DIRS})
message(STATUS "Using protobuf compiler: " ${PROTOBUF_PROTOC_EXECUTABLE}) message(STATUS "Using protobuf compiler: " ${PROTOBUF_PROTOC_EXECUTABLE})