@ -11,7 +11,7 @@ function(protobuf_generate)
include ( CMakeParseArguments )
set ( _options APPEND_PATH )
set ( _singleargs LANGUAGE OUT_VAR EXPORT_MACRO PROTOC_OUT_DIR PLUGIN )
set ( _singleargs LANGUAGE OUT_VAR EXPORT_MACRO PROTOC_OUT_DIR PLUGIN PLUGIN_OPTIONS )
if ( COMMAND target_sources )
list ( APPEND _singleargs TARGET )
endif ( )
@ -39,9 +39,18 @@ function(protobuf_generate)
endif ( )
if ( protobuf_generate_EXPORT_MACRO AND protobuf_generate_LANGUAGE STREQUAL cpp )
set ( _dll_export_decl "dllexport_decl=${protobuf_generate_EXPORT_MACRO}: " )
set ( _dll_export_decl "dllexport_decl=${protobuf_generate_EXPORT_MACRO}" )
endif ( )
foreach ( _option ${ _dll_export_decl } ${ protobuf_generate_PLUGIN_OPTIONS } )
# a p p e n d c o m m a - n o t u s i n g C M a k e l i s t s a n d s t r i n g r e p l a c e m e n t a s u s e r s
# m i g h t h a v e s e m i c o l o n s i n o p t i o n s
if ( _plugin_options )
set ( _plugin_options "${_plugin_options}," )
endif ( )
set ( _plugin_options "${_plugin_options}${_option}" )
endforeach ( )
if ( protobuf_generate_PLUGIN )
set ( _plugin "--plugin=${protobuf_generate_PLUGIN}" )
endif ( )
@ -127,12 +136,20 @@ function(protobuf_generate)
endforeach ( )
list ( APPEND _generated_srcs_all ${ _generated_srcs } )
set ( _comment "Running ${protobuf_generate_LANGUAGE} protocol buffer compiler on ${_proto}" )
if ( protobuf_generate_PROTOC_OPTIONS )
set ( _comment "${_comment}, protoc-options: ${protobuf_generate_PROTOC_OPTIONS}" )
endif ( )
if ( _plugin_options )
set ( _comment "${_comment}, plugin-options: ${_plugin_options}" )
endif ( )
add_custom_command (
O U T P U T $ { _ g e n e r a t e d _ s r c s }
C O M M A N D p r o t o b u f : : p r o t o c
A R G S $ { p r o t o b u f _ g e n e r a t e _ P R O T O C _ O P T I O N S } - - $ { p r o t o b u f _ g e n e r a t e _ L A N G U A G E } _ o u t $ { _ d l l _ e x p o r t _ d e c l } $ { p r o t o b u f _ g e n e r a t e _ P R O T O C _ O U T _ D I R } $ { _ p l u g i n } $ { _ p r o t o b u f _ i n c l u d e _ p a t h } $ { _ a b s _ f i l e }
C O M M A N D p r o t o b u f : : p r o t o c
A R G S $ { p r o t o b u f _ g e n e r a t e _ P R O T O C _ O P T I O N S } - - $ { p r o t o b u f _ g e n e r a t e _ L A N G U A G E } _ o u t $ { _ p l u g i n _ o p t i o n s } : $ { p r o t o b u f _ g e n e r a t e _ P R O T O C _ O U T _ D I R } $ { _ p l u g i n } $ { _ p r o t o b u f _ i n c l u d e _ p a t h } $ { _ a b s _ f i l e }
D E P E N D S $ { _ a b s _ f i l e } p r o t o b u f : : p r o t o c
C O M M E N T " R u n n i n g $ { p r o t o b u f _ g e n e r a t e _ L A N G U A G E } p r o t o c o l b u f f e r c o m p i l e r o n $ { _ p r o t o } . C u s t o m o p t i o n s : $ { p r o t o b u f _ g e n e r a t e _ P R O T O C _ O P T I O N S } "
C O M M E N T $ { _ c o m m e n t }
V E R B A T I M )
endforeach ( )