1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
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)?
CMAKE_INSTALL_PREFIX=/path/to/prefix
- Create a debug build?
CMAKE_BUILD_TYPE=Debug .
- Add additional package search directories?
CMAKE_PREFIX_PATH=/prefix/path
- Add additional include search directories?
CMAKE_INCLUDE_PATH=/include/path
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 \
-D CMAKE_INSTALL_PREFIX=/opt/mana .
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
SET(CMAKE_SYSTEM_NAME Windows)
# toolchain prefix, can be overridden by -DTOOLCHAIN=...
IF (NOT TOOLCHAIN)
SET(TOOLCHAIN "i386-mingw32-")
ENDIF()
# which compilers to use for C and C++
SET(CMAKE_C_COMPILER ${TOOLCHAIN}gcc)
SET(CMAKE_CXX_COMPILER ${TOOLCHAIN}g++)
# 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(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
- 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
- VERSION=$VERSION
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:
http://nsis.sourceforge.net/UnTGZ_plug-in
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 make-translations.sh 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:
-DDLLDIR=/build/mana-libs/lib/
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.
-DPRODUCT_VERSION=$VERSION
Same as above
-DUPX=true
Set to upx if you'd like to compress the binaries using upx (and install upx,
of course). Will remove debug symbols.
-DEXESUFFIX=/src
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 0.1.0.0 release you'd do the following:
$ cmake -DVERSION=0.1.0.0 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_TOOLCHAIN_FILE=/build/toolchain.cmake .
[...]
$ make
[...]
$ cd packaging/windows
$ ./make-translations.sh
[...]
$ makensis -DDLLDIR=/build/mana-libs/lib/ -DPRODUCT_VERSION=0.1.0.0 \
-DUPX=true -DEXESUFFIX=/src setup.nsi
and end up with the installer in mana-0.1.0.0-win32.exe
5. Building on OS X
-------------------
In your mana directory:
$ export CC=/usr/bin/clang
$ export CXX=/usr/bin/clang++
$ cmake .
$ make
$ src/mana
|