Best Build 21 Screenshot

Log in to vote!

Latest Posts

Changes in WidelandsGoingCMake

Editor Comment

Updates regarding build targets and directories

Revision Differences of Revision 35

# Widelands going CMake ¶

Widelands project plans to move from the current build system SCons to CMake. ¶

This page is to track progress and collect important information in the transition process. ¶

## Table of Contents: ¶
[TOC] ¶

## Important Links ¶

* [SCons](http://www.scons.org) ¶
* [CMake](http://www.cmake.org) ¶
* [CMake Tutorial \(PDF\]](http://www-flc.desy.de/ldcoptimization/documents/talks/CMake_Tutorial.pdf) ¶

## Important notes ¶
### Things to know about CMake/make ¶
* SCons and CMake use a very different approach on building. With SCons you build within the source path, with CMake you are very obligued not to do so, but build in a different path instead. This is called "out of source build". ¶
* With SCons you only use one command for building, with CMake you use two. CMake is a tool to generate Makefiles, which are then used to build. So it is "scons" vs. "cmake;make". But don't worry, most of the time you don't need to think about this. ¶

### Things to know about the transition ¶
* CMake transition is now on the main repository (bzr) in Launchpad. If you check out from there, and build using scons, you can also try building using cmake/make ¶

## What you can do with cmake/make for widelands ¶
### cmake ¶
* General cmake command (from out-of-source-directory!): cmake <path to source-top-level-directory> generates everything. ¶
* e.g. cd ~/widelands-cmake-build && cmake ~/widelands/widelands ¶
* all other settings in cmake are made using "directive" -D ¶
* Attention: every setting is "remembered" by CMake cache, so if you say -DFU=BAR and at next run of cmake you omit -DFU=BAR, it is still set! ¶
* Select build type: Debug or Release (at the moment only those two are supported) ¶
* cmake -DCMAKE_BUILD_TYPE=Release ~/widelands/widelands ¶
* cmake -DCMAKE_BUILD_TYPE=Debug ~/widelands/widelands ¶
* Define the version of the built package (override/skip SVN versioning scheme) ¶
* cmake -DWL_VERSION_MAJOR=0 -DWL_VERSION_MINOR=15 ~/widelands/widelands ¶
* Define the target directory for the "install" target ¶
* cmake -DCMAKE_INSTALL_PREFIX=~/widelands-install ¶

### make ¶
* make (ALL) ¶
* compile everything, up to executable with the settings from cmake call ¶
* make codecheck ¶
* run the codechecks ¶
* make doc ¶
* generate documentation. Currently only with Build Type Debug, but this is easily changed if necessary. ¶
* make pics ¶
* optimize the images in the pics directory (not in source directory, it copies them over) ¶
* make quickpics ¶
* just copy the images in the pics directory without optimizing them (this is a developer target) ¶
* make install ¶
* install into the target dir, this is /usr/local per default (you need root privileges!) or you change it (see above) ¶
* make package ¶
* generate a package, currently out of order (generating empty package) and has still missing features (pics not included and so on) ¶
* make lang ¶
* generate the translations (not in source directory, copies them over to build directory) ¶

### Starting with CMake in the transition (this is for Linux; Windows will differ) ¶
#### 1. Preparation ¶
* Get the sources, as written in BzrPrimer ¶
* $ cd ~/widelands/widelands ¶
* $ mkdir build-cmake ¶

#### 2. Using CMake ¶
* $ cd ~/widelands/widelands/build-cmake ¶
* go to the build directory ¶
* $ cmake .. ¶
* let CMake create the Makefiles in the current directory, regarding the CMakeLists.txt files in the parent (widelands-cmake) directory (this is out-of-source) ¶
* $ cmake -DCMAKE_INSTALL_PREFIX=~/widelands-cmake-install .. ¶
* if you want to have a different install directory for "make install" instead of /usr/local ¶

#### 3. Using make ¶
* $ cd ~/widelands/widelands/build-cmake ¶
* go to the build directory ¶
* $ make -j3 ¶
* this compiles the sources ¶
* -j3 tells make to run 3 concurrent tasks, which is recommended for DualCore CPUs. Basic rule is -j(number of cores + 1) as recommendation, but beware, gcc takes lots of RAM. ¶
* $ make install -j3 ¶
* this compiles the sources and then installs in either /usr/local (which you need root privileges for), or in the directory mentioned in 2. with -DCMAKE_INSTALL_PREFIX ¶
* -j3 tells make to run 3 concurrent tasks, which is recommended for DualCore CPUs. Basic rule is -j(number of cores + 1) as recommendation, but beware, gcc takes lots of RAM. ¶
* make install includes make, so "make install" is basically the same like "make && make install" ¶

#### 4. Running freshly built widelands ¶
* if you did just "make" ¶
* From
any directoury (which is not a different widelands-cm daketa directory (e.g. "cd ..") ¶
* ./build-cmake/src/widelands ¶
* ATTENTION: This is not recommended, since it will be missing some files (locale, consolidated pics...). Use "make install" instead. ¶
* if you did "make install" and were root ¶
* $ /usr/local/bin/widelands ¶
* if you were not root, used "make install" and specified "-DCMAKE_INSTALL_PREFIX" as above ¶
cd ~/widelands-cmake-install/share/widelands && ../../bin/widelands ¶

#### What you currently have to do to get a complete build ¶
This section tells you what you are currently (as in BZR trunk latest revision) have to do to get a full branch. This is work-in-progress and will change every now and then, so check back. ¶
* cmake (prepares the build directory) ¶
* make pics (optimizes the pics directory) ¶
* alternatively: make quickpics (just copy them over
) ¶
* make locale (only if you need a language other than English) ¶
* make install (compiles and installs) ¶

## Identified Tasks ¶
### Transition tasks ¶
* Identify SCons tasks and targets used by widelands, replace using cmake & make ¶
* scons ¶
* make ¶
* scons -c ¶
* make clean ¶
* scons doc ¶
* make doc (no dependency to make) ¶
* make install (no scons target?) ¶
* CMake 2.6 should be used. Do we need CMake 2.8? ¶
* Identify bugs/improvements from bug tracker and mailing list ¶
* Identify additional tasks, build tools etc. ¶
* build/scons-tools/Distribute.py ¶
* Script for packaging a complete binary distribution (Release?) ¶
* Scons and Python tool ¶
* proposal: make package with new CMake script ¶
###Issues ¶
* Running widelands writes to console: "WARNING: either we can not detect your home directory or you do not have one! Please contact the developers. Instead of your home directory, '.' will be used. Set home directory: ./.widelands". There's something missing. ¶
* Found the problem. config.h.cmake is missing #define HAS_GETENV which is done by Scons. Can we set this in any case? How does Windows react to that? ¶
* done in SVN/BZR, awaiting testers ¶
* Changing language doesn't work. English only. ¶
* Found the problem. The locales do not get compiled. Doesn't work on the fly because of out-of-source build (cmake) conflicting with the script which creates the locales (expects to be run from base dir and writes there). Either modify script or find a way to run it out-of-source. ¶
* Hopefully we will use Launchpad translation so this becomes not an issue anymore. ¶
* Finding doxygen works. Test with non-working doxygen and about working doxygen without dot to be done. ¶
* Find some Windows/MinGW system to test. ¶
* Do we really need 3 tools to optimize the PNG files? pngrewrite, optipng and advdef? ¶
* "make pics" needs testers for Windows and Darwin, trying to find pngrewrite and optipng. ¶
* CPack issue with path names and components package, always generating empty assemblies. ¶
* Either we get that sorted out, or we'd have to write own packaging scripts (not nice) ¶

## Build systems for testing ¶
### System1 (maintained by Qcumber-some) ¶
* Intel Core2 Duo, Gentoo Linux 32bit ¶
* gcc 4.3.4, cmake 2.6, libsdl 1.2.13, lua 5.1.4, boost 1.35 ¶