Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Bazel build: Fix ignoring unknown option '-std=c++14' for Windows builds #1100

@Vertexwahn

Description

@Vertexwahn

When build glog on Windows you get the following warning when using Visual Studio 2022: unknown option '-std=c++14' for Windows builds.

The reason for this is here.

Abseil has a good way to handle flags for different compilers - could copied here - something like this:

in configure_copts.bzl:

GLOG_MSVC_FLAGS = [
    "/std:c++20",
]

GLOG_GCC_FLAGS = [
    "-std=c++23",
]

GLOG_CLANG_FLAGS = [
    "-std=c++20",
]

GLOG_DEFAULT_COPTS = select({
    "//glog:msvc_compiler": GLOG_MSVC_FLAGS,
    "//glog:gcc_compiler": GLOG_GCC_FLAGS,
    "//glog:clang_compiler": GLOG_CLANG_FLAGS,
    "//conditions:default": GLOG_GCC_FLAGS,
})

In BUILD file:

config_setting(
    name = "msvc_compiler",
    flag_values = {
        "@bazel_tools//tools/cpp:compiler": "msvc-cl",
    },
    visibility = [":__subpackages__"],
)

config_setting(
    name = "gcc_compiler",
    flag_values = {
        "@bazel_tools//tools/cpp:compiler": "gcc",
    },
    visibility = [":__subpackages__"],
)

config_setting(
    name = "clang_compiler",
    flag_values = {
        "@bazel_tools//tools/cpp:compiler": "clang",
    },
    visibility = [":__subpackages__"],
)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions