CMake: Add TINT_EXTERNAL_BENCHMARK_CORPUS_DIR

If specified, CMake will glob all the .wgsl files in this directory, and add these to the list of benchmarks to run.

Change-Id: I75b2754a6561dcd931c42bd47649c4f625e1c581
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127980
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
diff --git a/src/tint/bench/benchmark.h b/src/tint/bench/benchmark.h
index 6801585..adb28b8 100644
--- a/src/tint/bench/benchmark.h
+++ b/src/tint/bench/benchmark.h
@@ -51,6 +51,15 @@
 /// @returns either the loaded Program or an Error
 std::variant<ProgramAndFile, Error> LoadProgram(std::string name);
 
+// If TINT_BENCHMARK_EXTERNAL_WGSL_PROGRAM_HEADER is defined, include that to
+// declare the TINT_BENCHMARK_EXTERNAL_WGSL_PROGRAMS() macro, which appends
+// external programs to the TINT_BENCHMARK_WGSL_PROGRAMS() list.
+#ifdef TINT_BENCHMARK_EXTERNAL_WGSL_PROGRAM_HEADER
+#include TINT_BENCHMARK_EXTERNAL_WGSL_PROGRAM_HEADER
+#else
+#define TINT_BENCHMARK_EXTERNAL_WGSL_PROGRAMS(x)
+#endif
+
 /// Declares a benchmark with the given function and WGSL file name
 #define TINT_BENCHMARK_WGSL_PROGRAM(FUNC, WGSL_NAME) BENCHMARK_CAPTURE(FUNC, WGSL_NAME, WGSL_NAME);
 
@@ -69,7 +78,8 @@
     TINT_BENCHMARK_WGSL_PROGRAM(FUNC, "simple-fragment.wgsl");               \
     TINT_BENCHMARK_WGSL_PROGRAM(FUNC, "simple-vertex.wgsl");                 \
     TINT_BENCHMARK_WGSL_PROGRAM(FUNC, "skinned-shadowed-pbr-fragment.wgsl"); \
-    TINT_BENCHMARK_WGSL_PROGRAM(FUNC, "skinned-shadowed-pbr-vertex.wgsl");
+    TINT_BENCHMARK_WGSL_PROGRAM(FUNC, "skinned-shadowed-pbr-vertex.wgsl");   \
+    TINT_BENCHMARK_EXTERNAL_WGSL_PROGRAMS(FUNC)
 
 }  // namespace tint::bench