summaryrefslogtreecommitdiffstats
path: root/project/cmake/README.md
blob: c0f94d821a5d286a65ca5939ef43c9e31451808e (plain)
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# Kodi CMake based buildsystem

This files describes Kodi's CMake based buildsystem. CMake is a cross-platform
tool for generating makefiles as well as project files used by IDEs.

The current version of the buildsystem is capable of building the main Kodi
executable (but no packaging or dependency management yet) for the following
platforms:

- Linux (GNU Makefiles)
- Windows (NMake Makefiles, Visual Studio 12 (2013))
- OSX (GNU Makefiles, Xcode)
- Android (GNU Makefiles)

Before building Kodi with CMake, please ensure that you have the platform
specific dependencies installed.

While the legacy build systems typically used in-source builds it's recommended
to use out-of-source builds with CMake. The necessary runtime dependencies such
as dlls, skins and configuration files are copied over to the build directory
automatically.

## Dependency installation

### Linux

The dependencies required to build on Linux can be found in
[docs/README.xxx](https://github.com/xbmc/xbmc/tree/master/docs).

### Raspberry Pi

The cross compilation environment for the Raspberry Pi as well as the
dependencies have to be installed as explained in
[docs/README.raspberrypi](https://github.com/xbmc/xbmc/tree/master/docs/README.raspberrypi).

### Windows

For Windows the dependencies can be found in the
[Wiki](http://kodi.wiki/view/HOW-TO:Compile_Kodi_for_Windows) (Step 1-4). If not already available on your pc, you should
install the [Windows Software Development Kit (SDK)](https://dev.windows.com/en-us/downloads/sdk-archive) for your Windows version. This is required for HLSL shader offline compiling with the [Effect-Compiler Tool](https://msdn.microsoft.com/de-de/library/windows/desktop/bb232919(v=vs.85).aspx) (fxc.exe).

On Windows, the CMake based buildsystem requires that the binary dependencies
are downloaded using `DownloadBuildDeps.bat` and `DownloadMingwBuildEnv.bat`
and that the mingw libs (ffmpeg, libdvd and others) are built using
`make-mingwlibs.bat`.

### OSX

For OSX the required dependencies can be found in
[docs/README.osx](https://github.com/xbmc/xbmc/tree/master/docs/README.osx).

On OSX it is necessary to build the dependencies in `tools/depends` using
`./bootstrap && ./configure --host=<PLATFORM> && make`. The other steps such
as `make -C tools/depends/target/xbmc` and `make xcode_depends` are not needed
as these steps are covered already by the CMake project.

### Android

The dependencies needed to compile for Android can be found in
[docs/README.osx](https://github.com/xbmc/xbmc/tree/master/docs/README.android)
. All described steps have to be executed (except 5.2 which is replaced by the
respective CMake command below).

## Building Kodi

This section lists the necessary commands for building Kodi with CMake.
CMake supports different generators that can be classified into two categories:
single- and multiconfiguration generators.

A single configuration generator (GNU/NMake Makefiles) generates project files
for a single build type (e.g. Debug, Release) specified at configure time.
Multi configuration generators (Visual Studio, Xcode) allow to specify the
build type at compile time.

All examples below are for out-of-source builds with Kodi checked out to
`<KODI_SRC>`:

```
mkdir kodi-build && cd kodi-build
```

### Linux with GNU Makefiles

```
cmake <KODI_SRC>/project/cmake/
cmake --build . -- VERBOSE=1 -j$(nproc)  # or: make VERBOSE=1 -j$(nproc)
./kodi.bin
```

`CMAKE_BUILD_TYPE` defaults to `Release`.

### Raspberry Pi with GNU Makefiles

```
cmake -DCMAKE_TOOLCHAIN_FILE=<KODI_SRC>/tools/depends/target/Toolchain.cmake <KODI_SRC>/project/cmake/
cmake --build . -- VERBOSE=1 -j$(nproc)  # or: make VERBOSE=1 -j$(nproc)
```

### Windows with NMake Makefiles

```
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release <KODI_SRC>/project/cmake/
cmake --build .  # or: nmake
kodi.exe
```

### Windows with Visual Studio project files

```
cmake -G "Visual Studio 12" <KODI_SRC>/project/cmake/
cmake --build . --config "Debug"  # or: Build solution with Visual Studio
set KODI_HOME="%CD%" && Debug\kodi.exe
```

### OSX with GNU Makefiles

```
cmake -DCMAKE_TOOLCHAIN_FILE=<KODI_SRC>/tools/depends/target/Toolchain.cmake <KODI_SRC>/project/cmake/
cmake --build . -- VERBOSE=1 -j$(sysctl -n hw.ncpu)  # or: make VERBOSE=1 -j$(sysctl -n hw.ncpu)
./kodi.bin
```

### OSX with Xcode project files

```
cmake -DCMAKE_TOOLCHAIN_FILE=<KODI_SRC>/tools/depends/target/Toolchain.cmake -G "Xcode" <KODI_SRC>/project/cmake/
cmake --build . --config "Release" -- -verbose -jobs $(sysctl -n hw.ncpu)  # or: Build solution with Xcode
KODI_HOME=$(pwd) ./Release/kodi.bin
```

### Android with GNU Makefiles

```
cmake -DCMAKE_TOOLCHAIN_FILE=<KODI_SRC>/tools/depends/target/Toolchain.cmake <KODI_SRC>/project/cmake/
cmake --build . -- VERBOSE=1 -j$(nproc)  # or: make VERBOSE=1 -j$(nproc)
```

## Extra targets

When using the makefile builds a few extra targets are defined:

- `make check` builds and executes the test suite.

## Debugging the build

This section covers some tips that can be useful for debugging a CMake
based build.

### Verbosity (show compiler and linker parameters)

In order to see the exact compiler commands `make` and `nmake` can be
executed with a `VERBOSE=1` parameter.

On Windows, this is unfortunately not enough because `nmake` uses
temporary files to workaround `nmake`'s command string length limitations.
In order to see verbose output the file
[Modules/Platform/Windows.cmake](https://github.com/Kitware/CMake/blob/master/Modules/Platform/Windows.cmake#L40)
in the local CMake installation has to be adapted by uncommenting these
lines:

```
# uncomment these out to debug nmake and borland makefiles
#set(CMAKE_START_TEMP_FILE "")
#set(CMAKE_END_TEMP_FILE "")
#set(CMAKE_VERBOSE_MAKEFILE 1)
```