Skip to content

Commit

Permalink
protobuf_generate: create include path only for proto files
Browse files Browse the repository at this point in the history
  • Loading branch information
hesmar committed Sep 29, 2017
1 parent fc5aa5d commit f7e2099
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions cmake/protobuf-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,23 @@ function(protobuf_generate)
endif()
endif()

if(protobuf_generate_TARGET)
get_target_property(_source_list ${protobuf_generate_TARGET} SOURCES)
foreach(_file ${_source_list})
if(_file MATCHES "proto$")
list(APPEND protobuf_generate_PROTOS ${_file})
endif()
endforeach()
endif()

if(NOT protobuf_generate_PROTOS)
message(SEND_ERROR "Error: protobuf_generate could not find any .proto files")
return()
endif()

if(protobuf_generate_APPEND_PATH)
# Create an include path for each file specified
foreach(_file ${ARGN})
foreach(_file ${protobuf_generate_PROTOS})
get_filename_component(_abs_file ${_file} ABSOLUTE)
get_filename_component(_abs_path ${_abs_file} PATH)
list(FIND _protobuf_include_path ${_abs_path} _contains_already)
Expand All @@ -71,20 +85,6 @@ function(protobuf_generate)
endif()
endforeach()

if(protobuf_generate_TARGET)
get_target_property(_source_list ${protobuf_generate_TARGET} SOURCES)
foreach(_file ${_source_list})
if(_file MATCHES "proto$")
list(APPEND protobuf_generate_PROTOS ${_file})
endif()
endforeach()
endif()

if(NOT protobuf_generate_PROTOS)
message(SEND_ERROR "Error: protobuf_generate could not find any .proto files")
return()
endif()

set(_generated_srcs_all)
foreach(_proto ${protobuf_generate_PROTOS})
get_filename_component(_abs_file ${_proto} ABSOLUTE)
Expand Down

0 comments on commit f7e2099

Please sign in to comment.