https://docs.bazel.build/versions/master/be/c-cpp.html
关于科普特人选项:
Each string in this attribute is added in the given order to COPTS before compiling the binary target. The flags take effect only for compiling this target, not its dependencies, so be careful about header files included elsewhere. All paths should be relative to the workspace, not to the current package.
cc_library(
name = 'lib1',
srcs = glob([
'src/*.cpp',
]),
hdrs = glob([
'include/*.h',
'include/**/*.h',
]),
copts = [
'-std=c++11',
'-fopenmp',
'-march=native',
],
)
cc_binary(
name = "test1",
srcs = ["tests/test1.cpp"],
deps = [
":lib1",
],
copts = [
'-std=c++11',
'-fopenmp',
'-march=native',
],
)
如果我删除 test1 规则中的科普特人,编译将失败。如何修改 lib1 规则,使依赖于它的所有规则也可以编译。
您还需要将 linkopts = ["-lgomp"]
添加到您的 cc_binary
规则。
我是一名优秀的程序员,十分优秀!