From 1bd9601c65449a961e2a9c442fec144089d80696 Mon Sep 17 00:00:00 2001 From: Kai Dohmen Date: Wed, 9 Dec 2020 13:39:04 +0100 Subject: Probe for release and debug version of protobuf libraries When cpp protobuf or nanopb gets compiled as debug build the library gets the suffix "d". The library probe will search for the release name and the debug name. If no library could be found let the user set the library name. Change-Id: I6574986e527fe4484935e58ccf45c86feee230e5 Reviewed-by: Ivan Komissarov --- share/qbs/modules/protobuf/cpp/protobufcpp.qbs | 16 ++++++++++++++-- share/qbs/modules/protobuf/nanopb/nanopb.qbs | 18 ++++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/share/qbs/modules/protobuf/cpp/protobufcpp.qbs b/share/qbs/modules/protobuf/cpp/protobufcpp.qbs index 9f2dbc7af..47d1a60c1 100644 --- a/share/qbs/modules/protobuf/cpp/protobufcpp.qbs +++ b/share/qbs/modules/protobuf/cpp/protobufcpp.qbs @@ -15,6 +15,13 @@ ProtobufBase { property string grpcIncludePath: grpcIncludeProbe.path property string grpcLibraryPath: grpcLibraryProbe.path + readonly property string _libraryName: { + var libraryName = FileInfo.baseName(libraryProbe.fileName); + if (libraryName.startsWith("lib")) + libraryName = libraryName.substring(3); + return libraryName; + } + Depends { name: "cpp" } property path grpcPluginPath: grpcPluginProbe.filePath @@ -34,7 +41,9 @@ ProtobufBase { return result; } cpp.dynamicLibraries: { - var result = ["protobuf"]; + var result = []; + if (_libraryName) + result.push(_libraryName) if (qbs.targetOS.contains("unix")) result.push("pthread"); if (useGrpc) @@ -89,7 +98,10 @@ ProtobufBase { Probes.LibraryProbe { id: libraryProbe - names: "protobuf" + names: [ + "protobuf", + "protobufd", + ] } Probes.IncludeProbe { diff --git a/share/qbs/modules/protobuf/nanopb/nanopb.qbs b/share/qbs/modules/protobuf/nanopb/nanopb.qbs index 02754b8c4..36bdc9254 100644 --- a/share/qbs/modules/protobuf/nanopb/nanopb.qbs +++ b/share/qbs/modules/protobuf/nanopb/nanopb.qbs @@ -12,6 +12,12 @@ ProtobufBase { property string pluginPath: pluginProbe.path property string _plugin: "protoc-gen-nanopb=" + FileInfo.joinPaths(pluginPath, "protoc-gen-nanopb") + readonly property string _libraryName: { + var libraryName = FileInfo.baseName(libraryProbe.fileName); + if (libraryName.startsWith("lib")) + libraryName = libraryName.substring(3); + return libraryName; + } Depends { name: "cpp" } @@ -21,7 +27,12 @@ ProtobufBase { result.push(libraryPath); return result; } - cpp.dynamicLibraries: "protobuf-nanopb" + cpp.dynamicLibraries: { + var result = []; + if (_libraryName) + result.push(_libraryName); + return result; + } cpp.includePaths: { var result = [outputDir]; if (includePath) @@ -62,7 +73,10 @@ ProtobufBase { Probes.LibraryProbe { id: libraryProbe - names: "protobuf-nanopb" + names: [ + "protobuf-nanopb", + "protobuf-nanopbd", + ] } Probes.BinaryProbe { -- cgit v1.2.3