grpc: build with CMAKE_CXX_STANDARD=17

This commit is contained in:
Phillip Cloud 2022-11-11 07:08:39 -05:00
parent c8825268d2
commit a05f2f2053
No known key found for this signature in database
GPG Key ID: D908212070FD785E
2 changed files with 22 additions and 18 deletions

View File

@ -54,22 +54,26 @@ stdenv.mkDerivation rec {
buildInputs = [ openssl protobuf ]
++ lib.optionals stdenv.isLinux [ libnsl ];
cmakeFlags = [
"-DgRPC_ZLIB_PROVIDER=package"
"-DgRPC_CARES_PROVIDER=package"
"-DgRPC_RE2_PROVIDER=package"
"-DgRPC_SSL_PROVIDER=package"
"-DgRPC_PROTOBUF_PROVIDER=package"
"-DgRPC_ABSL_PROVIDER=package"
"-DBUILD_SHARED_LIBS=ON"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"-D_gRPC_PROTOBUF_PROTOC_EXECUTABLE=${buildPackages.protobuf}/bin/protoc"
] ++ lib.optionals ((stdenv.hostPlatform.useLLVM or false) && lib.versionOlder stdenv.cc.cc.version "11.0") [
# Needs to be compiled with -std=c++11 for clang < 11. Interestingly this is
# only an issue with the useLLVM stdenv, not the darwin stdenv…
# https://github.com/grpc/grpc/issues/26473#issuecomment-860885484
"-DCMAKE_CXX_STANDARD=11"
];
cmakeFlags =
let
# Needs to be compiled with -std=c++11 for clang < 11. Interestingly this is
# only an issue with the useLLVM stdenv, not the darwin stdenv…
# https://github.com/grpc/grpc/issues/26473#issuecomment-860885484
useLLVMAndOldCC = (stdenv.hostPlatform.useLLVM or false) && lib.versionOlder stdenv.cc.cc.version "11.0";
cxxStandard = if useLLVMAndOldCC then "11" else "17";
in
[
"-DgRPC_ZLIB_PROVIDER=package"
"-DgRPC_CARES_PROVIDER=package"
"-DgRPC_RE2_PROVIDER=package"
"-DgRPC_SSL_PROVIDER=package"
"-DgRPC_PROTOBUF_PROVIDER=package"
"-DgRPC_ABSL_PROVIDER=package"
"-DBUILD_SHARED_LIBS=ON"
"-DCMAKE_CXX_STANDARD=${cxxStandard}"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"-D_gRPC_PROTOBUF_PROTOC_EXECUTABLE=${buildPackages.protobuf}/bin/protoc"
];
# CMake creates a build directory by default, this conflicts with the
# basel BUILD file on case-insensitive filesystems.

View File

@ -19468,9 +19468,9 @@ with pkgs;
grilo-plugins = callPackage ../development/libraries/grilo-plugins { };
grpc = callPackage ../development/libraries/grpc {
# grpc builds with c++14 so abseil must also be built that way
# grpc builds with c++17 so abseil must also be built that way
abseil-cpp = abseil-cpp_202206.override {
cxxStandard = "14";
cxxStandard = "17";
};
};