【发布时间】:2021-04-26 21:10:16
【问题描述】:
我有一个非常简单的 bazel 项目,我正在尝试将 https://github.com/nlohmann/json 添加为依赖项。为此,我在本地克隆了 json 存储库,并在存储库的根目录中添加了一个 BUILD 文件以生成一个包含单个包含 json.hpp 文件的 cc_library。但是当我构建它时,它总是抱怨没有什么可构建的。
├── json
│ ├── BUILD
│ ├── // all files under nlohmann/json repo.
├── myproject
│ ├── BUILD
│ └── Main.cpp
└── WORKSPACE
json/构建:
cc_library(
name = "json",
hdrs = ["single_include/nlohmann/json.hpp"],
includes = ["json"],
visibility = ["//visibility:public"],
)
上述构建成功,但没有生成库。注意输出中的“(没有构建)”消息。
bazel build :json
INFO: Analyzed target //json:json (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //json:json up-to-date (nothing to build)
INFO: Elapsed time: 0.065s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
我的项目/Main.cpp:
#include <single_include/nlohmann/json.hpp>
int main() {
...
}
我的项目/构建:
cc_binary(
name = "main",
srcs = ["Main.cpp"],
deps = [ "//json:json"]
)
myproject构建错误:
myproject/Main.cpp:1:44: fatal error: single_include/nlohmann/json.hpp: No such file or directory
compilation terminated.
任何想法我在这里错过了什么?我的目标是在我的 bazel 项目 myproject 中使用 json repo 作为依赖项。
【问题讨论】:
标签: c++ bazel nlohmann-json