如何在 bazel BUILD 文件中指定 -std=c++11 选项?
How to specify -std=c++11 option in bazel BUILD file?
如何将此选项添加到目标描述部分?
谢谢。
将 bazel build --cxxopt='-std=c++11'
添加到 .bazelrc
文件。
export BAZEL_CXXOPTS=-std=c++11
除了在 .bazelrc
或使用 BAZEL_CXXOPTS
中全局设置外,您还可以在 cc_binary
或 cc_test
规则中为每个目标单独设置它们:
cc_binary(
name = "target1",
srcs = ["target1.cc"],
copts = ["--std=c++17"],
)
cc_binary(
name = "target2",
srcs = ["target2.cc"],
copts = ["--std=c++14"],
)
如何将此选项添加到目标描述部分?
谢谢。
将 bazel build --cxxopt='-std=c++11'
添加到 .bazelrc
文件。
export BAZEL_CXXOPTS=-std=c++11
除了在 .bazelrc
或使用 BAZEL_CXXOPTS
中全局设置外,您还可以在 cc_binary
或 cc_test
规则中为每个目标单独设置它们:
cc_binary(
name = "target1",
srcs = ["target1.cc"],
copts = ["--std=c++17"],
)
cc_binary(
name = "target2",
srcs = ["target2.cc"],
copts = ["--std=c++14"],
)