2 include(CMakeParseArguments)
4 set(_options APPEND_PATH)
5 set(_singleargs LANGUAGE OUT_VAR EXPORT_MACRO)
6 if(COMMAND target_sources)
7 list(APPEND _singleargs TARGET)
9 set(_multiargs PROTOS IMPORT_DIRS GENERATE_EXTENSIONS)
11 cmake_parse_arguments(protobuf_generate "${_options}
" "${_singleargs}
" "${_multiargs}
" "${ARGN}
") 13 if(NOT protobuf_generate_PROTOS AND NOT protobuf_generate_TARGET) 14 message(SEND_ERROR "Error: protobuf_generate called without any targets or
source files
") 18 if(NOT protobuf_generate_OUT_VAR AND NOT protobuf_generate_TARGET) 19 message(SEND_ERROR "Error: protobuf_generate called without a
target or output variable
") 23 if(NOT protobuf_generate_LANGUAGE) 24 set(protobuf_generate_LANGUAGE cpp) 26 string(TOLOWER ${protobuf_generate_LANGUAGE} protobuf_generate_LANGUAGE) 28 if(protobuf_generate_EXPORT_MACRO AND protobuf_generate_LANGUAGE STREQUAL cpp) 29 set(_dll_export_decl "dllexport_decl=${protobuf_generate_EXPORT_MACRO}:
") 32 if(NOT protobuf_GENERATE_EXTENSIONS) 33 if(protobuf_generate_LANGUAGE STREQUAL cpp) 34 set(protobuf_GENERATE_EXTENSIONS .pb.h .pb.cc) 35 elseif(protobuf_generate_LANGUAGE STREQUAL python) 36 set(protobuf_GENERATE_EXTENSIONS _pb2.py) 38 message(SEND_ERROR "Error: protobuf_generate given unknown Language ${LANGUAGE}, please provide a
value for GENERATE_EXTENSIONS
") 43 if(protobuf_generate_TARGET) 44 get_target_property(_source_list ${protobuf_generate_TARGET} SOURCES) 45 foreach(_file ${_source_list}) 46 if(_file MATCHES "proto$
") 47 list(APPEND protobuf_generate_PROTOS ${_file}) 52 if(NOT protobuf_generate_PROTOS) 53 message(SEND_ERROR "Error: protobuf_generate could not find any .proto files
") 57 if(protobuf_generate_APPEND_PATH) 58 # Create an include path for each file specified 59 foreach(_file ${protobuf_generate_PROTOS}) 60 get_filename_component(_abs_file ${_file} ABSOLUTE) 61 get_filename_component(_abs_path ${_abs_file} PATH) 62 list(FIND _protobuf_include_path ${_abs_path} _contains_already) 63 if(${_contains_already} EQUAL -1) 64 list(APPEND _protobuf_include_path -I ${_abs_path}) 68 set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR}) 71 foreach(DIR ${protobuf_generate_IMPORT_DIRS}) 72 get_filename_component(ABS_PATH ${DIR} ABSOLUTE) 73 list(FIND _protobuf_include_path ${ABS_PATH} _contains_already) 74 if(${_contains_already} EQUAL -1) 75 list(APPEND _protobuf_include_path -I ${ABS_PATH}) 79 set(_generated_srcs_all) 80 foreach(_proto ${protobuf_generate_PROTOS}) 81 get_filename_component(_abs_file ${_proto} ABSOLUTE) 82 get_filename_component(_basename ${_proto} NAME_WE) 85 foreach(_ext ${protobuf_GENERATE_EXTENSIONS}) 86 list(APPEND _generated_srcs "${CMAKE_CURRENT_BINARY_DIR}/${_basename}${_ext}
") 88 list(APPEND _generated_srcs_all ${_generated_srcs}) 91 OUTPUT ${_generated_srcs} 92 COMMAND $<TARGET_FILE:ParaView::protoc> 93 ARGS --${protobuf_generate_LANGUAGE}_out ${_dll_export_decl}${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${_abs_file} 94 DEPENDS ${_abs_file} ParaView::protoc 95 COMMENT "Running ${protobuf_generate_LANGUAGE} protocol buffer compiler
on ${_proto}
" 99 set_source_files_properties(${_generated_srcs_all} PROPERTIES GENERATED TRUE) 100 if(protobuf_generate_OUT_VAR) 101 set(${protobuf_generate_OUT_VAR} ${_generated_srcs_all} PARENT_SCOPE) 103 if(protobuf_generate_TARGET) 104 target_sources(${protobuf_generate_TARGET} PRIVATE ${_generated_srcs_all}) boost::graph_traits< vtkGraph *>::vertex_descriptor target(boost::graph_traits< vtkGraph *>::edge_descriptor e, vtkGraph *)
function paraview_protobuf_generate()