@@ -80,9 +80,10 @@ function (google_cloud_cpp_generate_proto SRCS)
8080 foreach (file_path ${_opt_UNPARSED_ARGUMENTS} )
8181 get_filename_component (file_directory "${file_path} " DIRECTORY )
8282 get_filename_component (file_name "${file_path} " NAME )
83- # This gets the filename without the extension, analogous to $(basename
84- # "${file_path}" .proto)
85- get_filename_component (file_stem "${file_path} " NAME_WE )
83+ # This gets the file name without the ".proto" extension. We would like
84+ # to use get_filename_component with the option NAME_WLE, but that is
85+ # not available until CMake 3.14
86+ string (REPLACE ".proto" "" file_stem "${file_name} " )
8687
8788 # Strip all the prefixes in ${_opt_PROTO_PATH_DIRECTORIES} from the
8889 # source proto directory
@@ -175,11 +176,13 @@ function (google_cloud_cpp_generate_grpcpp SRCS)
175176 endforeach ()
176177
177178 set (${SRCS} )
178- foreach (filename ${_opt_UNPARSED_ARGUMENTS} )
179- get_filename_component (file_directory "${filename} " DIRECTORY )
180- # This gets the filename without the extension, analogous to $(basename
181- # "${filename}" .proto)
182- get_filename_component (file_stem "${filename} " NAME_WE )
179+ foreach (file_path ${_opt_UNPARSED_ARGUMENTS} )
180+ get_filename_component (file_directory "${file_path} " DIRECTORY )
181+ get_filename_component (file_name "${file_path} " NAME )
182+ # This gets the file name without the ".proto" extension. We would like
183+ # to use get_filename_component with the option NAME_WLE, but that is
184+ # not available until CMake 3.14
185+ string (REPLACE ".proto" "" file_stem "${file_name} " )
183186
184187 # Strip all the prefixes in ${_opt_PROTO_PATH_DIRECTORIES} from the
185188 # source proto directory
@@ -201,9 +204,9 @@ function (google_cloud_cpp_generate_grpcpp SRCS)
201204 --plugin=protoc-gen-grpc=$<TARGET_FILE:gRPC::grpc_cpp_plugin>
202205 "--grpc_out=${CMAKE_CURRENT_BINARY_DIR} "
203206 "--cpp_out=${CMAKE_CURRENT_BINARY_DIR} " ${protobuf_include_path}
204- "${filename } "
205- DEPENDS "${filename } " protobuf::protoc gRPC::grpc_cpp_plugin
206- COMMENT "Running gRPC C++ protocol buffer compiler on ${filename } "
207+ "${file_path } "
208+ DEPENDS "${file_path } " protobuf::protoc gRPC::grpc_cpp_plugin
209+ COMMENT "Running gRPC C++ protocol buffer compiler on ${file_path } "
207210 VERBATIM )
208211 endforeach ()
209212
0 commit comments