How to set C++ standard version when build with Ba

2020-02-01 03:47发布

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?

标签: bazel
2条回答
不美不萌又怎样
2楼-- · 2020-02-01 04:32

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).

查看更多
来,给爷笑一个
3楼-- · 2020-02-01 04:40

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.

查看更多
登录 后发表回答