1
This readme explains the most common parameters to CMake needed for 
2
building tmw.
3
4
Basic syntax
5
------------
6
7
cmake [options] <source directory>
8
9
If you don't need any special options just change to the directory where 
10
you extracted the sources and do `cmake . && make'
11
12
The syntax for setting variables to control CMakes behaviour is 
13
-D <variable>=<value>
14
15
16
How do I...
17
-----------
18
19
- Use a custom install prefix (like --prefix on autoconf)?
20
  CMAKE_INSTALL_PREFIX=/path/to/prefix
21
- Create a debug build?
22
  CMAKE_BUILD_TYPE=Debug .
23
- Add additional package search directories?
24
  CMAKE_PREFIX_PATH=/prefix/path
25
- Add additional include search directories?
26
  CMAKE_INCLUDE_PATH=/include/path
27
28
For example, to build tmw to install in /opt/tmw, with libraries in 
29
/build/tmw/lib, and SDL-headers in /build/tmw/include/SDL you'd use 
30
the following command:
31
32
cmake -D CMAKE_PREFIX_PATH=/build/tmw \
33
  -D CMAKE_INCLUDE_PATH=/build/tmw/include/SDL \
34
  -D CMAKE_INSTALL_PREFIX=/opt/tmw .
35
36
37
Crosscompiling using CMake
38
--------------------------
39
40
The following example assumes you're doing a Windows-build from within a
41
UNIX environement, using mingw32 installed in /build/mingw32.
42
43
- create a toolchain-file describing your environement:
44
$ cat /build/toolchain.cmake
45
# the name of the target operating system
46
SET(CMAKE_SYSTEM_NAME Windows)
47
# which compilers to use for C and C++
48
SET(CMAKE_C_COMPILER i386-mingw32-gcc)
49
SET(CMAKE_CXX_COMPILER i386-mingw32-g++)
50
# here is the target environment located
51
SET(CMAKE_FIND_ROOT_PATH  /build/mingw32 /build/tmw-libs )
52
# adjust the default behaviour of the FIND_XXX() commands:
53
# search headers and libraries in the target environment, search 
54
# programs in the host environment
55
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
56
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
57
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
58
59
- set your PATH to include the bin-directory of your mingw32-installation:
60
$ export PATH=/build/mingw32/bin:$PATH
61
62
- configure the source tree for the build, using the toolchain file:
63
$ cmake -DCMAKE_TOOLCHAIN_FILE=/build/toolchain.cmake . 
64
65
- use make for building the application