I'm kinda new to C++. I know how to set C++ version with CMake, but don't know how to set C++ version in Bazel.
Maybe set with the copts
parameter in cc_libary
but I have to set this in every cc_libary
?
I'm kinda new to C++. I know how to set C++ version with CMake, but don't know how to set C++ version in Bazel.
Maybe set with the copts
parameter in cc_libary
but I have to set this in every cc_libary
?
So the robust solution to specifying C++ toolchain in Bazel is to use the CROSSTOOL file. You might find about the CROSSTOOL wiki page helpful. To get you started you can read Building with a custom toolchain wiki page. To see what Bazel does when it autogenerates the crosstool for you you can read the blog post about autoconfiguration. And to get more examples on how to write features and action_configs, take a look at CppActionConfigs.java.
Or, just put build --cxxopt='-std=c++11'
into .bazelrc (stored in your home or in the folder where the WORKSPACE file is).
bazel build --cxxopt='-std=c++11' main:hello-world
This would work, but I wonder if there's way to set this cxxopt
globally, like CMAKE_CXX_FLAGS
.