[tint][cmake] Use build protoc instead of system installed version
The existing cmake rule will use the first protoc that shows up in your
path, so will likely default to the system installed version of protoc,
which may not be compatible with the version of libprotobuf in our repo.
Additionally this can lead to build failures when there is no installed
protoc, and the output path for the build is not in the path.
This also include a small fix for '"--${ARGS_LANGUAGE}_out', since
protoc uses '--<flag>=<arg>' or '-<flag><arg>' format for its CLI, not
'--<flag> <arg>'. And it was using the wrong variable name.
Fixes: 435357782
Change-Id: I20c921599caf5ac4b5c57545fb61886463092a13
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/257894
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: James Price <jrprice@google.com>
diff --git a/third_party/protobuf.cmake b/third_party/protobuf.cmake
index 7e7bdd5..bb9057e 100644
--- a/third_party/protobuf.cmake
+++ b/third_party/protobuf.cmake
@@ -173,11 +173,17 @@
file(MAKE_DIRECTORY "${ARGS_PROTOC_OUT_DIR}/${REL_DIR}")
+ if(PLUGIN_OPTIONS)
+ set(lang_out_arg "--${ARGS_LANGUAGE}_out=${PLUGIN_OPTIONS}:${ARGS_PROTOC_OUT_DIR}")
+ else()
+ set(lang_out_arg "--${ARGS_LANGUAGE}_out=${ARGS_PROTOC_OUT_DIR}")
+ endif()
+
add_custom_command(
OUTPUT ${GENERATED_SRCS}
- COMMAND protobuf::protoc
- ARGS ${ARGS_PROTOC_OPTIONS} --${ARGS_LANGUAGE}_out ${_plugin_options}:${ARGS_PROTOC_OUT_DIR} ${_plugin} ${PROTOBUF_INCLUDE_PATH} ${ABS_FILE}
- DEPENDS ${ABS_FILE} protobuf::protoc
+ COMMAND $<TARGET_FILE:protobuf::protoc>
+ ARGS ${ARGS_PROTOC_OPTIONS} ${lang_out_arg} ${_plugin} ${PROTOBUF_INCLUDE_PATH} ${ABS_FILE}
+ DEPENDS ${ABS_FILE} $<TARGET_FILE:protobuf::protoc>
COMMENT ${COMMENT}
VERBATIM)
endforeach()