• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

addons/H03-May-2022-238208

cpack/H24-Oct-2021-3,6712,909

installdata/H03-May-2022-

messages/flatbuffers/H24-Oct-2021-

modules/H03-May-2022-5,0054,260

platform/H03-May-2022-7050

scripts/H03-May-2022-5,8985,229

treedata/H03-May-2022-

KodiConfig.cmake.inH A D24-Oct-20211.1 KiB3430

README.mdH A D24-Oct-20216 KiB10676

README.md

1![Kodi Logo](../docs/resources/banner_slim.png)
2
3# Kodi's CMake Based Build System
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
6* Linux (several distros)
7* Windows
8* macOS, iOS and tvOS
9* Android
10* FreeBSD
11
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.
13
14## Build options
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.
16
17Example for forcefully enabling VAAPI and disabling VDPAU:
18```
19cmake ... -DENABLE_VAAPI=ON -DENABLE_VDPAU=OFF ...
20```
21
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)**.
23
24## Buildsystem variables
25The buildsystem uses the following variables (which can be passed into it when executing cmake with the -D`<variable-name>=<value>` format) to manipulate the build process (see READMEs in sub-directories for additional variables):
26- `CMAKE_BUILD_TYPE` specifies the type of the build. This can be either *Debug* or *Release* (default is *Release*)
27- `CMAKE_TOOLCHAIN_FILE` can be used to pass a toolchain file
28- `ARCH_DEFINES` specifies the platform-specific C/C++ preprocessor defines (defaults to empty)
29
30## Building
31To trigger the cmake-based buildsystem the following command must be executed with `<path>` set to this directory (absolute or relative) allowing for in-source and out-of-source builds
32
33`cmake <path> -G <generator>`
34
35CMake supports multiple generators. See [here] (https://cmake.org/cmake/help/v3.1/manual/cmake-generators.7.html) for a list.
36
37In case of additional options the call might look like this:
38
39cmake `<path>` [-G `<generator>`] \
40      -DCMAKE_BUILD_TYPE=Release \
41      -DARCH_DEFINES="-DTARGET_LINUX" \
42      -DCMAKE_INSTALL_PREFIX="`<path-to-install-directory`"
43
44## Tests
45Kodi 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.
46
47This 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.
48
49## Extra targets
50When using makefile builds, a few extra targets are defined:
51
52* `make check` builds and executes the test suite.
53* `make check-valgrind` builds and executes the test suite with valgrind memcheck.
54* `make doc` builds the Doxygen documentation.
55
56Code coverage (with Gcov, LCOV and Gcovr) can be built on Linux:
57
58* CMake has to be executed with `-DCMAKE_BUILD_TYPE=Coverage`.
59* `make coverage` generates an HTML code coverage report.
60* `make coverage_xml` generates an XML code coverage report.
61
62## Building binary addons
63Kodi'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.
64
65Build all add-ons:
66```
67make binary-addons
68```
69
70Build specific add-ons:
71```
72make binary-addons ADDONS="visualization.spectrum pvr.demo"
73```
74
75Add-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.
76```
77mkdir pvr.demo-build
78cd pvr.demo-build
79cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=<KODI_BUILD_DIR>/build -DKODI_BUILD_DIR=<KODI_BUILD_DIR> <pvr.demo-SRC>
80make
81```
82
83It 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).
84
85Both 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)**
86for add-on development and detailed documentation about the add-on build system.
87
88## Sanitizers
89Clang 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
90sanitizers, read the module **[documentation](modules/extra/ECMEnableSanitizers.cmake)**.
91
92It is also recommended to read the sections about sanitizers in the [Clang documentation](http://clang.llvm.org/docs/).
93
94## Debugging the build
95In order to see the exact compiler commands `make` and `nmake` can be executed with a `VERBOSE=1` parameter.
96
97On Windows, this is unfortunately not enough because `nmake` uses temporary files to workaround `nmake`'s command string length limitations.
98In 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:
99```
100# uncomment these out to debug nmake and borland makefiles
101#set(CMAKE_START_TEMP_FILE "")
102#set(CMAKE_END_TEMP_FILE "")
103#set(CMAKE_VERBOSE_MAKEFILE 1)
104```
105
106