Building SVN versions with CMake

After many years of using the autotools build system, the developers of Scribus have selected CMake as a replacement system. It provides a much more flexible setup with a lot less complexity. It also provides compatibility with build tools on Linux and variants of Unix, Windows and Mac OSX.

'''You must have CMake version &ge; 2.4.3 for best results. Older versions will fail.'''

You might aswell read http://wiki.scribus.net/canvas/Official:Compile_with_CMake

Introduction: don't let it scare you off
Building Scribus yourself is not as hard as it sounds. In the rest of this page you'll find an answer to (almost) every question, you could have about this subject. It is worth reading, but you hopefully won't have to bother with most of the problems outlined here.

So, you may be interested in just knowing how it works in the best case.

Using Linux, it just boils down to, in case you want to compile the development version (1.5, very unstable) :

mkdir ~/src/ mkdir ~/src/scribus_svn sudo mkdir /usr/local/scribus_svn cd ~/src/scribus_svn svn co svn://scribus.net/trunk/Scribus cd ./Scribus mkdir build cd build cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/scribus_svn .. make sudo make install


 * you may change ~/src/ to wherever you want to put your source into.
 * you may change /usr/local/scribus_svn/ to wherever you want to put the Scribus binaries.
 * in case you want to install the 1.4 stable version, replace the "svn" instruction with following : svn co svn://scribus.net/branches/Version14x/Scribus

Now, if you want to understand what that commands mean, you will have to read through the rest of this page...

The easy way for Debian users
If you're using Debian (or Ubuntu) you need to manually compile the SVN version, only if you want to be really really up to date.

Otherwise, you can rely on the .deb for scribus-ng in our own repositories or, if you don't find the packages for your platform (ppc for instance) you can let apt-get compile from source using the latest sources in the repositories (most of the time those will be older than the SVN ones, but you probably don't really care).

You first have to add the source line for deb-src in synaptic, then you should become root ( sudo -i ) and:

apt-get source scribus-ng; cd scribus-ng-1.3.5.dfsg~svn20090208; apt-get build-dep scribus-ng; debuild -us -uc; dpkg -i ../scribus-ng_1.3.5.dfsg~svn20090208-3_i386.deb

For more information on using Scribus with debian, please have a look at the Debian page our offical site

=First thing first: Download latest snapshot with Subversion=

Subversion is the versioning control system used for Scribus. Check this link for instructions for using Subversion.

All subversion URLs for Scribus anonsvn are based at:

svn://scribus.net/

There's also http://scribus.net/svn/Scribus/, which gets you to the same content, but svn://scribus.net/ is usually faster. HTTP access might be useful to those behind paranoid firewalls or proxies, though.

If you used to check out -r , check out  instead:

So, if I wanted to use svn:// to check out 1.4.x.svn, I'd run:

svn co svn://scribus.net/branches/Version14x/Scribus scribus14x

Updating your working copy is much the same as cvs - just cd into your working copy and run "svn up".

Some links to learn more about downloading Scribus and about SVN:
 * There is an online reference for SVN at this site.
 * Once you have subversion installed, you can get some help for SVN at the command line by entering svn help
 * See the installing section on docs.scribus.net for more info on the Official Documentation site.
 * Craig Ringer explained how to use SVN with Scribus on the list.

Thanks to Anduin.net [], anonymous SVN access is updated daily.

More info on downloading scribus:
 * Standard download
 * CVS download

If you are compiling for the first time, don't be scared of the command line. Just copy the lines relevant to the version of Scribus you want to use, one by one on the command line.

Watch out:
 * Newbies should take care, that only 'make install' part has to be done as a root. Rest of the part, like downloading and compiling can be done easily as a normal users. You can install as a user, however, if you are installing into a directory you have write permission for. See the -DCMAKE_INSTALL_PREFIX command below.
 * And if u already have a version of Scribus on your system, don't forget to use the option WANT_VERSIONING=1. You can specify this option as -DWANT_VERSIONING=1.

Good luck!

Getting All the Things You Need
This is probably something of a worst-case scenario, but likely representative for a situation for a newbie having no built-in capability to compile software.

An installation of Fedora 8 was done on a computer having no DVD drive, so therefore a CD had to be used, in this case the Fedora-8-Live-KDE CD. Installing Fedora 8 in this manner is simple, since everything on the CD gets installed, but you have no capability to compile software – none whatsoever.

The basic beginning packages needed are these, obtained with ... :
 * gcc
 * gcc-c++
 * cmake
 * subversion – if you're going to compile, you might as well get the latest Scribus updates

So if you follow the instructions above for downloading using, then use Cmake, you have many dependencies to deal with, so get these before you even try Cmake the first time:
 * ghostscript – this should already be there
 * qt-devel
 * pkgconfig
 * lcms-devel
 * libjpeg-devel
 * libtiff-devel
 * libart_lgpl-devel
 * cups-devel
 * libxml2 and libxml2-devel – you should already have libxml2
 * python and python-devel
 * fontconfig-devel
 * openssl-devel
 * freetype and freetype-devel
 * python-imaging-devel
 * tk and tkinter
 * hunspell and hunspell-devel (as of 1.4.2)
 * cairo and cairo-devel – you should already have cairo
 * qt4 and qt4-devel

For Fedora at least, the names are as used with yum, for example:

and so on. On other distros the exact names may vary. Here is a link describing the particulars for Ubuntu 7.10 (Gutsy Gibbon):

On Fedora, if you install various development packages, you have most of what you need. Exceptions seem to be cups-devel, lcms-devel, tk and tkinter, and python-imaging-devel (maybe cairo-devel). Incidentally, in Fedora 9 and later, Qt4 is loaded by default, and is labeled only qt and qt-devel.

On Debian, if you install the develeopment packages as described above you will need the following packages to build the trunk (status September 2011):
 * libqtwebkit-dev

Packages for Ubuntu
To install all the required libraries and packages for Debian or Ubuntu type the following in a terminal: sudo apt-get build-dep scribus-ng

Right now (March 2011) the build dependencies for Scribus 1.4.0 on Debian/Ubuntu are: debhelper (>= 7), cmake (>= 2.4.3), gcc (>=3.3.5), libqt4-dev (>= 4.6), libcairo2-dev, zlib1g-dev, liblcms1-dev (>= 1.13), libtiff4-dev, libcups2-dev,libxml2-dev (>= 2.6.16), gettext, python-all-dev, libboost-python-dev, libaspell-dev, libpodofo-dev (>= 0.8.4), quilt

Version 1.5.x
In 1.5.0+, there are a number of vector and bitmap graphics formats which can now be imported into Scribus. Some of these have particular additional dependencies.

GraphicsMagick (Optional)
You do not need GraphicsMagick to run cmake or compile 1.5.0svn, but some added capabilities will be present if you have it. What Scribus needs are the following (Fedora nomenclature): GraphicsMagick, GraphicsMagick-devel, GraphicsMagick-c++, and GraphicsMagick-c++-devel. These last two are tricky, since the message from cmake will tell you that GraphicsMagick++ is missing, but this is the name of the lib file, not the package.

Yum can help you with these kinds of things to avoid having to browse a repository.

yum list GraphicMagick* will show a list of available packages

yum install GraphicsMagick* will install all of them.

OpenSceneGraph (Optional)
This may be available with your Linux distribution (definitely for Fedora 17). You can also download and compile.

For Fedora, typing

should be enough, and will get you the additional requirements of Inventor, OpenThreads, and OpenThreads-devel.

For OpenSUSE, go to http://software.opensuse.org/package/OpenSceneGraph and use the 1-click install procedure.

Why Do I Have to 'Build' Scribus?
For that matter, what is Building?

When you are going to build or compile Scribus, what you have downloaded is a large collection of plain-text files (ending in '.c' or '.cpp' to denote either the C or C++ language respectively). The reason there are so many is that this actually makes the process of developing software easier, and allows for use of small parts repeatedly by different functions of the overall program. These plain-text files need to be converted to binary files (ending in ',o' for object files) so that your PC can use them, and the program works efficiently.

The first step is to configure your downloaded directory of files. This requires a check of your PC to make sure the compiling programs and all the other required outside resources are present and sufficiently up-to-date. Just as Scribus itself consists of these small program files, it also will use those of outside programs, like CUPS, lcms, and so on, so it needs to have on hand those plain text files to connect to these outside resources. After checking for the necessary resources, a script is written to tell the compiler how to go about building Scribus. The process will fail if you are missing something, and cmake will give you error messages.

The Scribus Team now encourages the use of cmake for this configuring process. It is quick, easy to use, and easy for the developers to write for -- even cmake needs instructions. You can also pass to cmake several special parameters for your particular PC setup, where you want Scribus to be installed, for example.

Next, the actual 'build' process is done with a program called make. To start the process you simply enter make in a command line. That's it. You do not need to have root privileges to compile, and it is generally recommended that do not compile as root (one reason for this is that, by creating a number of files under root's name, you then interfere with subsequent updating from SVN). Compiling takes up a good part of your computer's resources, especially your processor(s), so you will find its performance rather sluggish while compiling is going on. Consequently, many find that compiling is best done by starting make and then walking away from the PC to let it do its work.

Finally, you need to install, done with the command make install. If you are going to install in the default location, you will need to have root privileges. On most Linux distros this can easily be done with the su</tt> command (after which you need root's password), or with sudo, entered as sudo make install</tt>. You can run cmake with a command that can install Scribus in a directory for which you have write privileges, and therefore do not need to be  root.

For this help, and other advice, continue reading the following sections.

To start the build
Before continuing, please note that an out-of-source build is recommended, however.. From the Scribus directory:

For example:

Some options that the Scribus CMake files know about (more to come!):
 * -DWANT_VERSIONING=1: Sets the build to use the VERSION setting as a suffix for the install directories and the binary. Eg, the binary could be . This should mean that you can install multiple versions with the same prefix with no clashes.
 * -DWANT_DEBUG=1: Sets the build to be a debug release and use -O0 -g3, instead of -O2 (This is the default for now, and cannot be turned off unless you edit the CMakeFiles.txt file).
 * -DWANT_CAIRO=1: Makes CMake search for cairo and build with cairo instead of LibArt_LGPL. cairo is the primary supported option for 1.3.5+.
 * -DWANT_LIBART=1 (not available in 1.3.5, default in 1.3.3.x): Makes CMake search for and build with LibArt_LGPL instead of cairo.
 * -DWANT_QTARTHUR=1: In 1.3.5, uses the QT4 ARTHUR rendering library. This is an alternative to CAIRO.
 * -DWANT_HUNSPELL=1: This will enable the new (as of 1.4.2) hunspell-based spell checking capabilities across *all* platforms.

If you have several version of QT installed or QT is installed in a non standard location you'll have to tell cmake where to find it by setting

For example: to make a cairo debug build, then something like this:

To use qt_arthur instead:

Out-of-source builds
One of the advantages of CMake is that you can do an out-of-source build. What is this? It enables you to build the application without writing anything at all to the directory where the Scribus source is. This means your source tree is clean, always. Its easier and faster to update, and you can build multiple targets out-of-source from the same source tree. Cool!

To do an out-of-source build, you need a new directory to build in. Say you have the source files in:

Make the following directory:

So then, instead of doing:

you would then change to the builddir directory and run:

Simple!

More CMake Options
CMake_Build_Options

Continuing on to the build stage
Once this has successfully completed, simply run.

The CMake based build system is very new to Scribus and it will change and it will need improving. Please report issues on our mailing list or bugtracker.

There is a long todo list for this build system including, but not limited to:
 * Checking it works across distributions
 * Checking it works across various flavours of UNIX
 * Checking it works on 64 bit distros
 * Add Win32 and Mac OSX support

Compilation fails using Qt4 binaries
Systems with both Qt3 and Qt4 installed: You have  and   from Qt4 in the path and it may results to the compilation crash. This should NOT be the case with cmake 2.4.2 when released, or when using current Scribus CVS. However, this might be a useful workaround:

Remove cached options from previous cmake configuration run:

Then change PATH variable (for my Gentoo) e.g.:

And run cmake config phase again:

eg

Specific library locations
Whenever your distribution releases their package for a library Scribus depends on, it may still not be the very latest stable or unstable version from the writers of the library. In some cases, the Scribus developers have had to rely on the very latest code to further some parts of Scribus. In this case it is necessary to build your own version of such a library.

One example of this is the cairo graphics library. Right now, 1.3.5svn has the capability to use the very very latest code from the just released cairo 1.4.

To specify a new cairo install path, other than your system's default add this to the cmake command line:

Instructions for specific distributions or versions

 * [Scribus 1.3.5svn for Ubuntu 7.10 "Gutsy Gibbon"]

Making a tarball for distribution
To make a tarball for distribution, the old way would be to. The new way is to run  or   to give you a bundle of the source. With cmake 2.4.1 there is only support for a gzip  however a bzip2   is possible with later versions of cmake.

Notes For Packagers
If you package Scribus for a distribution keep in mind the issue of the install prefix versus temporary install directory prefix. The following seems to work well for Debian packaging:

then

where $(BUILD_DIR) is ./build and $(INSTALL_DIR) is ./install

Using $(PREFIX) is the key to avoiding hardcoded absolute path problem.

TODO

 * Enable more pkg-config usage
 * 64 bit supoprt
 * Prefixes for more packages

Success Stories
Please add the operating system or distribution that you have tested successfully on:
 * Gentoo, current (--Cbradney 17:04, 12 November 2006 (CET))


 * Kubuntu Dapper Drake (--TomZ 17:08, 12 November 2006 (CET))
 * Ubuntu Feisty (--Oberten 23 March 2007)
 * Ubuntu Gutsy 32bits (--Brunod 24 November 2007)
 * Ubuntu Hardy (--a.l.e 30 May 2008)


 * SuSE Linux 10.0 (--C_schaefer 19 November 2006)
 * openSuse 10.1 (--TomZ 17:08, 12 November 2006 (CET))
 * OpenSuSE 10.2 (--C_schaefer 28 February 2007)
 * OpenSUSE 10.3
 * SUSE Linux Enterprise Desktop 10 (i586) --Mhanski 15:41, 21 April 2007 (CEST)


 * Fedora Core 6 (--gpittman 15:44, 12 November 2006 (EST))
 * Fedora 8 i386 (--Zoonfafer 12:42, 10 December 2007 (CET))
 * Fedora 9 (--G Pittman)
 * Fedora 12 (--Hhartley 02:32, 12 May 2010 (CEST))
 * Fedora 13 (--Hhartley 00:27, 29 May 2010 (CEST))


 * PLD Linux Th (--DeeJay1 09:52, 13 November 2006 (CET))


 * Mandriva 2007 (--Leo mailto:leo.thealmighty@gmail.com 01:00, 16 November, 2006 (IST)) - a smooth ride


 * PCLinuxOS 0.93a (--Leo mailto:leo.thealmighty@gmail.com few days before i tried mandriva 2007) - manualy specified lib locations


 * MacOSX 10.4 Tiger (--avox 18:50, 1 March 2007 (CET)) check the advanced settings with ccmake, sometimes it doesnt pick up some paths


 * Debian Sid and Lenny (--Gemy_c 06 August 2007 and for a long time ;) )