0

I use Bazel as build system. I have a cc_library rule working well on Linux. I would like my code to compile on Windows where some options may be different. For example, '-std=c++14' / '/std:c++14', or "-lpthread".

cc_library(
        name = "name",
        hdrs = ["file.hpp"],
        srcs = ["file.cpp"],
        copts = ['-std=c++14'] # '/std:c++14' for Windows
        linkopts = ["-lpthread"],
        visibility = ["//visibility:public"],
)

What is the bazelistic way to handle this? I have seen Platforms but it seems overkill and I don't understand if it is meant for this.

fflorian
  • 19
  • 5
  • Add a `.bazelrc` to your project. Add the lines `build:vs2019 --cxxopt=/std:c++14` and `build:gcc --cxxopt=-std=c++14` - build your code `bazel build --config=msvc //...` or `bazel build --config=gcc //...`. I am really unhappy that his question was closed... – Vertexwahn Mar 13 '20 at 01:25
  • I closed the question because I managed to get the desired behavior with the link provided. However, the solution you posted seems better for global compilation options such as -std – fflorian Mar 13 '20 at 06:18

0 Answers0