From c9d622e878e9c4d2b35325223a919718f0ff0aac Mon Sep 17 00:00:00 2001 From: Jan Blackquill Date: Fri, 5 Feb 2021 00:09:12 -0500 Subject: protobufcpp: add linkLibraries option to disable modifiying linked libs + include paths This allows one to use Qbs' support for protoc without causing libprotobuf/libgrpc to be linked automatically, which is useful for when you want to build libprotobuf/libgrpc as part of your project. Change-Id: Ia40ebf6d79682b4ed88631f0ea540eeb6aad0bff Reviewed-by: Ivan Komissarov --- share/qbs/modules/protobuf/cpp/protobufcpp.qbs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/share/qbs/modules/protobuf/cpp/protobufcpp.qbs b/share/qbs/modules/protobuf/cpp/protobufcpp.qbs index 47d1a60c1..12d4e159f 100644 --- a/share/qbs/modules/protobuf/cpp/protobufcpp.qbs +++ b/share/qbs/modules/protobuf/cpp/protobufcpp.qbs @@ -12,6 +12,8 @@ ProtobufBase { property bool useGrpc: false + property bool _linkLibraries: true + property string grpcIncludePath: grpcIncludeProbe.path property string grpcLibraryPath: grpcLibraryProbe.path @@ -33,6 +35,9 @@ ProtobufBase { } cpp.libraryPaths: { + if (!_linkLibraries) + return []; + var result = []; if (libraryPath) result.push(libraryPath); @@ -41,6 +46,9 @@ ProtobufBase { return result; } cpp.dynamicLibraries: { + if (!_linkLibraries) + return []; + var result = []; if (_libraryName) result.push(_libraryName) @@ -51,6 +59,9 @@ ProtobufBase { return result; } cpp.includePaths: { + if (!_linkLibraries) + return [outputDir]; + var result = [outputDir]; if (includePath) result.push(includePath); @@ -118,17 +129,17 @@ ProtobufBase { validate: { HelperFunctions.validateCompiler(compilerName, compilerPath); - if (!HelperFunctions.checkPath(includePath)) + if (_linkLibraries && !HelperFunctions.checkPath(includePath)) throw "Can't find cpp protobuf include files. Please set the includePath property."; - if (!HelperFunctions.checkPath(libraryPath)) + if (_linkLibraries && !HelperFunctions.checkPath(libraryPath)) throw "Can't find cpp protobuf library. Please set the libraryPath property."; if (useGrpc) { if (!File.exists(grpcPluginPath)) throw "Can't find grpc_cpp_plugin plugin. Please set the grpcPluginPath property."; - if (!HelperFunctions.checkPath(grpcIncludePath)) + if (_linkLibraries && !HelperFunctions.checkPath(grpcIncludePath)) throw "Can't find grpc++ include files. Please set the grpcIncludePath property."; - if (!HelperFunctions.checkPath(grpcLibraryPath)) + if (_linkLibraries && !HelperFunctions.checkPath(grpcLibraryPath)) throw "Can't find grpc++ library. Please set the grpcLibraryPath property."; } } -- cgit v1.2.3