diff options
Diffstat (limited to 'project/cmake/README.md')
| -rw-r--r-- | project/cmake/README.md | 175 |
1 files changed, 154 insertions, 21 deletions
diff --git a/project/cmake/README.md b/project/cmake/README.md index 28af525..f3d727e 100644 --- a/project/cmake/README.md +++ b/project/cmake/README.md | |||
| @@ -3,14 +3,14 @@ | |||
| 3 | This files describes Kodi's CMake based buildsystem. CMake is a cross-platform | 3 | This files describes Kodi's CMake based buildsystem. CMake is a cross-platform |
| 4 | tool for generating makefiles as well as project files used by IDEs. | 4 | tool for generating makefiles as well as project files used by IDEs. |
| 5 | 5 | ||
| 6 | The current version of the buildsystem is capable of building the main Kodi | 6 | The current version of the buildsystem is capable of building and packaging |
| 7 | executable (but no packaging or dependency management yet) for the following | 7 | Kodi for the following platforms: |
| 8 | platforms: | ||
| 9 | 8 | ||
| 10 | - Linux (GNU Makefiles) | 9 | - Linux (GNU Makefiles, Ninja) |
| 11 | - Windows (NMake Makefiles, Visual Studio 14 (2015)) | 10 | - Windows (NMake Makefiles, Visual Studio 14 (2015), Ninja) |
| 12 | - OSX (GNU Makefiles, Xcode) | 11 | - macOS and iOS (GNU Makefiles, Xcode, Ninja) |
| 13 | - Android (GNU Makefiles) | 12 | - Android (GNU Makefiles) |
| 13 | - FreeBSD (GNU Makefiles) | ||
| 14 | 14 | ||
| 15 | Before building Kodi with CMake, please ensure that you have the platform | 15 | Before building Kodi with CMake, please ensure that you have the platform |
| 16 | specific dependencies installed. | 16 | specific dependencies installed. |
| @@ -44,12 +44,12 @@ are downloaded using `DownloadBuildDeps.bat` and `DownloadMingwBuildEnv.bat` | |||
| 44 | and that the mingw libs (ffmpeg, libdvd and others) are built using | 44 | and that the mingw libs (ffmpeg, libdvd and others) are built using |
| 45 | `make-mingwlibs.bat`. | 45 | `make-mingwlibs.bat`. |
| 46 | 46 | ||
| 47 | ### OSX | 47 | ### macOS |
| 48 | 48 | ||
| 49 | For OSX the required dependencies can be found in | 49 | For macOS the required dependencies can be found in |
| 50 | [docs/README.osx](https://github.com/xbmc/xbmc/tree/master/docs/README.osx). | 50 | [docs/README.osx](https://github.com/xbmc/xbmc/tree/master/docs/README.osx). |
| 51 | 51 | ||
| 52 | On OSX it is necessary to build the dependencies in `tools/depends` using | 52 | On macOS it is necessary to build the dependencies in `tools/depends` using |
| 53 | `./bootstrap && ./configure --host=<PLATFORM> && make`. The other steps such | 53 | `./bootstrap && ./configure --host=<PLATFORM> && make`. The other steps such |
| 54 | as `make -C tools/depends/target/xbmc` and `make xcode_depends` are not needed | 54 | as `make -C tools/depends/target/xbmc` and `make xcode_depends` are not needed |
| 55 | as these steps are covered already by the CMake project. | 55 | as these steps are covered already by the CMake project. |
| @@ -57,7 +57,7 @@ as these steps are covered already by the CMake project. | |||
| 57 | ### Android | 57 | ### Android |
| 58 | 58 | ||
| 59 | The dependencies needed to compile for Android can be found in | 59 | The dependencies needed to compile for Android can be found in |
| 60 | [docs/README.osx](https://github.com/xbmc/xbmc/tree/master/docs/README.android) | 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 | 61 | . All described steps have to be executed (except 5.2 which is replaced by the |
| 62 | respective CMake command below). | 62 | respective CMake command below). |
| 63 | 63 | ||
| @@ -89,6 +89,22 @@ cmake --build . -- VERBOSE=1 -j$(nproc) # or: make VERBOSE=1 -j$(nproc) | |||
| 89 | 89 | ||
| 90 | `CMAKE_BUILD_TYPE` defaults to `Release`. | 90 | `CMAKE_BUILD_TYPE` defaults to `Release`. |
| 91 | 91 | ||
| 92 | #### Debian package generation | ||
| 93 | The 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`. | ||
| 94 | You should use CMake/CPack 3.6.0 or higher. Lower versions can generate the packages but package names will be mangled. | ||
| 95 | |||
| 96 | The 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 | |||
| 103 | Packages metadata can be changed simply by editing files present in the `cpack/deb` folder | ||
| 104 | A 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 | |||
| 106 | Generated packages can be found in <BUILD_DIR>/packages. | ||
| 107 | |||
| 92 | ### Raspberry Pi with GNU Makefiles | 108 | ### Raspberry Pi with GNU Makefiles |
| 93 | 109 | ||
| 94 | ``` | 110 | ``` |
| @@ -96,23 +112,28 @@ cmake -DCMAKE_TOOLCHAIN_FILE=<KODI_SRC>/tools/depends/target/Toolchain.cmake <KO | |||
| 96 | cmake --build . -- VERBOSE=1 -j$(nproc) # or: make VERBOSE=1 -j$(nproc) | 112 | cmake --build . -- VERBOSE=1 -j$(nproc) # or: make VERBOSE=1 -j$(nproc) |
| 97 | ``` | 113 | ``` |
| 98 | 114 | ||
| 99 | ### Windows with NMake Makefiles | 115 | ### Windows with Visual Studio project files |
| 100 | 116 | ||
| 101 | ``` | 117 | ``` |
| 102 | cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release <KODI_SRC>/project/cmake/ | 118 | cmake -G "Visual Studio 14" <KODI_SRC>/project/cmake/ |
| 103 | cmake --build . # or: nmake | 119 | cmake --build . --config "Debug" # or: Build solution with Visual Studio |
| 104 | kodi.exe | 120 | Debug\kodi.exe |
| 105 | ``` | 121 | ``` |
| 106 | 122 | ||
| 107 | ### Windows with Visual Studio project files | 123 | #### Windows installer generation |
| 124 | |||
| 125 | The script [project/Win32BuildSetup](https://github.com/xbmc/xbmc/blob/master/project/Win32BuildSetup/BuildSetup.bat) | ||
| 126 | builds an installable package for Windows. | ||
| 127 | |||
| 128 | ### Windows with NMake Makefiles | ||
| 108 | 129 | ||
| 109 | ``` | 130 | ``` |
| 110 | cmake -G "Visual Studio 14" <KODI_SRC>/project/cmake/ | 131 | cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release <KODI_SRC>/project/cmake/ |
| 111 | cmake --build . --config "Debug" # or: Build solution with Visual Studio | 132 | cmake --build . # or: nmake |
| 112 | set KODI_HOME="%CD%" && Debug\kodi.exe | 133 | kodi.exe |
| 113 | ``` | 134 | ``` |
| 114 | 135 | ||
| 115 | ### OSX with GNU Makefiles | 136 | ### macOS with GNU Makefiles |
| 116 | 137 | ||
| 117 | ``` | 138 | ``` |
| 118 | cmake -DCMAKE_TOOLCHAIN_FILE=<KODI_SRC>/tools/depends/target/Toolchain.cmake <KODI_SRC>/project/cmake/ | 139 | cmake -DCMAKE_TOOLCHAIN_FILE=<KODI_SRC>/tools/depends/target/Toolchain.cmake <KODI_SRC>/project/cmake/ |
| @@ -120,12 +141,28 @@ cmake --build . -- VERBOSE=1 -j$(sysctl -n hw.ncpu) # or: make VERBOSE=1 -j$(sy | |||
| 120 | ./kodi.bin | 141 | ./kodi.bin |
| 121 | ``` | 142 | ``` |
| 122 | 143 | ||
| 123 | ### OSX with Xcode project files | 144 | ### macOS with Xcode project files |
| 124 | 145 | ||
| 125 | ``` | 146 | ``` |
| 126 | cmake -DCMAKE_TOOLCHAIN_FILE=<KODI_SRC>/tools/depends/target/Toolchain.cmake -G "Xcode" <KODI_SRC>/project/cmake/ | 147 | cmake -DCMAKE_TOOLCHAIN_FILE=<KODI_SRC>/tools/depends/target/Toolchain.cmake -G "Xcode" <KODI_SRC>/project/cmake/ |
| 127 | cmake --build . --config "Release" -- -verbose -jobs $(sysctl -n hw.ncpu) # or: Build solution with Xcode | 148 | cmake --build . --config "Release" -- -verbose -jobs $(sysctl -n hw.ncpu) # or: Build solution with Xcode |
| 128 | KODI_HOME=$(pwd) ./Release/kodi.bin | 149 | ./Release/kodi.bin |
| 150 | ``` | ||
| 151 | |||
| 152 | #### macOS installer generation | ||
| 153 | |||
| 154 | Afterwards an installable DMG for macOS can be built with the following command: | ||
| 155 | |||
| 156 | ``` | ||
| 157 | cmake --build . --config "Release" --target "dmg" # or: make dmg | ||
| 158 | ``` | ||
| 159 | |||
| 160 | #### iOS package generation | ||
| 161 | |||
| 162 | Consequently an installable DEB for iOS can be built with the following command: | ||
| 163 | |||
| 164 | ``` | ||
| 165 | make deb | ||
| 129 | ``` | 166 | ``` |
| 130 | 167 | ||
| 131 | ### Android with GNU Makefiles | 168 | ### Android with GNU Makefiles |
| @@ -135,11 +172,107 @@ cmake -DCMAKE_TOOLCHAIN_FILE=<KODI_SRC>/tools/depends/target/Toolchain.cmake <KO | |||
| 135 | cmake --build . -- VERBOSE=1 -j$(nproc) # or: make VERBOSE=1 -j$(nproc) | 172 | cmake --build . -- VERBOSE=1 -j$(nproc) # or: make VERBOSE=1 -j$(nproc) |
| 136 | ``` | 173 | ``` |
| 137 | 174 | ||
| 175 | #### Android package generation | ||
| 176 | |||
| 177 | An installable APK for Android can be built with the following command: | ||
| 178 | |||
| 179 | ``` | ||
| 180 | make apk | ||
| 181 | ``` | ||
| 182 | |||
| 183 | ## Options | ||
| 184 | |||
| 185 | Kodi supports a number of build options that can enable or disable certain | ||
| 186 | functionality.i These options must be set when running CMake with | ||
| 187 | `-DENABLE_<OPTION>=<ON|OFF|AUTO`. The default is `AUTO` which enables | ||
| 188 | the option if a certain dependency is found. For example CEC support is | ||
| 189 | enabled if libCEC is available. `ON` forcefully enables the dependency | ||
| 190 | and the CMake run will fail if the related dependency is not available. | ||
| 191 | This is mostly useful for packagers. `OFF` will disable the feature. | ||
| 192 | |||
| 193 | Example for forcefully enabling VAAPI and disabling VDPAU: | ||
| 194 | |||
| 195 | ``` | ||
| 196 | cmake ... -DENABLE_VAAPI=ON -DENABLE_VDPAU=OFF ... | ||
| 197 | ``` | ||
| 198 | |||
| 199 | Example for building with external FFMPEG: | ||
| 200 | |||
| 201 | ``` | ||
| 202 | cmake ... -DFFMPEG_PATH=/opt/ffmpeg -DENABLE_INTERNAL_FFMPEG=OFF ... | ||
| 203 | ``` | ||
| 204 | |||
| 205 | For more information and an updated list of option, please check the | ||
| 206 | main [project/cmake/CMakeLists.txt](https://github.com/xbmc/xbmc/tree/master/project/cmake/CMakeLists.txt). | ||
| 207 | |||
| 208 | ## Tests | ||
| 209 | |||
| 210 | Kodi uses Google Test as its testing framework. Each test file is scanned for tests and these | ||
| 211 | are added to CTest, which is the native test driver for CMake. | ||
| 212 | |||
| 213 | This scanning happens at configuration time. If tests depend on generated support files which | ||
| 214 | should not be scanned, then those support files should be added to the SUPPORT_SOURCES | ||
| 215 | variable as opposed to SOURCES before calling core_add_test. You might want to do this where | ||
| 216 | the generated support files would not exist at configure time, or if they are so large that | ||
| 217 | scanning them would take up an unreasonable amount of configure time. | ||
| 218 | |||
| 138 | ## Extra targets | 219 | ## Extra targets |
| 139 | 220 | ||
| 140 | When using the makefile builds a few extra targets are defined: | 221 | When using the makefile builds a few extra targets are defined: |
| 141 | 222 | ||
| 142 | - `make check` builds and executes the test suite. | 223 | - `make check` builds and executes the test suite. |
| 224 | - `make check-valgrind` builds and executes the test suite with valgrind memcheck. | ||
| 225 | - `make doc` builds the Doxygen documentation. | ||
| 226 | |||
| 227 | Code coverage (with Gcov, LCOV and Gcovr) can be built on Linux: | ||
| 228 | |||
| 229 | - CMake has to be executed with `-DCMAKE_BUILD_TYPE=Coverage` | ||
| 230 | - `make coverage` generates an HTML code coverage report. | ||
| 231 | - `make coverage_xml` generates an XML code coverage report. | ||
| 232 | |||
| 233 | ## Building binary addons | ||
| 234 | |||
| 235 | The CMake build system integrates with the addon build system if the GNU | ||
| 236 | Makefile generator is used. This offers an easy way to build addons for | ||
| 237 | packagers or Kodi developers who don't work on addons. | ||
| 238 | |||
| 239 | ``` | ||
| 240 | make binary-addons | ||
| 241 | ``` | ||
| 242 | |||
| 243 | Specific addons can be built with: | ||
| 244 | |||
| 245 | ``` | ||
| 246 | make binary-addons ADDONS="visualization.spectrum pvr.demo" | ||
| 247 | ``` | ||
| 248 | |||
| 249 | Addon developers can build single addons into the Kodi build directory | ||
| 250 | so that the addon can be tested with self-compiled specific versions of Kodi. | ||
| 251 | |||
| 252 | ``` | ||
| 253 | mkdir pvr.demo-build && cd pvr.demo-build | ||
| 254 | cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=<KODI_BUILD_DIR>/build -DKODI_BUILD_DIR=<KODI_BUILD_DIR> <pvr.demo-SRC> | ||
| 255 | make | ||
| 256 | ``` | ||
| 257 | |||
| 258 | It is recommended to specify the directories as absolute paths. If relative | ||
| 259 | paths are used, they are considered relative to the build directory in which | ||
| 260 | `cmake` was executed (aka the current working working directory). | ||
| 261 | |||
| 262 | Both methods work only for already existing addons. See this | ||
| 263 | [forum thread](http://forum.kodi.tv/showthread.php?tid=219166&pid=1934922#pid1934922) | ||
| 264 | and [addons/README.md](https://github.com/xbmc/xbmc/blob/master/project/cmake/addons/README.md) | ||
| 265 | for addon development and detailed documentation about the addon build system. | ||
| 266 | |||
| 267 | ## Sanitizers | ||
| 268 | |||
| 269 | Clang and GCC support different kinds of Sanitizers. To enable a Sanitizer call CMake with the | ||
| 270 | option `-DECM_ENABLE_SANITIZERS=’san1;san2;...'`. For more information about enabling the | ||
| 271 | Sanitizers read the documentation in | ||
| 272 | [modules/extra/ECMEnableSanitizers.cmake](https://github.com/xbmc/xbmc/tree/master/project/cmake/modules/extra/ECMEnableSanitizers.cmake). | ||
| 273 | |||
| 274 | It is also recommended to read the sections about the Sanitizers in the [Clang | ||
| 275 | documentation](http://clang.llvm.org/docs/). | ||
| 143 | 276 | ||
| 144 | ## Debugging the build | 277 | ## Debugging the build |
| 145 | 278 | ||
