24 How to compile the desktop client
Camila edited this page 2022-03-21 18:34:39 +01:00
This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Note: This document is in the process of being merged with the official documentation and may be out of date. For the most up-to-date version of the build instructions, visit the source version of the official documentation page here.

Step by step instructions

1. Clone the repo

You have two possibilities to clone the repo.

First option is as remote URL -- you can choose between cloning with HTTPS (which is recommended) or with SSH.

https://github.com/nextcloud/desktop.git

If you don't have an SSH key added to your GitHub account, or are not part of the Nextcloud Github organisation, clone with HTTPS:

$ git clone git@github.com:nextcloud/desktop.git

2. Create build directory:

$ cd desktop
$ mkdir build

3. Compile and install

Optional - depending on how you have your dev environment set up, you might need to define those paths as cmake flags or as environment variables:

  • QTKEYCHAIN_LIBRARY
  • QTKEYCHAIN_INCLUDE_DIR
  • OPENSSL_ROOT_DIR
  • OPENSSL_INCLUDE_DIR

You can enable the build of the tests by setting the cmake flag BUILD_TESTING to 1.

The cmake flag CMAKE_BUILD_TYPE has Debug and Release as options.

⚠️ For development reasons it is better to install the client on user space instead on the global system. Mixing up libs/dll's of different version can lead to undefined behavior and crashes:

  • You could use the cmake flag CMAKE_INSTALL_PREFIX as ~/.local/ in a Linux system. If you want to install system wide you could use /usr/local or /opt/nextcloud/.

  • On Windows 10 $USERPROFILE refers to C:\Users\<USERNAME>.

🐧 Linux

Generate the build files:

$ cd build
$ cmake .. -DCMAKE_INSTALL_PREFIX=~/nextcloud-desktop-client -DCMAKE_BUILD_TYPE=Debug

Compile and install:

$ make install

🚪 Windows

Generate the build files:

$ cmake "-GVisual Studio 15 2017 Win64" .. -DCMAKE_INSTALL_PREFIX=$USERPROFILE\nextcloud-desktop-client -DCMAKE_BUILD_TYPE=Debug

Compile and install:

$ cmake --build . --config Debug --target install

🍎 Mac OS

macOS Universal binaries

There is no official support for M1 Arm binaries for Qt 5 only Qt 6.2 supports building M1 ARM and Intel binaries. So if you want to use Qt 5 you will have to compile Qt yourself (it's very important to use the latest public published commit of Qt5), OpenSSL and QtKeychain. To produce an universal binary you will to compile them all once for x86_64 and once for arm64.

It's also important to set the deployment target. This can be set by setting a environment variable before starting a build with export MACOSX_DEPLOYMENT_TARGET=10.13. We use 10.13 at the moment. The packages can then be compiled by following the guide below. Open a terminal and type:

mkdir -p ~/nextcloud
cd ~/nextcloud
# Configure Qt5
git clone git://code.qt.io/qt/qt5.git
cd qt5
git checkout 5.15
./init-repository
cd ..

# Build Qt5 for x86_64
mkdir qt5-5.15-macOS-x86_64-release
cd qt5-5.15-macOS-x86_64-release
../qt5/configure -release -prefix ./qtbase -nomake examples -nomake tests QMAKE_APPLE_DEVICE_ARCHS=x86_64 -opensource -confirm-license -skip qt3d -skip qtwebengine
make -j15
cd ..

# Build Qt5 for arm64
mkdir qt5-5.15-macOS-arm64-release
cd qt5-5.15-macOS-x86_64-release
../qt5/configure -release -prefix ./qtbase -nomake examples -nomake tests QMAKE_APPLE_DEVICE_ARCHS=arm64 -opensource -confirm-license -skip qt3d -skip qtwebengine
make -j15
cd ..

# Configure OpenSSL
curl -O http://www.openssl.org/source/openssl-1.1.1k.tar.gz

# Build OpenSSL for x86_64
tar xvf openssl-1.1.1k.tar.gz
cd openssl-1.1.1k
# Switch to a x86 shell to use auto discovery of the platform in OpenSSL's config script
arch -x86_64 zsh
./config --prefix=/Users/nextcloud/nextcloud/openssl-1.1.1k-x86_64-release --openssldir=/Users/nextcloud/nextcloud/openssl-1.1.1k-x86_64-release
make -j15
make -j15 install
cd ..
rm -rf openssl-1.1.1k
# Exit from the x86 shell
exit

# Build OpenSSL for arm64
tar xvf openssl-1.1.1k.tar.gz
cd openssl-1.1.1k
./config --prefix=/Users/nextcloud/nextcloud/openssl-1.1.1k-arm64-release --openssldir=/Users/nextcloud/nextcloud/openssl-1.1.1k-arm64-release
make -j15
make -j15 install
cd ..
rm -rf openssl-1.1.1k

# Configure QtKeychain
git clone https://github.com/frankosterfeld/qtkeychain

# Build QtKeychain for x86_64
cd qtkeychain
mkdir build-x86_64
cd build-x86_64
cmake .. -DCMAKE_INSTALL_PREFIX=~/nextcloud/qtkeychain-x86_64-release -DCMAKE_OSX_ARCHITECTURES="x86_64"
make -j15
make -j15 install
cd ../..

# Build QtKeychain for arm64
cd qtkeychain
mkdir build-arm64
cd build-arm64
cmake .. -DCMAKE_INSTALL_PREFIX=~/nextcloud/qtkeychain-arm64-release -DCMAKE_OSX_ARCHITECTURES="arm64"
make -j15
make -j15 install
cd ../..

Now you can build two separate app packages of the desktop client (one for x86_64 and one for arm64) and then merge the binaries of these two app packages together to get a universal app package.

Compile the desktop client

After compiling Qt5, OpenSSL and QtKeychain, you can use this script (with the necessary modifications to match your environment and data) to compile, build, sign and notarize the package: build.sh