mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-30 13:30:00 +00:00
Fix/cmake build grpc (#7028)
* BuildFlatbuffers.cmake: add verbose on build * BuildFlatbuffers.cmake: properly add *.fb.* files with --grpc argument When "--grpc" argument is provided as an extra flag, resulting grpc files should be added as part of the interface library. This prevent adding .fb.cc files manually to the build. V2: fix dependency on grpc files
This commit is contained in:
@@ -230,16 +230,30 @@ function(flatbuffers_generate_headers)
|
|||||||
foreach(schema ${FLATBUFFERS_GENERATE_HEADERS_SCHEMAS})
|
foreach(schema ${FLATBUFFERS_GENERATE_HEADERS_SCHEMAS})
|
||||||
get_filename_component(filename ${schema} NAME_WE)
|
get_filename_component(filename ${schema} NAME_WE)
|
||||||
set(generated_include "${generated_include_dir}/${filename}_generated.h")
|
set(generated_include "${generated_include_dir}/${filename}_generated.h")
|
||||||
|
|
||||||
|
# Generate files for grpc if needed
|
||||||
|
set(generated_source_file)
|
||||||
|
if("${FLATBUFFERS_GENERATE_HEADERS_FLAGS}" MATCHES "--grpc")
|
||||||
|
# Check if schema file contain a rpc_service definition
|
||||||
|
file(STRINGS ${schema} has_grpc REGEX "rpc_service")
|
||||||
|
if(has_grpc)
|
||||||
|
list(APPEND generated_include "${generated_include_dir}/${filename}.grpc.fb.h")
|
||||||
|
set(generated_source_file "${generated_include_dir}/${filename}.grpc.fb.cc")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${generated_include}
|
OUTPUT ${generated_include} ${generated_source_file}
|
||||||
COMMAND ${FLATC} ${FLATC_ARGS}
|
COMMAND ${FLATC} ${FLATC_ARGS}
|
||||||
-o ${generated_include_dir}
|
-o ${generated_include_dir}
|
||||||
${include_params}
|
${include_params}
|
||||||
-c ${schema}
|
-c ${schema}
|
||||||
${FLATBUFFERS_GENERATE_HEADERS_FLAGS}
|
${FLATBUFFERS_GENERATE_HEADERS_FLAGS}
|
||||||
DEPENDS ${FLATC_TARGET} ${schema}
|
DEPENDS ${FLATC_TARGET} ${schema}
|
||||||
WORKING_DIRECTORY "${working_dir}")
|
WORKING_DIRECTORY "${working_dir}"
|
||||||
|
COMMENT "Building ${schema} flatbuffers...")
|
||||||
list(APPEND all_generated_header_files ${generated_include})
|
list(APPEND all_generated_header_files ${generated_include})
|
||||||
|
list(APPEND all_generated_source_files ${generated_source_file})
|
||||||
|
|
||||||
# Geneate the binary flatbuffers schemas if instructed to.
|
# Geneate the binary flatbuffers schemas if instructed to.
|
||||||
if (NOT ${FLATBUFFERS_GENERATE_HEADERS_BINARY_SCHEMAS_DIR} STREQUAL "")
|
if (NOT ${FLATBUFFERS_GENERATE_HEADERS_BINARY_SCHEMAS_DIR} STREQUAL "")
|
||||||
@@ -264,6 +278,7 @@ function(flatbuffers_generate_headers)
|
|||||||
INTERFACE
|
INTERFACE
|
||||||
${all_generated_header_files}
|
${all_generated_header_files}
|
||||||
${all_generated_binary_files}
|
${all_generated_binary_files}
|
||||||
|
${all_generated_source_files}
|
||||||
${FLATBUFFERS_GENERATE_HEADERS_SCHEMAS})
|
${FLATBUFFERS_GENERATE_HEADERS_SCHEMAS})
|
||||||
add_dependencies(
|
add_dependencies(
|
||||||
${FLATBUFFERS_GENERATE_HEADERS_TARGET}
|
${FLATBUFFERS_GENERATE_HEADERS_TARGET}
|
||||||
@@ -278,6 +293,10 @@ function(flatbuffers_generate_headers)
|
|||||||
TREE "${generated_target_dir}"
|
TREE "${generated_target_dir}"
|
||||||
PREFIX "Flatbuffers/Generated/Headers Files"
|
PREFIX "Flatbuffers/Generated/Headers Files"
|
||||||
FILES ${all_generated_header_files})
|
FILES ${all_generated_header_files})
|
||||||
|
source_group(
|
||||||
|
TREE "${generated_target_dir}"
|
||||||
|
PREFIX "Flatbuffers/Generated/Source Files"
|
||||||
|
FILES ${all_generated_source_files})
|
||||||
source_group(
|
source_group(
|
||||||
TREE ${working_dir}
|
TREE ${working_dir}
|
||||||
PREFIX "Flatbuffers/Schemas"
|
PREFIX "Flatbuffers/Schemas"
|
||||||
@@ -371,7 +390,8 @@ function(flatbuffers_generate_binary_files)
|
|||||||
-b ${FLATBUFFERS_GENERATE_BINARY_FILES_SCHEMA} ${json_file}
|
-b ${FLATBUFFERS_GENERATE_BINARY_FILES_SCHEMA} ${json_file}
|
||||||
${FLATBUFFERS_GENERATE_BINARY_FILES_FLAGS}
|
${FLATBUFFERS_GENERATE_BINARY_FILES_FLAGS}
|
||||||
DEPENDS ${FLATC_TARGET} ${json_file}
|
DEPENDS ${FLATC_TARGET} ${json_file}
|
||||||
WORKING_DIRECTORY "${working_dir}")
|
WORKING_DIRECTORY "${working_dir}"
|
||||||
|
COMMENT "Building ${json_file} binary flatbuffers...")
|
||||||
list(APPEND all_generated_binary_files ${generated_binary_file})
|
list(APPEND all_generated_binary_files ${generated_binary_file})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user