From 0e9bae1cdb5d7bcd967bcab10539805cc3bccb32 Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Fri, 8 May 2020 10:08:46 +0200 Subject: [PATCH] Create a BUILD file for compatibility with bazel With this change, it's much easier for bazel projects to depend on Catch. They just need to add: - In the workspace: ``` http_archive( name = "com_github_catchorg_catch2", urls = ["https://github.com/catchorg/Catch2/archive/v2.12.1.tar.gz"], strip_prefix = "Catch2-2.12.1", sha256 = "e5635c082282ea518a8dd7ee89796c8026af8ea9068cd7402fb1615deacd91c3", ) ``` Or the appropriate version/sha256. - For the tests, assuming that `test_main.cc` contains the `CATCH_CONFIG_MAIN`: ``` cc_library( name = "test_main", srcs = ["test_main.cc"], deps = ["@com_github_catchorg_catch2//:catch2"], ) ``` --- .gitignore | 1 + BUILD.bazel | 10 ++++++++++ WORKSPACE | 0 3 files changed, 11 insertions(+) create mode 100644 BUILD.bazel create mode 100644 WORKSPACE diff --git a/.gitignore b/.gitignore index f017e9e0..dd12a74b 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ Build cmake-build-* benchmark-dir .conan/test_package/build +bazel-* diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 00000000..2a412a8e --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,10 @@ +# Load the cc_library rule. +load("@rules_cc//cc:defs.bzl", "cc_library") + +# Header-only rule to export catch2/catch.hpp. +cc_library( + name = "catch2", + hdrs = ["single_include/catch2/catch.hpp"], + visibility = ["//visibility:public"], + includes = ["single_include/"], +) diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 00000000..e69de29b