How to set C++ standard in Bazel project or workspace?

  bazel, c++

I’m currently migrating a multipackage C++14 project to Bazel, but whenever I run $ bazel build on linux I end up getting build errors because Bazel is calling the compiler with -std=c++0x.

One of the requirements for this project is to gradually migrate its packages to C++17 once the build system is up and running. However, after browsing through Bazel’s docs I saw no reference to how to set a project’s target C++ standard version. CMake handles this trivially and effortlessly through its CXX_STANDARD target property, but so far I saw no reference to this usecase being supported by Bazel.

With this in mind, does anyone know if Bazel allows users to specify C++ standard versions for specific projects/workspaces? If it does, is it possible to provide a minimal working example?

Source: Windows Questions C++