Difference between revisions of "Guidelines and HOWTOs/Build from source/Mac"

Jump to: navigation, search
(Add instructions on using René's / Marko's patched port tree, and why you'd want to do this.)
(Install Craft)
 
(17 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
== Overview ==
 
== Overview ==
  
Several methods of building KDE / KF5 on Mac are available, and it is not firmly established, yet, which one is "best". The two main approaches are using either a "stock" version of Qt, or a "patched" Qt. The reason for patching being that KF5-applications will not be able to locate their resources (and particularly theme icons) out of the box with current stock versions of Qt.
+
Several methods of building KDE / KF5 on Mac are available, and it is not firmly established, yet, which one is "best". The two main approaches are using either a "stock" version of Qt, or a "patched" Qt. The latter has several patches meant to make KF5-applications work better on Mac. It also follows the file system layout of KDE on Linux, which should mean that KDE applications will be more likely to work correctly, without adjustments.
  
 
There is some hope that the required patches will eventually become available in official Qt packages, but this is not the case as of this writing. The main drawback with this is that Qt has to be compiled on your computer, adding hours to your setup time. The main advantage is that most things can be expected to work out of the box.
 
There is some hope that the required patches will eventually become available in official Qt packages, but this is not the case as of this writing. The main drawback with this is that Qt has to be compiled on your computer, adding hours to your setup time. The main advantage is that most things can be expected to work out of the box.
Line 8: Line 8:
  
 
* [https://guide.macports.org/#installing.macports Install Macports]
 
* [https://guide.macports.org/#installing.macports Install Macports]
** Since the patched version of Qt is not co-installable with a regular version of Qt (in the same prefix), you may want to install MacPorts to a non-default path, e.g. /opt/kf5, esp. if you are using other Qt packages in MacPorts.
+
** Note: If you have an existing installation of MacPorts ''and'' installed ports that depend on Qt, see [https://mail.kde.org/pipermail/kde-mac/2017-June/005280.html this mail].
 
* Install git, if you don't have it yet:
 
* Install git, if you don't have it yet:
 
  sudo port install git  
 
  sudo port install git  
Line 18: Line 18:
 
  cd macstrop
 
  cd macstrop
 
  portindex
 
  portindex
* Register the new ports with Macports. To do so, edit ${prefix}/etc/macports/sources.conf, where prefix is the root path of your MacPorts installation (/opt/local by default). Add the following line:
+
* [https://guide.macports.org/chunked/development.local-repositories.html Register the new ports with Macports]. To do so, edit ${prefix}/etc/macports/sources.conf, where prefix is the root path of your MacPorts installation (/opt/local by default). Add the following line ''above'' any other path specifications (thus making sure it will take precedence):
 
  file:///Users/YourUserName/macstrop
 
  file:///Users/YourUserName/macstrop
 +
 +
It is recommended that you build the patched Qt before any frameworks, in order to make extra sure all dependencies are resolved, correctly:
 +
sudo port install qt5-kde
  
 
You can now start building frameworks or applications (if already packaged), using e.g.
 
You can now start building frameworks or applications (if already packaged), using e.g.
 
  sudo port install kf5-parts
 
  sudo port install kf5-parts
or
+
  sudo port install kf5-kate
  sudo port install kate
+
  sudo port install kf5-frameworkintegration    # will get the most common frameworks in one go
 
 
The patched Qt itself is available as
 
  sudo port install qt5-kde
 
  
== Installation using stock version of Qt and Craft ==
+
Many ports have additional variants, such as "+docs" for handbooks / API documentation:
 +
sudo port install kf5-kate +docs
 +
port variants kf5-kate      # list available variants
 +
port notes kf5-kate            # show any notes
  
=== Install required tools and libraries ===
+
== Installation using Craft ==
Required tools and libraries can be installed using ''either'' Homebrew or Macports, as described below.
 
  
In ''both'' cases, you will need to download and install [https://developer.apple.com/xcode/ XCode], first.
+
* Install [https://www.python.org/downloads/ Python 3]
 +
* Install [https://developer.apple.com/xcode/ XCode] (at least developper command-line tools suffice):
 +
xcode-select --install
  
==== Homebrew (plus official Qt installer) ====
+
=== Install Craft ===
* Install Qt (use the official Qt installer, recommended version Qt >= 5.6)
+
  curl https://raw.githubusercontent.com/KDE/craft/master/setup/CraftBootstrap.py -o setup.py && python3 setup.py --prefix ~/CraftRoot
* Install homebrew and get some basic dependencies (http://brew.sh/)
 
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
 
brew install cmake wget coreutils p7zip gettext ninja python3 bison boost shared-mime-info
 
* Optional: You might need some extra environment variables
 
  
export CMAKE_LIBRARY_PATH=/usr/local/Cellar/gettext/0.19.8.1/lib
+
'''Note''': At the time of this writing, with a fresh installation of Python 3.7 or 3.8, this command will fail with "certificate verify failed: unable to get local issuer certificate". To fix this, run the following, ''once'':
export CMAKE_INCLUDE_PATH=/usr/local/Cellar/gettext/0.19.8.1/include
+
  /Applications/Python[Version]/Install/Certificates.command
export PATH=/usr/local/Cellar/bison/3.0.4/bin:$PATH
 
 
 
# Setup environment (path must contain your Qt install, here 5.7 default location and brew's gettext)
 
export PATH=/Users/cullmann/Qt5.7.0/5.7/clang_64/bin:/usr/local/Cellar/gettext/0.19.7/bin:$PATH
 
 
 
==== Macports (including Qt) ====
 
* [https://guide.macports.org/#installing.macports Install Macports]
 
* Install basic dependencies and tools:
 
sudo port install git qt56 cmake wget coreutils p7zip gettext ninja python36 bison boost shared-mime-info p5-any-uri-escape
 
* Add GNU coreutils to your system path:
 
export PATH=/opt/local/libexec/gnubin/:$PATH
 
 
 
=== Install Craft ===
 
# Prepare some build directory in your home directory, here we assume:
 
mkdir ~/kf
 
# Switch to this build dir
 
cd ~/kf
 
# Get Craft
 
git clone git://anongit.kde.org/craft.git
 
# Copy Mac OS X config template to right location, should be OK to use out of the box
 
mkdir etc
 
cp craft/kdesettings.mac etc/kdesettings.ini
 
  
 
=== Using craft ===
 
=== Using craft ===
 
* Every time you want to use craft in a new shell, you need to set up the craft environment, first:
 
* Every time you want to use craft in a new shell, you need to set up the craft environment, first:
  . craft/kdeenv.sh
+
  source ~/CraftRoot/craft/craftenv.sh
  
 
* In this shell, now craft is usable, e.g. to build Kate with all dependencies:
 
* In this shell, now craft is usable, e.g. to build Kate with all dependencies:
 
  craft kate
 
  craft kate
 
=== Deploying applications ===
 
* To create a app bundle (+ dmg file), you need to have the breeze-icons around:
 
craft breeze-icons
 
 
* To do deploy all things, unfortunately at the moment you need a patched macdeployqt. Example scripty for kate can be found on [https://quickgit.kde.org/?p=kate.git&a=blob&f=mac%2Femerge-deploy.sh kate.git/mac/emerge-deploy.sh]
 
** If you installed qt using Macports, your copy of macdeployqt ''should'' be patched, already. It will not be in your system path by default, however. Find it at /opt/local/libexec/qt5 .
 

Latest revision as of 10:18, 19 December 2019

Overview

Several methods of building KDE / KF5 on Mac are available, and it is not firmly established, yet, which one is "best". The two main approaches are using either a "stock" version of Qt, or a "patched" Qt. The latter has several patches meant to make KF5-applications work better on Mac. It also follows the file system layout of KDE on Linux, which should mean that KDE applications will be more likely to work correctly, without adjustments.

There is some hope that the required patches will eventually become available in official Qt packages, but this is not the case as of this writing. The main drawback with this is that Qt has to be compiled on your computer, adding hours to your setup time. The main advantage is that most things can be expected to work out of the box.

Installation using patched version of Qt and MacPorts

  • Install Macports
    • Note: If you have an existing installation of MacPorts and installed ports that depend on Qt, see this mail.
  • Install git, if you don't have it yet:
sudo port install git 
  • Get the ports tree for patched qt and frameworks:
# We assume you're doing this in your home directory
cd ~
git clone https://github.com/mkae/macstrop.git
# create index
cd macstrop
portindex
  • Register the new ports with Macports. To do so, edit ${prefix}/etc/macports/sources.conf, where prefix is the root path of your MacPorts installation (/opt/local by default). Add the following line above any other path specifications (thus making sure it will take precedence):
file:///Users/YourUserName/macstrop

It is recommended that you build the patched Qt before any frameworks, in order to make extra sure all dependencies are resolved, correctly:

sudo port install qt5-kde

You can now start building frameworks or applications (if already packaged), using e.g.

sudo port install kf5-parts
sudo port install kf5-kate
sudo port install kf5-frameworkintegration     # will get the most common frameworks in one go

Many ports have additional variants, such as "+docs" for handbooks / API documentation:

sudo port install kf5-kate +docs
port variants kf5-kate       # list available variants
port notes kf5-kate            # show any notes

Installation using Craft

  • Install Python 3
  • Install XCode (at least developper command-line tools suffice):
xcode-select --install

Install Craft

 curl https://raw.githubusercontent.com/KDE/craft/master/setup/CraftBootstrap.py -o setup.py && python3 setup.py --prefix ~/CraftRoot

Note: At the time of this writing, with a fresh installation of Python 3.7 or 3.8, this command will fail with "certificate verify failed: unable to get local issuer certificate". To fix this, run the following, once:

 /Applications/Python[Version]/Install/Certificates.command

Using craft

  • Every time you want to use craft in a new shell, you need to set up the craft environment, first:
source ~/CraftRoot/craft/craftenv.sh
  • In this shell, now craft is usable, e.g. to build Kate with all dependencies:
craft kate

This page was last edited on 19 December 2019, at 10:18. Content is available under Creative Commons License SA 4.0 unless otherwise noted.