Open liuluheng opened 1 year ago
Hi, @liuluheng,
I'm facing the same issue:
bazel build //src/server:main
succeeds, but bazel build //src/server:main -c dbg
fails.
Even using -DCMAKE_DEBUG_POSTFIX=""
doesn’t solve the problem.
Here’s the error I encountered:
ERROR: /home/xiaochen/code/small-db-v2/BUILD:55:6: output 'spdlog/lib/libspdlog.a' was not created
ERROR: /home/xiaochen/code/small-db-v2/BUILD:55:6: Foreign Cc - CMake: Building spdlog failed: not all outputs were created or valid
Do you know how to troubleshoot this? I'd like to understand Bazel's behavior, such as where it searches for the output files.
Here are my Bazel build files:
Update:
I had to explicitly set out_static_libs
because spdlog doesn’t care about CMAKE_DEBUG_POSTFIX
.
cmake(
name = "spdlog",
build_args = ["-j"],
lib_source = "@spdlog//:all",
out_static_libs = select({
"//conditions:default": ["libspdlog.a"],
# spdlog doesn't care about CMAKE_DEBUG_POSTFIX, so we have to adapt to it.
":debug": ["libspdlogd.a"],
}),
visibility = ["//visibility:public"],
)
config_setting(
name = "debug",
values = {"compilation_mode": "dbg"},
)
cmake debug build will add
d
suffix by default, which is not consistent with the library name. for examplewith thrift cmake rule as follows https://github.com/apache/brpc/blob/master/bazel/third_party/thrift/thrift.BUILD#L23
run
will get
to solve this i passed
-DCMAKE_DEBUG_POSTFIX=\"\"
to the cmake attrgenerate_args
but i think cmake rule should handle this by default