summaryrefslogtreecommitdiff
path: root/README.cmake
blob: d703ecb9da835ce548a430cbc18f0070a915bd8c (plain) (blame)
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
This readme explains the most common parameters to CMake needed for 
building mana.

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>


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 .


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)
# which compilers to use for C and C++
SET(CMAKE_C_COMPILER i386-mingw32-gcc)
SET(CMAKE_CXX_COMPILER i386-mingw32-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