summaryrefslogtreecommitdiffstats
path: root/cmake/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/README.md')
-rw-r--r--cmake/README.md315
1 files changed, 37 insertions, 278 deletions
diff --git a/cmake/README.md b/cmake/README.md
index c1b953f..8637da6 100644
--- a/cmake/README.md
+++ b/cmake/README.md
@@ -1,326 +1,85 @@
1# Kodi CMake based buildsystem 1![Kodi Logo](../docs/resources/banner_slim.png)
2 2
3This files describes Kodi's CMake based buildsystem. CMake is a cross-platform 3# Kodi's CMake Based Build System
4tool for generating makefiles as well as project files used by IDEs. 4Welcome to Kodi's CMake Based Build System. CMake is a cross-platform tool for generating makefiles as well as project files used by IDEs. The current version of the build system is capable of building and packaging Kodi for the following platforms:
5 5
6The current version of the buildsystem is capable of building and packaging 6* Linux (several distros)
7Kodi for the following platforms: 7* Windows
8* macOS and iOS
9* Android
10* FreeBSD
8 11
9- Linux (GNU Makefiles, Ninja) 12While 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. Instructions are highly dependent on your operating system and target platform but we prepared a set of **[build guides](../docs/README.md)** for your convenience.
10- Windows (NMake Makefiles, Visual Studio 14 (2015), Ninja)
11- macOS and iOS (GNU Makefiles, Xcode, Ninja)
12- Android (GNU Makefiles)
13- FreeBSD (GNU Makefiles)
14 13
15Before building Kodi with CMake, please ensure that you have the platform 14## Build options
16specific dependencies installed. 15Kodi supports a number of build options that can enable or disable functionality. These options must be set when running CMake with `-DENABLE_<OPTION>=<ON|OFF|AUTO`. The default is `AUTO` which enables the option if a certain dependency is found. For example CEC support is enabled if `libCEC` is available. `ON` forcefully enables the dependency and the CMake run will **fail** if the related dependency is not available. `OFF` will disable the feature.
17
18While the legacy build systems typically used in-source builds it's recommended
19to use out-of-source builds with CMake. The necessary runtime dependencies such
20as dlls, skins and configuration files are copied over to the build directory
21automatically.
22
23## Dependency installation
24
25### Linux
26
27The dependencies required to build on Linux can be found in
28[docs/README.xxx](https://github.com/xbmc/xbmc/tree/master/docs).
29
30### Raspberry Pi
31
32The cross compilation environment for the Raspberry Pi as well as the
33dependencies have to be installed as explained in
34[docs/README.raspberrypi](https://github.com/xbmc/xbmc/tree/master/docs/README.raspberrypi).
35
36### Windows
37
38For Windows the dependencies can be found in the
39[Wiki](https://kodi.wiki/view/HOW-TO:Compile_Kodi_for_Windows#Setting_up_the_build_Environment) (Step 1-4). If not already available on your pc, you should
40install 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).
41
42On Windows, the CMake based buildsystem requires that the binary dependencies
43are downloaded using `download-dependencies.bat` and `download-msys2.bat`
44and that the mingw libs (ffmpeg, libdvd and others) are built using
45`make-mingwlibs.bat`.
46
47### macOS
48
49For macOS the required dependencies can be found in
50[docs/README.osx.md](https://github.com/xbmc/xbmc/tree/master/docs/README.osx.md).
51
52On macOS it is necessary to build the dependencies in `tools/depends` using
53`./bootstrap && ./configure --host=<PLATFORM> && make`. The other steps such
54as `make -C tools/depends/target/xbmc` and `make xcode_depends` are not needed
55as these steps are covered already by the CMake project.
56
57### Android
58
59The dependencies needed to compile for Android can be found in
60[docs/README.android](https://github.com/xbmc/xbmc/tree/master/docs/README.android)
61. All described steps have to be executed (except 5.2 which is replaced by the
62respective CMake command below).
63
64## Building Kodi
65
66This section lists the necessary commands for building Kodi with CMake.
67CMake supports different generators that can be classified into two categories:
68single- and multiconfiguration generators.
69
70A single configuration generator (GNU/NMake Makefiles) generates project files
71for a single build type (e.g. Debug, Release) specified at configure time.
72Multi configuration generators (Visual Studio, Xcode) allow to specify the
73build type at compile time.
74
75All examples below are for out-of-source builds with Kodi checked out to
76`<KODI_SRC>`:
77
78```
79mkdir kodi-build && cd kodi-build
80```
81
82### Linux with GNU Makefiles
83
84```
85cmake <KODI_SRC>
86cmake --build . -- VERBOSE=1 -j$(nproc) # or: make VERBOSE=1 -j$(nproc)
87./kodi.bin
88```
89
90`CMAKE_BUILD_TYPE` defaults to `Release`.
91
92#### Debian package generation
93The buildsystem is capable of generating Debian packages using CPack. To generate them, `CPACK_GENERATOR` has to be set to *DEB*, i.e. executing CMake's configure step with `-DCPACK_GENERATOR=DEB`.
94You should use CMake/CPack 3.6.0 or higher. Lower versions can generate the packages but package names will be mangled.
95
96The following optional variables (which can be passed to buildsystem when executing cmake with the -D`<variable-name>=<value>` format) can be used to manipulate package type, name and version:
97
98- `DEBIAN_PACKAGE_TYPE` controls the name and version of generated packages. Accepted values are `stable`, `unstable` and `nightly` (default is `nightly`).
99- `DEBIAN_PACKAGE_EPOCH` controls package epoch (default is `2`)
100- `DEBIAN_PACKAGE_VERSION` controls package version (default is `0`)
101- `DEBIAN_PACKAGE_REVISION` controls package revision (no default is set)
102
103Packages metadata can be changed simply by editing files present in the `cpack/deb` folder
104A lot more variables are available (see cpack/CPackDebian.cmake file) but you shouldn't mess with them unless you know what you're doing.
105
106Generated packages can be found in <BUILD_DIR>/packages.
107
108### Raspberry Pi with GNU Makefiles
109
110```
111cmake -DCMAKE_TOOLCHAIN_FILE=<KODI_SRC>/tools/depends/target/Toolchain.cmake <KODI_SRC>
112cmake --build . -- VERBOSE=1 -j$(nproc) # or: make VERBOSE=1 -j$(nproc)
113```
114
115### Windows with Visual Studio project files
116These instructions are for Visual Studio 2015. If you want to build for Visal Studio 2017, you need to target `Visual Studio 15` instead of `Visual Studio 14`.
117
118#### Build for win32
119```
120cmake -G "Visual Studio 14" <KODI_SRC>
121cmake --build . --config "Debug" # or: Build solution with Visual Studio
122Debug\kodi.exe
123```
124
125Building on a x64 cpu can be improved, if you're on a cmake version > 3.8:
126```
127cmake -G "Visual Studio 14" -T host=x64 <KODI_SRC>
128cmake --build . --config "Debug" # or: Build solution with Visual Studio
129Debug\kodi.exe
130```
131This will choose the x64 toolset, as windows uses the x32 toolset by default.
132
133#### Build for x64
134```
135cmake -G "Visual Studio 14 Win64" <KODI_SRC>
136cmake --build . --config "Debug" # or: Build solution with Visual Studio
137Debug\kodi.exe
138```
139
140Building on a x64 cpu can be improved, if you're on a cmake version > 3.8:
141```
142cmake -G "Visual Studio 14 Win64" -T host=x64 <KODI_SRC>
143cmake --build . --config "Debug" # or: Build solution with Visual Studio
144Debug\kodi.exe
145```
146This will choose the x64 toolset, as windows uses the x32 toolset by default.
147
148You can always check ``cmake --help` to see which generators are available and how to call those.
149
150#### Windows installer generation
151
152The script [project/Win32BuildSetup](https://github.com/xbmc/xbmc/blob/master/tools/buildsteps/windows/win32/BuildSetup.bat) or [project/Win64BuildSetup](https://github.com/xbmc/xbmc/blob/master/tools/buildsteps/windows/x64/BuildSetup.bat)
153builds an installable package for Windows. Choose either 32bit or 64bit, depending on what your trying to build.
154
155### Windows with NMake Makefiles
156
157```
158cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release <KODI_SRC>
159cmake --build . # or: nmake
160kodi.exe
161```
162
163### macOS with GNU Makefiles
164
165```
166cmake -DCMAKE_TOOLCHAIN_FILE=<KODI_SRC>/tools/depends/target/Toolchain.cmake <KODI_SRC>
167cmake --build . -- VERBOSE=1 -j$(sysctl -n hw.ncpu) # or: make VERBOSE=1 -j$(sysctl -n hw.ncpu)
168./kodi.bin
169```
170
171### macOS with Xcode project files
172
173```
174cmake -DCMAKE_TOOLCHAIN_FILE=<KODI_SRC>/tools/depends/target/Toolchain.cmake -G "Xcode" <KODI_SRC>
175cmake --build . --config "Release" -- -verbose -jobs $(sysctl -n hw.ncpu) # or: Build solution with Xcode
176./Release/kodi.bin
177```
178
179#### macOS installer generation
180
181Afterwards an installable DMG for macOS can be built with the following command:
182
183```
184cmake --build . --config "Release" --target "dmg" # or: make dmg
185```
186
187#### iOS package generation
188
189Consequently an installable DEB for iOS can be built with the following command:
190
191```
192make deb
193```
194
195### Android with GNU Makefiles
196
197```
198cmake -DCMAKE_TOOLCHAIN_FILE=<KODI_SRC>/tools/depends/target/Toolchain.cmake <KODI_SRC>
199cmake --build . -- VERBOSE=1 -j$(nproc) # or: make VERBOSE=1 -j$(nproc)
200```
201
202#### Android package generation
203
204An installable APK for Android can be built with the following command:
205
206```
207make apk
208```
209
210## Options
211
212Kodi supports a number of build options that can enable or disable certain
213functionality.i These options must be set when running CMake with
214`-DENABLE_<OPTION>=<ON|OFF|AUTO`. The default is `AUTO` which enables
215the option if a certain dependency is found. For example CEC support is
216enabled if libCEC is available. `ON` forcefully enables the dependency
217and the CMake run will fail if the related dependency is not available.
218This is mostly useful for packagers. `OFF` will disable the feature.
219 16
220Example for forcefully enabling VAAPI and disabling VDPAU: 17Example for forcefully enabling VAAPI and disabling VDPAU:
221
222``` 18```
223cmake ... -DENABLE_VAAPI=ON -DENABLE_VDPAU=OFF ... 19cmake ... -DENABLE_VAAPI=ON -DENABLE_VDPAU=OFF ...
224``` 20```
225 21
226Example for building with external FFMPEG: 22Unfortunately, Kodi's CMake gazillion options are not fully documented yet. For more information and an updated list of options, please check the main **[CMakeLists.txt](../CMakeLists.txt)**.
227
228```
229cmake ... -DFFMPEG_PATH=/opt/ffmpeg -DENABLE_INTERNAL_FFMPEG=OFF ...
230```
231
232For more information and an updated list of option, please check the
233main [CMakeLists.txt](https://github.com/xbmc/xbmc/tree/master/CMakeLists.txt).
234 23
235## Tests 24## Tests
25Kodi uses Google Test as its testing framework. Each test file is scanned for tests and these are added to CTest, which is the native test driver for CMake.
236 26
237Kodi uses Google Test as its testing framework. Each test file is scanned for tests and these 27This scanning happens at configuration time. If tests depend on generated support files which should not be scanned, then those support files should be added to the `SUPPORT_SOURCES` variable as opposed to `SOURCES` before calling `core_add_test`. You might want to do this where the generated support files would not exist at configure time, or if they are so large that scanning them would take up an unreasonable amount of configure time.
238are added to CTest, which is the native test driver for CMake.
239
240This scanning happens at configuration time. If tests depend on generated support files which
241should not be scanned, then those support files should be added to the SUPPORT_SOURCES
242variable as opposed to SOURCES before calling core_add_test. You might want to do this where
243the generated support files would not exist at configure time, or if they are so large that
244scanning them would take up an unreasonable amount of configure time.
245 28
246## Extra targets 29## Extra targets
30When using makefile builds, a few extra targets are defined:
247 31
248When using the makefile builds a few extra targets are defined: 32* `make check` builds and executes the test suite.
249 33* `make check-valgrind` builds and executes the test suite with valgrind memcheck.
250- `make check` builds and executes the test suite. 34* `make doc` builds the Doxygen documentation.
251- `make check-valgrind` builds and executes the test suite with valgrind memcheck.
252- `make doc` builds the Doxygen documentation.
253 35
254Code coverage (with Gcov, LCOV and Gcovr) can be built on Linux: 36Code coverage (with Gcov, LCOV and Gcovr) can be built on Linux:
255 37
256- CMake has to be executed with `-DCMAKE_BUILD_TYPE=Coverage` 38* CMake has to be executed with `-DCMAKE_BUILD_TYPE=Coverage`.
257- `make coverage` generates an HTML code coverage report. 39* `make coverage` generates an HTML code coverage report.
258- `make coverage_xml` generates an XML code coverage report. 40* `make coverage_xml` generates an XML code coverage report.
259 41
260## Building binary addons 42## Building binary addons
43Kodi's CMake build system integrates with the add-on build system if the GNU Makefile generator is used. This offers an easy way to build add-ons for packagers or Kodi developers who don't work on add-ons.
261 44
262The CMake build system integrates with the addon build system if the GNU 45Build all add-ons:
263Makefile generator is used. This offers an easy way to build addons for
264packagers or Kodi developers who don't work on addons.
265
266``` 46```
267make binary-addons 47make binary-addons
268``` 48```
269 49
270Specific addons can be built with: 50Build specific add-ons:
271
272``` 51```
273make binary-addons ADDONS="visualization.spectrum pvr.demo" 52make binary-addons ADDONS="visualization.spectrum pvr.demo"
274``` 53```
275 54
276Addon developers can build single addons into the Kodi build directory 55Add-on developers can build single add-ons into the Kodi build directory so that the add-on can be tested with self-compiled specific versions of Kodi.
277so that the addon can be tested with self-compiled specific versions of Kodi.
278
279``` 56```
280mkdir pvr.demo-build && cd pvr.demo-build 57mkdir pvr.demo-build
58cd pvr.demo-build
281cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=<KODI_BUILD_DIR>/build -DKODI_BUILD_DIR=<KODI_BUILD_DIR> <pvr.demo-SRC> 59cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=<KODI_BUILD_DIR>/build -DKODI_BUILD_DIR=<KODI_BUILD_DIR> <pvr.demo-SRC>
282make 60make
283``` 61```
284 62
285It is recommended to specify the directories as absolute paths. If relative 63It is recommended to specify the directories as absolute paths. If relative paths are used, they are considered relative to the build directory in which `cmake` was executed (the current working directory).
286paths are used, they are considered relative to the build directory in which
287`cmake` was executed (aka the current working working directory).
288 64
289Both methods work only for already existing addons. See this 65Both methods work only for already existing add-ons. See this **[forum thread](https://forum.kodi.tv/showthread.php?tid=219166&pid=1934922)** and add-ons **[README](cmake/addons/README.md)**
290[forum thread](http://forum.kodi.tv/showthread.php?tid=219166&pid=1934922#pid1934922) 66for add-on development and detailed documentation about the add-on build system.
291and [addons/README.md](https://github.com/xbmc/xbmc/blob/master/cmake/addons/README.md)
292for addon development and detailed documentation about the addon build system.
293 67
294## Sanitizers 68## Sanitizers
69Clang and GCC support different kinds of sanitizers. To enable a sanitizer, call CMake with the option `-DECM_ENABLE_SANITIZERS=’san1;san2;...'`. For more information about enabling the
70sanitizers, read the module **[documentation](modules/extra/ECMEnableSanitizers.cmake)**.
295 71
296Clang and GCC support different kinds of Sanitizers. To enable a Sanitizer call CMake with the 72It is also recommended to read the sections about sanitizers in the [Clang documentation](http://clang.llvm.org/docs/).
297option `-DECM_ENABLE_SANITIZERS=’san1;san2;...'`. For more information about enabling the
298Sanitizers read the documentation in
299[modules/extra/ECMEnableSanitizers.cmake](https://github.com/xbmc/xbmc/tree/master/cmake/modules/extra/ECMEnableSanitizers.cmake).
300
301It is also recommended to read the sections about the Sanitizers in the [Clang
302documentation](http://clang.llvm.org/docs/).
303 73
304## Debugging the build 74## Debugging the build
75In order to see the exact compiler commands `make` and `nmake` can be executed with a `VERBOSE=1` parameter.
305 76
306This section covers some tips that can be useful for debugging a CMake 77On Windows, this is unfortunately not enough because `nmake` uses temporary files to workaround `nmake`'s command string length limitations.
307based build. 78In 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:
308
309### Verbosity (show compiler and linker parameters)
310
311In order to see the exact compiler commands `make` and `nmake` can be
312executed with a `VERBOSE=1` parameter.
313
314On Windows, this is unfortunately not enough because `nmake` uses
315temporary files to workaround `nmake`'s command string length limitations.
316In order to see verbose output the file
317[Modules/Platform/Windows.cmake](https://github.com/Kitware/CMake/blob/master/Modules/Platform/Windows.cmake#L40)
318in the local CMake installation has to be adapted by uncommenting these
319lines:
320
321``` 79```
322# uncomment these out to debug nmake and borland makefiles 80# uncomment these out to debug nmake and borland makefiles
323#set(CMAKE_START_TEMP_FILE "") 81#set(CMAKE_START_TEMP_FILE "")
324#set(CMAKE_END_TEMP_FILE "") 82#set(CMAKE_END_TEMP_FILE "")
325#set(CMAKE_VERBOSE_MAKEFILE 1) 83#set(CMAKE_VERBOSE_MAKEFILE 1)
326``` 84```
85