Skip to content

Commit

Permalink
Add protobuf compilation support to build
Browse files Browse the repository at this point in the history
This adds dependencies on libprotobuf, protoc, and a C++11 compiler.
  • Loading branch information
special committed Nov 18, 2014
1 parent 63fd48c commit 5103430
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ tests/*/tst_*
!tst_*.pro
!tst_*.cpp
!tst_*.h
*.pb.h
*.pb.cc
packaging/installer/Qt
packaging/installer/Output
translation/*.qm
config
config.ricochet
ricochet

19 changes: 16 additions & 3 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ By default, Ricochet will be portable, and configuration is stored in a folder n
You will need:
* Qt >= 5.1.0
* OpenSSL (libcrypto)
* Protocol Buffers (libprotobuf, protoc)

#### Fedora
```sh
yum install make gcc-c++ qt5-qtbase qt5-qttools-devel qt5-qttools qt5-qtquickcontrols qt5-qtdeclarative qt5-qtbase-devel qt5-qtbase-gui qt5-qtdeclarative-devel openssl-devel
yum install make gcc-c++ protobuf-devel protobuf-compiler openssl-devel
yum install qt5-qtbase qt5-qttools-devel qt5-qttools qt5-qtquickcontrols qt5-qtdeclarative qt5-qtbase-devel qt5-qtbase-gui qt5-qtdeclarative-devel
yum install tor # or build your own
```
#### Ubuntu 14.04 or later
```sh
apt-get install build-essential libssl-dev pkg-config qt5-qmake qt5-default qtbase5-dev qttools5-dev-tools qtdeclarative5-dev qtdeclarative5-controls-plugin
apt-get install build-essential libssl-dev pkg-config libprotobuf-dev protobuf-compiler
apt-get install qt5-qmake qt5-default qtbase5-dev qttools5-dev-tools qtdeclarative5-dev qtdeclarative5-controls-plugin
apt-get install tor # or build your own
```
#### Qt SDK
Expand Down Expand Up @@ -53,6 +56,7 @@ The [buildscripts](https://github.com/ricochet-im/buildscripts) repository conta
You will need:
* Xcode (for toolchain)
* Qt 5 - preferably the [Qt SDK](https://qt-project.org/downloads)
* Protocol Buffers (libprotobuf, protoc) - `brew install protobuf`

You can either load `ricochet.pro` in Qt Creator and build normally, or build command-line with:
```sh
Expand All @@ -72,8 +76,17 @@ Building for Windows is difficult. You will need:
* Visual Studio C++ or MinGW
* Qt 5 - preferably the [Qt SDK](https://qt-project.org/downloads)
* OpenSSL (including libs and headers)
* Protocol Buffers >= 2.6.0

After installing the Qt SDK, open the `ricochet.pro` project in Qt Creator. Before building, you must click the 'Projects' tab on the left side, and under 'Build Steps', modify 'Additional arguments' to add: `OPENSSLDIR=C:\path\to\openssl\`. Use the 'Build -> Run qmake' menu to test your changes.
Compile OpenSSL and protobuf first, according to their instructions.

After installing the Qt SDK, open the `ricochet.pro` project in Qt Creator. Before building, you must click the 'Projects' tab on the left side, and under 'Build Steps', modify 'Additional arguments' to add:

```
OPENSSLDIR=C:\path\to\openssl\ PROTOBUFDIR=C:\path\to\protobuf
```

Use the 'Build -> Run qmake' menu to test your changes.

You also need a `tor.exe` binary, placed in the same folder as `ricochet.exe`.

Expand Down
36 changes: 36 additions & 0 deletions protobuf.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Qt qmake integration with Google Protocol Buffers compiler protoc
#
# To compile protocol buffers with qt qmake, specify PROTOS variable and
# include this file
#
# Based on:
# https://vilimpoc.org/blog/2013/06/09/using-google-protocol-buffers-with-qmake/

PROTOC = protoc

unix {
CONFIG += link_pkgconfig
PKGCONFIG += protobuf
}

win32 {
isEmpty(PROTOBUFDIR):error(You must pass PROTOBUFDIR=path/to/protobuf to qmake on this platform)
INCLUDEPATH += $${PROTOBUFDIR}/include
LIBS += -L$${PROTOBUFDIR}/lib -llibprotobuf
PROTOC = $${PROTOBUFDIR}/protoc.exe
}

protobuf_decl.name = protobuf headers
protobuf_decl.input = PROTOS
protobuf_decl.output = ${QMAKE_FILE_IN_PATH}/${QMAKE_FILE_BASE}.pb.h
protobuf_decl.commands = $$PROTOC --cpp_out=${QMAKE_FILE_IN_PATH} --proto_path=${QMAKE_FILE_IN_PATH} ${QMAKE_FILE_NAME}
protobuf_decl.variable_out = HEADERS
QMAKE_EXTRA_COMPILERS += protobuf_decl

protobuf_impl.name = protobuf sources
protobuf_impl.input = PROTOS
protobuf_impl.output = ${QMAKE_FILE_IN_PATH}/${QMAKE_FILE_BASE}.pb.cc
protobuf_impl.depends = ${QMAKE_FILE_IN_PATH}/${QMAKE_FILE_BASE}.pb.h
protobuf_impl.commands = $$escape_expand(\n)
protobuf_impl.variable_out = SOURCES
QMAKE_EXTRA_COMPILERS += protobuf_impl
1 change: 1 addition & 0 deletions ricochet.pro
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ lessThan(QT_MAJOR_VERSION,5)|lessThan(QT_MINOR_VERSION,1) {
TARGET = ricochet
TEMPLATE = app
QT += core gui network quick widgets
CONFIG += c++11

VERSION = 1.0.4

Expand Down

0 comments on commit 5103430

Please sign in to comment.