To complete this tutorial, you'll need:
* A compatible operating system (e.g. Linux, macOS, Windows).
-* A compatible C++ compiler that supports at least C++11.
+* A compatible C++ compiler that supports at least C++14.
* [Bazel](https://bazel.build/), the preferred build system used by the
GoogleTest team.
compatible with GoogleTest.
If you don't already have Bazel installed, see the
-[Bazel installation guide](https://docs.bazel.build/versions/main/install.html).
+[Bazel installation guide](https://bazel.build/install).
-{: .callout .note}
-Note: The terminal commands in this tutorial show a Unix shell prompt, but the
-commands work on the Windows command line as well.
+{: .callout .note} Note: The terminal commands in this tutorial show a Unix
+shell prompt, but the commands work on the Windows command line as well.
## Set up a Bazel workspace
http_archive(
name = "com_google_googletest",
- urls = ["https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip"],
- strip_prefix = "googletest-609281088cfefc76f9d0ce82e1ff6c30cc3591e5",
+ urls = ["https://github.com/google/googletest/archive/5ab508a01f9eb089207ee87fd547d290da39d015.zip"],
+ strip_prefix = "googletest-5ab508a01f9eb089207ee87fd547d290da39d015",
)
```
The above configuration declares a dependency on GoogleTest which is downloaded
as a ZIP archive from GitHub. In the above example,
-`609281088cfefc76f9d0ce82e1ff6c30cc3591e5` is the Git commit hash of the
+`5ab508a01f9eb089207ee87fd547d290da39d015` is the Git commit hash of the
GoogleTest version to use; we recommend updating the hash often to point to the
-latest version.
+latest version. Use a recent hash on the `main` branch.
Now you're ready to build C++ code that uses GoogleTest.
see the
[Bazel C++ Tutorial](https://docs.bazel.build/versions/main/tutorial/cpp.html).
+{: .callout .note}
+NOTE: In the example below, we assume Clang or GCC and set `--cxxopt=-std=c++14`
+to ensure that GoogleTest is compiled as C++14 instead of the compiler's default
+setting (which could be C++11). For MSVC, the equivalent would be
+`--cxxopt=/std:c++14`. See [Supported Platforms](platforms.md) for more details
+on supported language versions.
+
Now you can build and run your test:
<pre>
-<strong>my_workspace$ bazel test --test_output=all //:hello_test</strong>
+<strong>my_workspace$ bazel test --cxxopt=-std=c++14 --test_output=all //:hello_test</strong>
INFO: Analyzed target //:hello_test (26 packages loaded, 362 targets configured).
INFO: Found 1 test target...
INFO: From Testing //:hello_test: