# -*- bazel -*-

load("@drake//tools/install:install.bzl", "install")
load("@drake//tools/skylark:cc.bzl", "cc_library")

licenses(["notice"])  # MIT

package(default_visibility = ["//visibility:public"])

cc_library(
    name = "nlohmann",
    hdrs = [
        "single_include/nlohmann/json.hpp",
        "single_include/nlohmann/json_fwd.hpp",
    ],
    strip_include_prefix = "single_include",
    defines = [
        # The nlohmann/json code has logic that tries to infer whether or not
        # the compiler toolchain supports the spaceship operator (<=>).
        # However, something it does is not quite correct and ends up failing
        # with Ubuntu 24.04's current version of GCC 13. The problem might be
        # https://github.com/nlohmann/json/issues/4197 but that doesn't seem
        # quite like it, either. In any case, we don't particularly care about
        # spaceship support so we can just force it to be off; problem solved.
        "JSON_HAS_THREE_WAY_COMPARISON=0",
    ],
    linkstatic = 1,
)

# Install the license file.
install(
    name = "install",
    docs = ["LICENSE.MIT"],
)
