GoogleTest provided with C/C++test CT can be integrated into a Bazel project that uses modules. Follow these steps to integrate it into your project:
Extract the contents of theĀ <INSTALL_DIR>/googletest/googletest.zip. package.
It is recommended to extract the archive to <INSTALL_DIR>/googletest. This guide assumes the GoogleTest sources are located there.
In your Bazel project, add the following to the top-level MODULE.bazel file:
# if another version of googletest is already specified, then that one must be commented out
bazel_dep(name = "googletest", version = "1.17.0")
local_path_override(
module_name = "googletest",
path = "<INSTALL_DIR>/googletest",
) |
Notes:
<INSTALL_DIR>/googletest/MODULE.bazel. If you encounter version mismatch errors, verify that the version specified in MODULE.bazel matches the version used in your project's bazel_dep() statement.