Fetching contributors…
Cannot retrieve contributors at this time
149 lines (112 sloc) 4.62 KB
0. Contents
1. Basic syntax
2. How do I...
3. Crosscompiling using CMake
4. Creating an installer binary for Windows
5. Building on OS X
This readme explains the most common parameters to CMake needed for
building mana, as well as setting up a cross build environement to
create Windows builds.
1. Basic syntax
cmake [options] <source directory>
If you don't need any special options just change to the directory where
you extracted the sources and do `cmake . && make'
The syntax for setting variables to control CMakes behaviour is
-D <variable>=<value>
2. How do I...
- Use a custom install prefix (like --prefix on autoconf)?
- Create a debug build?
- Add additional package search directories?
- Add additional include search directories?
For example, to build mana to install in /opt/mana, with libraries in
/build/mana/lib, and SDL-headers in /build/mana/include/SDL you'd use
the following command:
cmake -D CMAKE_PREFIX_PATH=/build/mana \
-D CMAKE_INCLUDE_PATH=/build/mana/include/SDL \
3. Crosscompiling using CMake
The following example assumes you're doing a Windows-build from within a
UNIX environement, using mingw32 installed in /build/mingw32.
- create a toolchain-file describing your environement:
$ cat /build/toolchain.cmake
# the name of the target operating system
# toolchain prefix, can be overridden by -DTOOLCHAIN=...
SET(TOOLCHAIN "i386-mingw32-")
# which compilers to use for C and C++
# here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /build/mingw32 /build/mana-libs )
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
- set your PATH to include the bin-directory of your mingw32-installation:
$ export PATH=/build/mingw32/bin:$PATH
- configure the source tree for the build, using the toolchain file:
$ cmake -DCMAKE_TOOLCHAIN_FILE=/build/toolchain.cmake .
- use make for building the application
4. Creating an installer binary for Windows
Call cmake with the following flags:
- CMAKE_TOOLCHAIN_FILE=/build/toolchain.cmake
The path to your toolchain file from chapter 3
The version number for the build, used to set client identification and
EXE meta information. Needs to be in the form Major.Minor.Release.Build
- CMAKE_BUILD_TYPE=RelWithDebInfo|Release
RelWithDebInfo is the prefered build type, as it provides some backtrace
information without blowing the binary up too much. Don't use Debug.
Install nsis (on Debian, apt-get install nsis), and get the UnTGZ plugin:
Place untgz.dll in nsis plugins directory (on Debian, /usr/share/nsis/Plugins/)
Now chdir to packaging/windows. Make sure you have the msgfmt program (from
gettext), and execute to generate translations from the
po-files in ../../translations/
Check that you've got the translations, and call `makensis setup.nsi' with the
following parameters:
The directory you've put the libraries. It's the one from the toolchain file
with /lib/ added at the end. If you'd like to include the Dr. MingW crash
handler place exchndl.dll in this directory.
Same as above
Set to upx if you'd like to compress the binaries using upx (and install upx,
of course). Will remove debug symbols.
Suffix to the source directory, pointing to the directory where the binaries
are. For cmake-builds that's /src.
To build the installer for the release you'd do the following:
$ cmake -DVERSION= -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_TOOLCHAIN_FILE=/build/toolchain.cmake .
$ make
$ cd packaging/windows
$ ./
$ makensis -DDLLDIR=/build/mana-libs/lib/ -DPRODUCT_VERSION= \
-DUPX=true -DEXESUFFIX=/src setup.nsi
and end up with the installer in mana-
5. Building on OS X
In your mana directory:
$ export CC=/usr/bin/clang
$ export CXX=/usr/bin/clang++
$ make
$ src/mana