mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-03 05:08:47 -06:00
Protobuf: restore 'DESCRIPTORS' support
This was not present in the upstream code.
This commit is contained in:
committed by
Brad King
parent
1385b4b113
commit
2ae2d0bd3e
@@ -122,7 +122,7 @@
|
|||||||
function(protobuf_generate)
|
function(protobuf_generate)
|
||||||
include(CMakeParseArguments)
|
include(CMakeParseArguments)
|
||||||
|
|
||||||
set(_options APPEND_PATH)
|
set(_options APPEND_PATH DESCRIPTORS)
|
||||||
set(_singleargs LANGUAGE OUT_VAR EXPORT_MACRO PROTOC_OUT_DIR)
|
set(_singleargs LANGUAGE OUT_VAR EXPORT_MACRO PROTOC_OUT_DIR)
|
||||||
if(COMMAND target_sources)
|
if(COMMAND target_sources)
|
||||||
list(APPEND _singleargs TARGET)
|
list(APPEND _singleargs TARGET)
|
||||||
@@ -212,12 +212,18 @@ function(protobuf_generate)
|
|||||||
foreach(_ext ${protobuf_generate_GENERATE_EXTENSIONS})
|
foreach(_ext ${protobuf_generate_GENERATE_EXTENSIONS})
|
||||||
list(APPEND _generated_srcs "${protobuf_generate_PROTOC_OUT_DIR}/${_rel_dir}/${_basename}${_ext}")
|
list(APPEND _generated_srcs "${protobuf_generate_PROTOC_OUT_DIR}/${_rel_dir}/${_basename}${_ext}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
if(protobuf_generate_DESCRIPTORS AND protobuf_generate_LANGUAGE STREQUAL cpp)
|
||||||
|
set(_descriptor_file "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.desc")
|
||||||
|
set(_dll_desc_out "--descriptor_set_out=${_descriptor_file}")
|
||||||
|
list(APPEND _generated_srcs ${_descriptor_file})
|
||||||
|
endif()
|
||||||
list(APPEND _generated_srcs_all ${_generated_srcs})
|
list(APPEND _generated_srcs_all ${_generated_srcs})
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${_generated_srcs}
|
OUTPUT ${_generated_srcs}
|
||||||
COMMAND protobuf::protoc
|
COMMAND protobuf::protoc
|
||||||
ARGS --${protobuf_generate_LANGUAGE}_out ${_dll_export_decl}${protobuf_generate_PROTOC_OUT_DIR}/${_rel_dir} ${_protobuf_include_path} ${_abs_file}
|
ARGS --${protobuf_generate_LANGUAGE}_out ${_dll_export_decl}${protobuf_generate_PROTOC_OUT_DIR}/${_rel_dir} ${_dll_desc_out} ${_protobuf_include_path} ${_abs_file}
|
||||||
DEPENDS ${_abs_file} protobuf::protoc
|
DEPENDS ${_abs_file} protobuf::protoc
|
||||||
COMMENT "Running ${protobuf_generate_LANGUAGE} protocol buffer compiler on ${_proto}"
|
COMMENT "Running ${protobuf_generate_LANGUAGE} protocol buffer compiler on ${_proto}"
|
||||||
VERBATIM )
|
VERBATIM )
|
||||||
@@ -233,7 +239,7 @@ function(protobuf_generate)
|
|||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(PROTOBUF_GENERATE_CPP SRCS HDRS)
|
function(PROTOBUF_GENERATE_CPP SRCS HDRS)
|
||||||
cmake_parse_arguments(protobuf_generate_cpp "" "EXPORT_MACRO" "" ${ARGN})
|
cmake_parse_arguments(protobuf_generate_cpp "" "EXPORT_MACRO;DESCRIPTORS" "" ${ARGN})
|
||||||
|
|
||||||
set(_proto_files "${protobuf_generate_cpp_UNPARSED_ARGUMENTS}")
|
set(_proto_files "${protobuf_generate_cpp_UNPARSED_ARGUMENTS}")
|
||||||
if(NOT _proto_files)
|
if(NOT _proto_files)
|
||||||
@@ -245,6 +251,10 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS)
|
|||||||
set(_append_arg APPEND_PATH)
|
set(_append_arg APPEND_PATH)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(protobuf_generate_cpp_DESCRIPTORS)
|
||||||
|
set(_descriptors DESCRIPTORS)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(DEFINED PROTOBUF_IMPORT_DIRS AND NOT DEFINED Protobuf_IMPORT_DIRS)
|
if(DEFINED PROTOBUF_IMPORT_DIRS AND NOT DEFINED Protobuf_IMPORT_DIRS)
|
||||||
set(Protobuf_IMPORT_DIRS "${PROTOBUF_IMPORT_DIRS}")
|
set(Protobuf_IMPORT_DIRS "${PROTOBUF_IMPORT_DIRS}")
|
||||||
endif()
|
endif()
|
||||||
@@ -254,19 +264,28 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(_outvar)
|
set(_outvar)
|
||||||
protobuf_generate(${_append_arg} LANGUAGE cpp EXPORT_MACRO ${protobuf_generate_cpp_EXPORT_MACRO} OUT_VAR _outvar ${_import_arg} PROTOS ${_proto_files})
|
protobuf_generate(${_append_arg} ${_descriptors} LANGUAGE cpp EXPORT_MACRO ${protobuf_generate_cpp_EXPORT_MACRO} OUT_VAR _outvar ${_import_arg} PROTOS ${_proto_files})
|
||||||
|
|
||||||
set(${SRCS})
|
set(${SRCS})
|
||||||
set(${HDRS})
|
set(${HDRS})
|
||||||
|
if(protobuf_generate_cpp_DESCRIPTORS)
|
||||||
|
set(${protobuf_generate_cpp_DESCRIPTORS})
|
||||||
|
endif()
|
||||||
|
|
||||||
foreach(_file ${_outvar})
|
foreach(_file ${_outvar})
|
||||||
if(_file MATCHES "cc$")
|
if(_file MATCHES "cc$")
|
||||||
list(APPEND ${SRCS} ${_file})
|
list(APPEND ${SRCS} ${_file})
|
||||||
|
elseif(_file MATCHES "desc$")
|
||||||
|
list(APPEND ${protobuf_generate_cpp_DESCRIPTORS} ${_file})
|
||||||
else()
|
else()
|
||||||
list(APPEND ${HDRS} ${_file})
|
list(APPEND ${HDRS} ${_file})
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
set(${SRCS} ${${SRCS}} PARENT_SCOPE)
|
set(${SRCS} ${${SRCS}} PARENT_SCOPE)
|
||||||
set(${HDRS} ${${HDRS}} PARENT_SCOPE)
|
set(${HDRS} ${${HDRS}} PARENT_SCOPE)
|
||||||
|
if(protobuf_generate_cpp_DESCRIPTORS)
|
||||||
|
set(${protobuf_generate_cpp_DESCRIPTORS} "${${protobuf_generate_cpp_DESCRIPTORS}}" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(PROTOBUF_GENERATE_PYTHON SRCS)
|
function(PROTOBUF_GENERATE_PYTHON SRCS)
|
||||||
|
|||||||
Reference in New Issue
Block a user