瀏覽代碼

Added abilty to pass options to protoc executable from cmake

Igor Sirotin 4 年之前
父節點
當前提交
5d0c30934b
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      cmake/protobuf-config.cmake.in

+ 3 - 3
cmake/protobuf-config.cmake.in

@@ -15,7 +15,7 @@ function(protobuf_generate)
   if(COMMAND target_sources)
   if(COMMAND target_sources)
     list(APPEND _singleargs TARGET)
     list(APPEND _singleargs TARGET)
   endif()
   endif()
-  set(_multiargs PROTOS IMPORT_DIRS GENERATE_EXTENSIONS)
+  set(_multiargs PROTOS IMPORT_DIRS GENERATE_EXTENSIONS PROTOC_OPTIONS)
 
 
   cmake_parse_arguments(protobuf_generate "${_options}" "${_singleargs}" "${_multiargs}" "${ARGN}")
   cmake_parse_arguments(protobuf_generate "${_options}" "${_singleargs}" "${_multiargs}" "${ARGN}")
 
 
@@ -130,9 +130,9 @@ function(protobuf_generate)
     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} ${_plugin} ${_protobuf_include_path} ${_abs_file}
+      ARGS ${protobuf_generate_PROTOC_OPTIONS} --${protobuf_generate_LANGUAGE}_out ${_dll_export_decl}${protobuf_generate_PROTOC_OUT_DIR} ${_plugin} ${_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}. Custom options: ${protobuf_generate_PROTOC_OPTIONS}"
       VERBATIM )
       VERBATIM )
   endforeach()
   endforeach()