2016-01-10, 14:59
Hey everyone,
in the past weeks I've helped out a bit with the CMake based build system that is being developed in FernetMenta's repository.
Since there is currently no tool in place to track the progress and open tasks I'm starting this thread here.
Introduction
Kodi is cross-platform software, but uses native build systems for all its supported platform. This leads to an enormous amount of work to keep those build systems in sync.
Because of this notspiff, wsnipex, FernetMenta, Montellese, et al. are working on a generic CMake based build system that can be used cross-platform.
Instead of manually maintaining Autotools, XCode and Visual Studio project files, CMake is able to generate those project files and build configurations, source files, compiler & linker flags, libraries and other build options are then managed in one generic place. In addition CMake can also unify and simplify the dependency management.
Even though a huge amount of work has already be done by the guys, there is still a lot of work to do (especially support for the missing platforms). Yep, Kodi's build process is quite complicated.
Current Status
This lists the current platform status (CMake generators in parentheses).
- Linux (Makefile): done
- Raspberry Pi (Makefile): done
- Windows (NMake, Visual Studio 14): done
- OSX (Makefile, Xcode): done
- IOS (Makefile, Xcode): done
- Android (Makefile): done
Currently CMake 3.1 is required, but it's likely that we have to bump to an even more recent version. Luckily it's typically easy to install newer CMake versions on most platforms.
Jenkins is now able to build Kodi for all platforms and is currently configured to do a nightly build with CMake.
Instructions
I've put together a readme file in the repo for the build instructions: https://github.com/xbmc/xbmc/tree/master.../README.md
TODOs
Here's the list of open points and known issues. Not really sorted yet, but it's a start.
Generic
- Some functions and macros have manually implemented parameter handling. Use CMakeParseArguments instead.
- Check if all build types work (CMAKE_BUILD_TYPE) and print warnings / error messages if a non supported build type is selected.
- Modernize the FindXXX.cmake modules and start to use imported targets (Target::Target).
- Replace the hand crafted optional/recommended feature list with FeatureSummary
- Create targets for the projects built with externalproject_add. This should allow us to remove the add_dependencies calls. example
- Change in treefiles doesn't trigger a cmake rerun when starting a build.
- Options and optional dependencies not applicable for a certain platform should not be listed.
- copy_if_different is very slow (especially on non SSDs) because it byte compares the files. For our purpose it would be enough to check the timestamps. This thread explains a solution using custom commands. Unfortunately file based dependency support has some issues so that it's not that easy to implement with just one function (as our copy_file_to_buildtree function). (PR9561)
- Add headers and other files to the libraries (this will improve IDE support. Some IDEs only show headers with the same name as source files.
Windows
- Build Texturepacker. (now that missing giflib static library is awailable in the dependencies)
- Use ExternalProject_Add to compile the mingw dependencies (needs: https://github.com/fetzerch/xbmc/commit/...t-15277878)
- Additional libraries, nodefaultlibs and delayedloadeddlls, are currently hardcoded in macros/windows.cmake and applied to all targets. The cleanest way would be to have a Find Module for them and they have to be specified only for the main Kodi executable.
- Check (and fix) options. CMake offers now the possibility to disable certain features on Windows like it was possible with the Autotools project on Linux. Not sure if this works properly or if some macros are still set incorrectly.
- Replace #pragma comment(lib) by the properly found libraries.
- Make sure that compiler and linker options are the same as in the Visual Studio project and fix remaining warnings.
- The compiled exe does not start from the folder where it's built (Debug or Release). (FIXED: KODI_HOME has to be set to the build directory)
Original PR: https://github.com/xbmc/xbmc/pull/9083
CMake Documentation
CMake has progressed a lot in the past years but many tutorials and documents that can be found in the internet are highly outdated. Hence here's a list of useful documentation material:
- CMake: The CMake Buildsystem
- CMake: How to write Find Modules
- Stephen Kelly - The What, Why and How of Modern CMake
- CMake Introduction and best practices
Cheers,
Christian
in the past weeks I've helped out a bit with the CMake based build system that is being developed in FernetMenta's repository.
Since there is currently no tool in place to track the progress and open tasks I'm starting this thread here.
Introduction
Kodi is cross-platform software, but uses native build systems for all its supported platform. This leads to an enormous amount of work to keep those build systems in sync.
Because of this notspiff, wsnipex, FernetMenta, Montellese, et al. are working on a generic CMake based build system that can be used cross-platform.
Instead of manually maintaining Autotools, XCode and Visual Studio project files, CMake is able to generate those project files and build configurations, source files, compiler & linker flags, libraries and other build options are then managed in one generic place. In addition CMake can also unify and simplify the dependency management.
Even though a huge amount of work has already be done by the guys, there is still a lot of work to do (especially support for the missing platforms). Yep, Kodi's build process is quite complicated.
Current Status
This lists the current platform status (CMake generators in parentheses).
- Linux (Makefile): done
- Raspberry Pi (Makefile): done
- Windows (NMake, Visual Studio 14): done
- OSX (Makefile, Xcode): done
- IOS (Makefile, Xcode): done
- Android (Makefile): done
Currently CMake 3.1 is required, but it's likely that we have to bump to an even more recent version. Luckily it's typically easy to install newer CMake versions on most platforms.
Jenkins is now able to build Kodi for all platforms and is currently configured to do a nightly build with CMake.
Instructions
I've put together a readme file in the repo for the build instructions: https://github.com/xbmc/xbmc/tree/master.../README.md
TODOs
Here's the list of open points and known issues. Not really sorted yet, but it's a start.
Generic
- Some functions and macros have manually implemented parameter handling. Use CMakeParseArguments instead.
- Check if all build types work (CMAKE_BUILD_TYPE) and print warnings / error messages if a non supported build type is selected.
- Modernize the FindXXX.cmake modules and start to use imported targets (Target::Target).
- Replace the hand crafted optional/recommended feature list with FeatureSummary
- Create targets for the projects built with externalproject_add. This should allow us to remove the add_dependencies calls. example
- Change in treefiles doesn't trigger a cmake rerun when starting a build.
- Options and optional dependencies not applicable for a certain platform should not be listed.
- copy_if_different is very slow (especially on non SSDs) because it byte compares the files. For our purpose it would be enough to check the timestamps. This thread explains a solution using custom commands. Unfortunately file based dependency support has some issues so that it's not that easy to implement with just one function (as our copy_file_to_buildtree function). (PR9561)
- Add headers and other files to the libraries (this will improve IDE support. Some IDEs only show headers with the same name as source files.
Windows
- Build Texturepacker. (now that missing giflib static library is awailable in the dependencies)
- Use ExternalProject_Add to compile the mingw dependencies (needs: https://github.com/fetzerch/xbmc/commit/...t-15277878)
- Additional libraries, nodefaultlibs and delayedloadeddlls, are currently hardcoded in macros/windows.cmake and applied to all targets. The cleanest way would be to have a Find Module for them and they have to be specified only for the main Kodi executable.
- Check (and fix) options. CMake offers now the possibility to disable certain features on Windows like it was possible with the Autotools project on Linux. Not sure if this works properly or if some macros are still set incorrectly.
- Replace #pragma comment(lib) by the properly found libraries.
- Make sure that compiler and linker options are the same as in the Visual Studio project and fix remaining warnings.
- The compiled exe does not start from the folder where it's built (Debug or Release). (FIXED: KODI_HOME has to be set to the build directory)
Original PR: https://github.com/xbmc/xbmc/pull/9083
CMake Documentation
CMake has progressed a lot in the past years but many tutorials and documents that can be found in the internet are highly outdated. Hence here's a list of useful documentation material:
- CMake: The CMake Buildsystem
- CMake: How to write Find Modules
- Stephen Kelly - The What, Why and How of Modern CMake
- CMake Introduction and best practices
Cheers,
Christian