Skip to content

Commit

Permalink
Suppress protobuf warnings in unix builds
Browse files Browse the repository at this point in the history
The protobuf code creates lots of spurious warnings
throughout our compile which we can do nothing about.
This patch changes the way we integrate the generated
code in our build to work around this.

We now run protoc and generated code compilation as a seperate
mumble_proto target producing a static lib. This lib is then
linked by mumble and murmur.

The folder of this module is added to the include paths so
Mumble.pb.h is available. On Unix platforms a -isystem entry
is added for the directory.

The advantages of this approach is that we can disable warnings
for the compilation of this target like we do for 3rd party modules.
Additionally we no longer generate and compile the protobuf files
twice.
  • Loading branch information
hacst committed Jul 4, 2015
1 parent fac930b commit 75feffb
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 21 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Expand Up @@ -14,11 +14,10 @@ indent.sh
*.vcxproj
*.vcxproj.*
*~
*.pb.h
*.pb.cc
*.pro.user
ui_*.h
*.qm
*.pb.*
installer/Mumble.exe
overlay/*.hex
overlay_winx64/*.hex
Expand Down
2 changes: 2 additions & 0 deletions main.pro
@@ -1,6 +1,8 @@
TEMPLATE = subdirs
CONFIG *= ordered debug_and_release

SUBDIRS *= src/mumble_proto

!CONFIG(no-client) {
unix:!CONFIG(bundled-speex):system(pkg-config --atleast-version=1.2 speexdsp):system(pkg-config --atleast-version=1.2 speex) {
CONFIG *= no-bundled-speex
Expand Down
29 changes: 10 additions & 19 deletions src/mumble.pri
Expand Up @@ -2,26 +2,17 @@ include(../compiler.pri)
include(../qt.pri)

VERSION = 1.3.0
DIST = mumble.pri Message.h PacketDataStream.h CryptState.h Timer.h Version.h OSInfo.h SSL.h Mumble.proto
DIST = mumble.pri Message.h PacketDataStream.h CryptState.h Timer.h Version.h OSInfo.h SSL.h
CONFIG += qt thread debug_and_release warn_on
DEFINES *= MUMBLE_VERSION_STRING=$$VERSION
INCLUDEPATH += $$PWD .
INCLUDEPATH += $$PWD . ../mumble_proto
VPATH += $$PWD
HEADERS *= ACL.h Channel.h CryptState.h Connection.h Group.h User.h Net.h OSInfo.h Timer.h SSL.h Version.h
SOURCES *= ACL.cpp Group.cpp Channel.cpp Connection.cpp User.cpp Timer.cpp CryptState.cpp OSInfo.cpp Net.cpp SSL.cpp Version.cpp
PROTOBUF *= ../Mumble.proto

pbh.output = ${QMAKE_FILE_BASE}.pb.h
pbh.depends = ${QMAKE_FILE_BASE}.pb.cc
pbh.commands = $$escape_expand(\\n)
pbh.input = PROTOBUF
pbh.CONFIG *= no_link explicit_dependencies target_predeps

pb.output = ${QMAKE_FILE_BASE}.pb.cc
pb.commands = protoc --cpp_out=. -I. -I.. ${QMAKE_FILE_NAME}
pb.input = PROTOBUF
pb.CONFIG *= no_link explicit_dependencies
pb.variable_out = SOURCES
LIBS *= -lmumble_proto
# Note: Protobuf generates into its own directory so we can mark it as a
# system include folder for unix. Otherwise the generated code creates
# a lot of spurious warnings in ours.

CONFIG(packaged) {
MUMDEFVER = $$find(DEFINES, "MUMBLE_VERSION=")
Expand All @@ -31,7 +22,7 @@ CONFIG(packaged) {
}

win32 {
INCLUDEPATH *= "$$PROTOBUF_PATH/vsprojects/include" "$$PROTOBUF_PATH/src"
INCLUDEPATH *= "$$PROTOBUF_PATH/vsprojects/include" "$$PROTOBUF_PATH/src" protobuf
CONFIG(debug, debug|release) {
QMAKE_LIBDIR *= "$$PROTOBUF_PATH/vsprojects/Debug"
} else {
Expand All @@ -51,6 +42,9 @@ unix {
PKG_CONFIG = pkg-config --static
}

QMAKE_CFLAGS *= -isystem ../mumble_proto
QMAKE_CXXFLAGS *= -isystem ../mumble_proto

CONFIG *= link_pkgconfig
LIBS *= -lprotobuf

Expand All @@ -68,9 +62,6 @@ isEqual(QT_MAJOR_VERSION, 4) {
DEFINES *= Q_DECL_FINAL=
}


QMAKE_EXTRA_COMPILERS *= pb pbh

CONFIG(debug, debug|release) {
CONFIG += console
QMAKE_LIBDIR += ../../debug
Expand Down
43 changes: 43 additions & 0 deletions src/mumble_proto/mumble_proto.pro
@@ -0,0 +1,43 @@
include(../../compiler.pri)

PROTOBUF *= ../Mumble.proto

pbh.output = ${QMAKE_FILE_BASE}.pb.h
pbh.depends = ${QMAKE_FILE_BASE}.pb.cc
pbh.commands = $$escape_expand(\\n)
pbh.input = PROTOBUF
pbh.CONFIG *= no_link explicit_dependencies target_predeps
pbh.variable_out = HEADERS

pb.output = ${QMAKE_FILE_BASE}.pb.cc
pb.commands = protoc --cpp_out=. -I. -I.. ${QMAKE_FILE_NAME}
pb.input = PROTOBUF
pb.CONFIG *= no_link explicit_dependencies
pb.variable_out = SOURCES

TEMPLATE = lib
CONFIG -= qt
CONFIG += debug_and_release
CONFIG += staticlib

INCLUDEPATH *= "$$PROTOBUF_PATH/vsprojects/include" "$$PROTOBUF_PATH/src" protobuf

QMAKE_EXTRA_COMPILERS *= pb pbh

!CONFIG(third-party-warnings) {
# We ignore warnings in third party builds. We won't actually look
# at them and they clutter out our warnings.
CONFIG -= warn_on
CONFIG += warn_off
}

CONFIG(debug, debug|release) {
DESTDIR = ../../debug
}

CONFIG(release, debug|release) {
DESTDIR = ../../release
}

include(../../symbols.pri)

0 comments on commit 75feffb

Please sign in to comment.