summaryrefslogtreecommitdiffstats
path: root/cmake/addons
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2017-06-04 16:57:49 +0200
committermanuel <manuel@mausz.at>2017-06-04 16:57:49 +0200
commitf44ecaa4f27e7538ddcad66d40e543bffa2d2d86 (patch)
treed8de60fc7e17edeb6f0921726c038ee54b281445 /cmake/addons
parentae08c8b7221bc965ac40d70e53fc8fcddb050c46 (diff)
downloadkodi-pvr-build-f44ecaa4f27e7538ddcad66d40e543bffa2d2d86.tar.gz
kodi-pvr-build-f44ecaa4f27e7538ddcad66d40e543bffa2d2d86.tar.bz2
kodi-pvr-build-f44ecaa4f27e7538ddcad66d40e543bffa2d2d86.zip
sync with upstream
Diffstat (limited to 'cmake/addons')
-rw-r--r--cmake/addons/CMakeLists.txt439
-rw-r--r--cmake/addons/README.md65
-rw-r--r--cmake/addons/addons/pvr.dvbviewer/platforms.txt1
-rw-r--r--cmake/addons/addons/pvr.dvbviewer/pvr.dvbviewer.txt1
-rw-r--r--cmake/addons/bootstrap/Bootstrap.cmake39
-rw-r--r--cmake/addons/bootstrap/CMakeLists.txt93
-rw-r--r--cmake/addons/bootstrap/README.md48
-rw-r--r--cmake/addons/bootstrap/repositories/binary-addons.txt1
-rw-r--r--cmake/addons/depends/CMakeLists.txt41
-rw-r--r--cmake/addons/depends/README61
-rw-r--r--cmake/addons/depends/common/kodi-platform/deps.txt2
-rw-r--r--cmake/addons/depends/common/kodi-platform/kodi-platform.txt1
-rw-r--r--cmake/addons/depends/common/p8-platform/p8-platform.txt1
-rw-r--r--cmake/addons/depends/common/tinyxml/CMakeLists.txt22
-rw-r--r--cmake/addons/depends/common/tinyxml/tinyxml.txt1
-rw-r--r--cmake/addons/depends/windows/CMakeLists.txt52
-rw-r--r--cmake/addons/depends/windows/Install.cmake24
-rw-r--r--cmake/addons/depends/windows/README19
-rw-r--r--cmake/addons/depends/windows/cmake/mingw/CMakeLists.txt37
-rw-r--r--cmake/addons/depends/windows/cmake/mingw/MinGWConfig.cmake.in3
-rw-r--r--cmake/addons/depends/windows/cmake/mingw/Toolchain_mingw32.cmake.in17
-rw-r--r--cmake/addons/depends/windows/cmake/mingw/mingw.txt1
-rw-r--r--cmake/addons/depends/windows/cmake/mingw/mingw32-cmd.bat.in6
-rw-r--r--cmake/addons/depends/windows/cmake/mingw/noinstall.txt0
-rw-r--r--cmake/addons/depends/windows/cmake/msys/CMakeLists.txt5
-rw-r--r--cmake/addons/depends/windows/cmake/msys/msys.txt1
-rw-r--r--cmake/addons/depends/windows/cmake/msys/noinstall.txt0
-rw-r--r--cmake/addons/depends/windows/prebuilt/README21
28 files changed, 1002 insertions, 0 deletions
diff --git a/cmake/addons/CMakeLists.txt b/cmake/addons/CMakeLists.txt
new file mode 100644
index 0000000..a6ea149
--- /dev/null
+++ b/cmake/addons/CMakeLists.txt
@@ -0,0 +1,439 @@
1cmake_minimum_required(VERSION 3.1)
2project(kodi-addons)
3
4list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
5
6option(ADDON_TARBALL_CACHING "Cache downloaded addon source tarballs?" ON)
7if(ADDON_TARBALL_CACHING)
8 message(STATUS "Addon source tarball caching is enabled")
9else()
10 message(STATUS "Addon source tarball caching is disabled")
11endif()
12
13if(NOT CMAKE_BUILD_TYPE)
14 set(CMAKE_BUILD_TYPE Release)
15endif()
16
17if(NOT CORE_SYSTEM_NAME)
18 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
19 set(CORE_SYSTEM_NAME "osx")
20 else()
21 string(TOLOWER ${CMAKE_SYSTEM_NAME} CORE_SYSTEM_NAME)
22 endif()
23endif()
24
25include(ExternalProject)
26
27### setup all the necessary paths
28if(APP_ROOT)
29 set(CORE_SOURCE_DIR ${APP_ROOT})
30 unset(APP_ROOT)
31 message(WARNING "APP_ROOT is deprecated. Please use CORE_SOURCE_DIR instead.")
32endif()
33if(NOT CORE_SOURCE_DIR)
34 set(CORE_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../..)
35else()
36 file(TO_CMAKE_PATH "${CORE_SOURCE_DIR}" CORE_SOURCE_DIR)
37endif()
38get_filename_component(CORE_SOURCE_DIR "${CORE_SOURCE_DIR}" ABSOLUTE)
39
40if(NOT BUILD_DIR)
41 set(BUILD_DIR "${CMAKE_BINARY_DIR}/build")
42else()
43 file(TO_CMAKE_PATH "${BUILD_DIR}" BUILD_DIR)
44endif()
45get_filename_component(BUILD_DIR "${BUILD_DIR}" ABSOLUTE)
46
47if(NOT ADDON_DEPENDS_PATH)
48 set(ADDON_DEPENDS_PATH "${BUILD_DIR}/depends")
49else()
50 file(TO_CMAKE_PATH "${ADDON_DEPENDS_PATH}" ADDON_DEPENDS_PATH)
51endif()
52get_filename_component(ADDON_DEPENDS_PATH "${ADDON_DEPENDS_PATH}" ABSOLUTE)
53
54if(NOT PLATFORM_DIR)
55 set(PLATFORM_DIR ${CORE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME})
56 file(TO_CMAKE_PATH "${PLATFORM_DIR}" PLATFORM_DIR)
57endif()
58
59# make sure CMAKE_PREFIX_PATH is set
60if(NOT CMAKE_PREFIX_PATH)
61 set(CMAKE_PREFIX_PATH "${ADDON_DEPENDS_PATH}")
62else()
63 file(TO_CMAKE_PATH "${CMAKE_PREFIX_PATH}" CMAKE_PREFIX_PATH)
64 list(APPEND CMAKE_PREFIX_PATH "${ADDON_DEPENDS_PATH}")
65endif()
66
67# check for autoconf stuff to pass on
68if(AUTOCONF_FILES)
69 string(REPLACE " " ";" AUTOCONF_FILES ${AUTOCONF_FILES})
70 set(CROSS_AUTOCONF "yes")
71endif()
72
73if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR NOT CMAKE_INSTALL_PREFIX)
74 set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/output/addons")
75endif()
76list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX})
77
78set(BUILD_ARGS -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
79 -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
80 -DPACKAGE_CONFIG_PATH=${ADDON_DEPENDS_PATH}/lib/pkgconfig
81 -DADDON_DEPENDS_PATH=${ADDON_DEPENDS_PATH}
82 -DOVERRIDE_PATHS=${OVERRIDE_PATHS}
83 -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
84 -DCMAKE_USER_MAKE_RULES_OVERRIDE=${CMAKE_USER_MAKE_RULES_OVERRIDE}
85 -DCMAKE_USER_MAKE_RULES_OVERRIDE_CXX=${CMAKE_USER_MAKE_RULES_OVERRIDE_CXX}
86 -DCORE_SYSTEM_NAME=${CORE_SYSTEM_NAME}
87 -DBUILD_SHARED_LIBS=1
88 -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
89 -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS})
90
91if(MSVC)
92 # move cmake specific targets to a CMakePredefinedTargets folder in Visual Studio
93 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
94endif()
95
96option(PACKAGE_ZIP "Prepare built addons for packaging" OFF)
97if(PACKAGE_ZIP)
98 # needed for project installing
99 list(APPEND BUILD_ARGS -DPACKAGE_ZIP=ON)
100
101 # figure out where to store the packaged ZIP archives
102 if(NOT PACKAGE_DIR)
103 set(PACKAGE_DIR "${BUILD_DIR}/zips")
104 else()
105 file(TO_CMAKE_PATH "${PACKAGE_DIR}" PACKAGE_DIR)
106 endif()
107 list(APPEND BUILD_ARGS -DPACKAGE_DIR=${PACKAGE_DIR})
108
109 message(STATUS "ZIP packaging enabled (destination: ${PACKAGE_DIR})")
110endif()
111
112if(CMAKE_TOOLCHAIN_FILE)
113 list(APPEND BUILD_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE})
114 message(STATUS "Toolchain specified")
115 message(STATUS ${BUILD_ARGS})
116endif()
117
118if(NOT ADDONS_TO_BUILD)
119 set(ADDONS_TO_BUILD "all")
120else()
121 string(STRIP "${ADDONS_TO_BUILD}" ADDONS_TO_BUILD)
122 message(STATUS "Building following addons: ${ADDONS_TO_BUILD}")
123 string(REPLACE " " ";" ADDONS_TO_BUILD ${ADDONS_TO_BUILD})
124endif()
125
126if(NOT ADDONS_DEFINITION_DIR)
127 set(ADDONS_DEFINITION_DIR ${PROJECT_SOURCE_DIR}/addons)
128else()
129 file(TO_CMAKE_PATH "${ADDONS_DEFINITION_DIR}" ADDONS_DEFINITION_DIR)
130endif()
131get_filename_component(ADDONS_DEFINITION_DIR "${ADDONS_DEFINITION_DIR}" ABSOLUTE)
132
133if(ADDON_SRC_PREFIX)
134 if(NOT IS_ABSOLUTE ${ADDON_SRC_PREFIX})
135 get_filename_component(ADDON_SRC_PREFIX "${CMAKE_BINARY_DIR}/${ADDON_SRC_PREFIX}" ABSOLUTE)
136 endif()
137 message(STATUS "Overriding addon source directory prefix: ${ADDON_SRC_PREFIX}")
138endif()
139
140if(NOT APP_LIB_DIR)
141 set(APP_LIB_DIR "${ADDON_DEPENDS_PATH}/lib/kodi")
142else()
143 file(TO_CMAKE_PATH "${APP_LIB_DIR}" APP_LIB_DIR)
144endif()
145
146set(APP_PREFIX "${CMAKE_INSTALL_PREFIX}")
147
148# check for platform specific stuff
149if(EXISTS ${PLATFORM_DIR}/defines.txt)
150 file(STRINGS ${PLATFORM_DIR}/defines.txt platformdefines)
151
152 if(NOT ARCH_DEFINES AND platformdefines)
153 set(ARCH_DEFINES ${platformdefines})
154 endif()
155endif()
156
157# include check_target_platform() function
158include(${CORE_SOURCE_DIR}/cmake/scripts/common/CheckTargetPlatform.cmake)
159
160set(ADDON_INSTALL_DIR ${CMAKE_INSTALL_PREFIX})
161if(NOT WIN32)
162 # check install permissions
163 check_install_permissions(${CMAKE_INSTALL_PREFIX} can_write)
164 if(NOT ${can_write} AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
165 set(NEED_SUDO TRUE)
166 set(ADDON_INSTALL_DIR ${CMAKE_BINARY_DIR}/.install)
167 list(APPEND BUILD_ARGS -DOVERRIDE_PATHS=ON)
168 message(STATUS "NEED_SUDO: ${NEED_SUDO} (no write permission for ${CMAKE_INSTALL_PREFIX})")
169 endif()
170endif()
171
172### prepare the build environment for the binary addons
173# copy the PrepareEnv.cmake script to the depends path so that we can include it
174file(COPY ${CORE_SOURCE_DIR}/cmake/scripts/common/PrepareEnv.cmake DESTINATION ${APP_LIB_DIR})
175
176# add the location of PrepareEnv.cmake to CMAKE_MODULE_PATH so that it is found
177list(APPEND CMAKE_MODULE_PATH ${APP_LIB_DIR})
178
179# include PrepareEnv.cmake which contains the logic to install the addon header bindings etc
180include(PrepareEnv)
181
182### add the depends subdirectory for any general dependencies
183message(STATUS "\n-- ---- Preparing general dependencies ----")
184add_subdirectory(depends)
185
186# add a custom target "package-addons" which will package and install all addons
187add_custom_target(package-addons)
188
189### get and build all the binary addons
190# look for all the addons to be built
191file(GLOB_RECURSE addons ${ADDONS_DEFINITION_DIR}/*.txt)
192
193#if there are no addons assume that bootstrapping hasn't happened yet
194if(NOT addons)
195 message(STATUS "Bootstrapping all default repositories as no addons were found...")
196 set(BOOTSTRAP_BUILD_DIR "${BUILD_DIR}/bootstrap")
197
198 # make sure that the bootstraps build addon exists
199 if(NOT EXISTS ${BOOTSTRAP_BUILD_DIR})
200 file(MAKE_DIRECTORY ${BOOTSTRAP_BUILD_DIR})
201 endif()
202
203 string(REPLACE ";" " " ADDONS_TO_BUILD_STR "${ADDONS_TO_BUILD}")
204 # generate the bootstrap buildsystem
205 execute_process(COMMAND ${CMAKE_COMMAND} ${PROJECT_SOURCE_DIR}/bootstrap
206 -DCMAKE_INSTALL_PREFIX:PATH=${ADDONS_DEFINITION_DIR}
207 -DBUILD_DIR:PATH=${BOOTSTRAP_BUILD_DIR}
208 -DADDONS_TO_BUILD:STRING=${ADDONS_TO_BUILD_STR}
209 -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
210 WORKING_DIRECTORY ${BOOTSTRAP_BUILD_DIR})
211
212 # execute the generated bootstrap buildsystem
213 execute_process(COMMAND ${CMAKE_COMMAND} --build ${BOOTSTRAP_BUILD_DIR}
214 WORKING_DIRECTORY ${BOOTSTRAP_BUILD_DIR})
215
216 # now look for all the addons to be built again
217 file(GLOB_RECURSE addons ${ADDONS_DEFINITION_DIR}/*.txt)
218
219 if(NOT addons)
220 message(FATAL_ERROR "No addons available to be built")
221 endif()
222endif()
223
224# Track if at least one addon has been found. Everything else is likely an
225# error either in ADDONS_TO_BUILD or in the directory configuration.
226set(SUPPORTED_ADDON_FOUND FALSE)
227
228foreach(addon ${addons})
229 if(NOT (addon MATCHES platforms.txt))
230 file(STRINGS ${addon} def)
231 string(REPLACE " " ";" def ${def})
232 list(GET def 0 id)
233
234 set(ADDON_FOUND FALSE)
235 # try to find a perfect match
236 list(FIND ADDONS_TO_BUILD ${id} idx)
237 if(idx GREATER -1 OR "${ADDONS_TO_BUILD}" STREQUAL "all")
238 set(ADDON_FOUND TRUE)
239 # Maybe we have a regex
240 elseif(id MATCHES "${ADDONS_TO_BUILD}")
241 message(STATUS "Pattern ${ADDONS_TO_BUILD} matches ${id}, building addon")
242 set(ADDON_FOUND TRUE)
243 endif()
244
245 if(ADDON_FOUND)
246 message(STATUS "\n-- ---- Configuring addon ${addon} ----")
247 set(SUPPORTED_ADDON_FOUND TRUE)
248
249 get_filename_component(dir ${addon} DIRECTORY)
250
251 # check if the addon has a platforms.txt
252 set(platform_found FALSE)
253 check_target_platform(${dir} ${CORE_SYSTEM_NAME} platform_found)
254
255 if(${platform_found})
256 # make sure the output directory is clean
257 file(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/${id}/")
258
259 # get the URL and revision of the addon
260 list(LENGTH def deflength)
261 list(GET def 1 url)
262
263 set(archive_name ${id})
264 if(ADDON_SRC_PREFIX)
265 set(SOURCE_DIR ${ADDON_SRC_PREFIX}/${id})
266 set(archive_name "")
267 else()
268 set(SOURCE_DIR "")
269 endif()
270
271 # if there is a 3rd parameter in the file, we consider it a git revision
272 if(deflength GREATER 2 AND "${SOURCE_DIR}" STREQUAL "")
273 list(GET def 2 revision)
274
275 # we need access to a git executable
276 find_package(Git REQUIRED)
277
278 # resolve revision to git hash
279 execute_process(COMMAND ${GIT_EXECUTABLE} ls-remote ${url} ${revision} OUTPUT_VARIABLE revision_hash)
280 # git ls-remote only works on branches and tag names but not on revisions
281 if(NOT "${revision_hash}" STREQUAL "")
282 string(REPLACE "\t" ";" revision_list ${revision_hash})
283 list(GET revision_list 0 revision_hash)
284 message(STATUS "${id}: git branch/tag ${revision} resolved to hash: ${revision_hash}")
285 set(revision ${revision_hash})
286 endif()
287
288 # Note: downloading specific revisions via http in the format below is probably github specific
289 # if we ever use other repositories, this might need adapting
290 set(url ${url}/archive/${revision}.tar.gz)
291 set(archive_name ${archive_name}-${revision})
292 elseif("${SOURCE_DIR}" STREQUAL "")
293 # check if the URL starts with file://
294 string(REGEX MATCH "^file://.*$" local_url "${url}")
295
296 #if not we assume this to be a local directory
297 if(local_url)
298 # this is not an archive
299 set(archive_name "")
300
301 # remove the file:// protocol from the URL
302 string(REPLACE "file://" "" SOURCE_DIR "${url}")
303
304 # on win32 we may have to remove another leading /
305 if(WIN32)
306 # check if the path is a local path
307 string(REGEX MATCH "^/.*$" local_path "${SOURCE_DIR}")
308 if(local_path)
309 string(SUBSTRING "${SOURCE_DIR}" 1 -1 SOURCE_DIR)
310 endif()
311 endif()
312 endif()
313 endif()
314
315 # download the addon if necessary
316 if(NOT "${archive_name}" STREQUAL "")
317 # download and extract the addon
318 if(NOT ADDON_TARBALL_CACHING OR NOT EXISTS ${BUILD_DIR}/download/${archive_name}.tar.gz)
319 # cleanup any of the previously downloaded archives of this addon
320 file(GLOB archives "${BUILD_DIR}/download/${id}*.tar.gz")
321 if(archives)
322 message(STATUS "Removing old archives of ${id}: ${archives}")
323 file(REMOVE ${archives})
324 endif()
325
326 # download the addon
327 file(DOWNLOAD "${url}" "${BUILD_DIR}/download/${archive_name}.tar.gz" STATUS dlstatus LOG dllog SHOW_PROGRESS)
328 list(GET dlstatus 0 retcode)
329 if(NOT ${retcode} EQUAL 0)
330 file(REMOVE ${BUILD_DIR}/download/${archive_name}.tar.gz)
331 message(STATUS "ERROR downloading ${url} - status: ${dlstatus} log: ${dllog}")
332 # add a dummy target for addons to get it in addons failure file
333 list(APPEND ALL_ADDONS_BUILDING ${id})
334 add_custom_target(${id} COMMAND ${CMAKE_COMMAND} -E echo "IGNORED ${id} - download failed" COMMAND exit 1)
335 continue()
336 endif()
337 endif()
338
339 # remove any previously extracted version of the addon
340 file(REMOVE_RECURSE "${BUILD_DIR}/${id}")
341
342 # extract the addon from the archive
343 execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzvf ${BUILD_DIR}/download/${archive_name}.tar.gz
344 WORKING_DIRECTORY ${BUILD_DIR})
345 file(GLOB extract_dir "${BUILD_DIR}/${archive_name}*")
346 if(extract_dir STREQUAL "")
347 message(FATAL_ERROR "${id}: error extracting ${BUILD_DIR}/download/${archive_name}.tar.gz")
348 else()
349 file(RENAME "${extract_dir}" "${BUILD_DIR}/${id}")
350 endif()
351
352 set(SOURCE_DIR ${BUILD_DIR}/${id})
353 endif()
354
355 if(NOT "${SOURCE_DIR}" STREQUAL "" AND EXISTS ${SOURCE_DIR})
356 # create a list of addons we are building
357 list(APPEND ALL_ADDONS_BUILDING ${id})
358
359 # setup the buildsystem for the addon
360 externalproject_add(${id}
361 SOURCE_DIR ${SOURCE_DIR}
362 INSTALL_DIR ${ADDON_INSTALL_DIR}
363 CMAKE_ARGS ${BUILD_ARGS})
364
365 # add a custom step to the external project between the configure and the build step which will always
366 # be executed and therefore forces a re-build of all changed files
367 externalproject_add_step(${id} forcebuild
368 COMMAND ${CMAKE_COMMAND} -E echo "Force build of ${id}"
369 DEPENDEES configure
370 DEPENDERS build
371 ALWAYS 1)
372
373 # add "kodi-platform" as a dependency to every addon
374 add_dependencies(${id} kodi-platform)
375
376 set(${id}_DEPENDS_DIR ${SOURCE_DIR}/depends)
377
378 if(EXISTS ${${id}_DEPENDS_DIR})
379 include(${CORE_SOURCE_DIR}/cmake/scripts/common/HandleDepends.cmake)
380 add_addon_depends(${id} ${${id}_DEPENDS_DIR})
381 if(${id}_DEPS AND NOT "${${id}_DEPS}" STREQUAL "")
382 message(STATUS "${id} DEPENDENCIES: ${${id}_DEPS}")
383 add_dependencies(${id} ${${id}_DEPS})
384 endif()
385 endif()
386
387 if(CROSS_AUTOCONF AND AUTOCONF_FILES)
388 if(EXISTS ${SOURCE_DIR}/bootstrap/autoreconf.txt)
389 file(STRINGS ${SOURCE_DIR}/bootstrap/autoreconf.txt conf_dirs)
390 foreach(conf_dir ${conf_dirs})
391 foreach(afile ${AUTOCONF_FILES})
392 message(STATUS "copying ${afile} to ${SOURCE_DIR}/${conf_dir}")
393 file(COPY ${afile} DESTINATION ${SOURCE_DIR}/${conf_dir})
394 endforeach()
395 endforeach()
396 endif()
397 endif()
398
399 # create a forwarding target to the addon-package target
400 add_custom_target(package-${id}
401 COMMAND ${CMAKE_COMMAND} --build ${id}-prefix/src/${id}-build --target addon-package
402 DEPENDS ${id})
403 add_dependencies(package-addons package-${id})
404
405 else()
406 message(FATAL_ERROR "${id}: invalid or missing addon source directory at ${SOURCE_DIR}")
407 endif()
408 else()
409 # add a dummy target for addons that are unsupported on this platform
410 add_custom_target(${id} COMMAND ${CMAKE_COMMAND} -E echo "IGNORED ${id} - not supported on ${CORE_SYSTEM_NAME}\n")
411 endif()
412 endif()
413 endif()
414endforeach()
415message(STATUS "")
416
417if(NEED_SUDO)
418 add_custom_target(sudo-install
419 COMMAND ${CMAKE_COMMAND} -E echo "sudo rights needed to install to ${CMAKE_INSTALL_PREFIX}\n"
420 COMMAND sudo ${CMAKE_COMMAND} -E copy_directory ${ADDON_INSTALL_DIR}/ ${CMAKE_INSTALL_PREFIX}/
421 COMMAND sudo -k)
422
423 foreach(_id ${ALL_ADDONS_BUILDING})
424 add_dependencies(sudo-install ${_id})
425 endforeach()
426 message(WARNING "sudo rights needed to install to ${CMAKE_INSTALL_PREFIX}")
427 message(STATUS "\nplease type \"make sudo-install\"\n\n")
428endif()
429
430if(NOT SUPPORTED_ADDON_FOUND)
431 message(FATAL_ERROR "${ADDONS_TO_BUILD} did not match any of the supported addons. \
432 A list of supported addons can be viewed by building the 'supported_addons' target. \
433 Addon definitions are loaded from ADDONS_DEFINITION_DIR (${ADDONS_DEFINITION_DIR}).")
434endif()
435
436# add custom target "supported_addons" that returns all addons that are supported on this platform
437string(REPLACE ";" " " ALL_ADDONS_BUILDING "${ALL_ADDONS_BUILDING}")
438add_custom_target(supported_addons COMMAND ${CMAKE_COMMAND} -E echo "ALL_ADDONS_BUILDING: ${ALL_ADDONS_BUILDING}" VERBATIM)
439add_custom_target(need-sudo COMMAND ${CMAKE_COMMAND} -E echo ${NEED_SUDO} VERBATIM)
diff --git a/cmake/addons/README.md b/cmake/addons/README.md
new file mode 100644
index 0000000..6470ee1
--- /dev/null
+++ b/cmake/addons/README.md
@@ -0,0 +1,65 @@
1![Kodi logo](https://raw.githubusercontent.com/xbmc/xbmc-forum/master/xbmc/images/logo-sbs-black.png)
2# Kodi add-ons CMake based buildsystem
3This directory contains the cmake-based buildsystem for Kodi add-ons. It looks into the directory pointed to by the *ADDONS_DEFINITION_DIR* option (which defaults to the *addons* sub-directory) and parses all *.txt files recursively. Each add-on must have its own `<addon-id>.txt` file in a separate sub-directory that must follow one of the defined formats:
4
5 - `<addon-id> <git-url> <git-revision>`
6 - `<addon-id> <tarball-url>`
7 - `<addon-id> <file://path>`
8
9where
10- `<addon-id>` must be identical to the add-on's ID as defined in the add-on's addon.xml
11- `<git-url>` must be the URL of the git repository containing the add-on
12- `<git-revision>` must be a valid git tag/branch/commit in the add-on's git repository which will be used for the build
13- `<tarball-url>` must be the URL to a .tar.gz tarball containing the add-on
14- `<file://path>` must be a *file://* based path to the directory containing the add-on
15
16## Reserved filenames
17- **platforms.txt**
18
19List of platforms to build an add-on for (or *all*). Negating platforms is supported using a leading exclamation mark, e.g. *!windows*.
20
21Available platforms are: linux, windows, osx, ios, android, rbpi and freebsd.
22
23#### Attention
24If no add-on definitions could be found, the buildsystem assumes that the bootstrapping of the add-on definition repositories hasn't been performed yet and automatically executes the add-on bootstrapping buildsystem located in the *bootstrap* sub-directory with the default settings (i.e. *all* add-ons from all pre-defined add-on definition repositories are bootstrapped into the directory pointed to by the *ADDONS_DEFINITION_DIR* option).
25
26## Buildsystem variables
27The 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:
28- `ADDONS_TO_BUILD` has two variations, which are tested in order:
29 - a quoted, space delimited list of `<addon-id>s` that you want to build (default is *all*)
30 - a regular expression that every `<addon-id>` is matched against (e.g. `ADDONS_TO_BUILD="pvr.*"`) to build all pvr add-ons
31- `ADDONS_DEFINITION_DIR` points to the directory containing the definitions for the addons to be built
32- `ADDON_SRC_PREFIX` can be used to override the add-on repository location. It must point to the locally available parent directory of the add-on(s) to build. `<addon-id>` will be appended to this path automatically
33- `CMAKE_BUILD_TYPE` specifies the type of the build. This can be either *Debug* or *Release* (default is *Release*)
34- `CMAKE_INSTALL_PREFIX` points to the directory where the built add-ons and their additional files (addon.xml, resources, ...) will be installed to (defaults to `<ADDON_DEPENDS_PATH>`)
35- `CMAKE_TOOLCHAIN_FILE` can be used to pass a toolchain file into the add-on builds
36- `ADDON_DEPENDS_PATH` points to the directory containing the *include* and *lib* directories of the add-ons' dependencies.
37- `CORE_SOURCE_DIR` points to the root directory of the project (default is the absolute representation of ../../.. starting from this directory)
38- `BUILD_DIR` points to the directory where the add-ons and their dependencies will be downloaded and built
39- `PACKAGE_ZIP=ON` means that the add-ons will be 'packaged' into a common folder, rather than being placed in `<CMAKE_INSTALL_PREFIX>/lib/kodi/addons` and `<CMAKE_INSTALL_PREFIX>/share/kodi/addons`
40- `PACKAGE_DIR` points to the directory where the ZIP archived add-ons will be stored after they have been packaged (defaults to `<BUILD_DIR>/zips`)
41- `ARCH_DEFINES` specifies the platform-specific C/C++ preprocessor defines (defaults to empty)
42- `ADDON_TARBALL_CACHING` specifies whether downloaded add-on source tarballs should be cached or not (defaults to *ON*)
43
44## Deprecated buildsystem variables
45Buildsystem will print a warning if you use any of the below-listed variables. For now they still work but you should adapt your workflow to the new variables.
46- `APP_ROOT` - Use `CORE_SOURCE_DIR` instead
47
48## Building
49The buildsystem makes some assumptions about the environment which must be met by whoever uses it:
50- Any dependencies of the add-ons must already be built and their include and library files must be present in the path pointed to by `<CMAKE_PREFIX_PATH>` (in *include* and *lib* sub-directories)
51
52To 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
53
54`cmake <path> -G <generator>`
55
56CMake supports multiple generators. See [here] (https://cmake.org/cmake/help/v3.1/manual/cmake-generators.7.html) for a list.
57
58In case of additional options the call might look like this:
59
60cmake `<path>` [-G `<generator>`] \
61 -DCMAKE_BUILD_TYPE=Release \
62 -DCORE_SOURCE_DIR="`<path-to-app-root>`" \
63 -DARCH_DEFINES="-DTARGET_LINUX" \
64 -DADDON_DEPENDS_PATH=`<path-to-built-depends>` \
65 -DCMAKE_INSTALL_PREFIX="`<path-to-install-directory`"
diff --git a/cmake/addons/addons/pvr.dvbviewer/platforms.txt b/cmake/addons/addons/pvr.dvbviewer/platforms.txt
new file mode 100644
index 0000000..baa6044
--- /dev/null
+++ b/cmake/addons/addons/pvr.dvbviewer/platforms.txt
@@ -0,0 +1 @@
all \ No newline at end of file
diff --git a/cmake/addons/addons/pvr.dvbviewer/pvr.dvbviewer.txt b/cmake/addons/addons/pvr.dvbviewer/pvr.dvbviewer.txt
new file mode 100644
index 0000000..db25aa2
--- /dev/null
+++ b/cmake/addons/addons/pvr.dvbviewer/pvr.dvbviewer.txt
@@ -0,0 +1 @@
pvr.dvbviewer https://github.com/manuelm/pvr.dvbviewer master \ No newline at end of file
diff --git a/cmake/addons/bootstrap/Bootstrap.cmake b/cmake/addons/bootstrap/Bootstrap.cmake
new file mode 100644
index 0000000..5d20302
--- /dev/null
+++ b/cmake/addons/bootstrap/Bootstrap.cmake
@@ -0,0 +1,39 @@
1list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
2
3# make sure that the installation location has been specified
4if(NOT CMAKE_INSTALL_PREFIX)
5 message(FATAL_ERROR "CMAKE_INSTALL_PREFIX has not been specified")
6endif()
7
8# figure out which addons to bootstrap (defaults to all)
9if(NOT ADDONS_TO_BUILD)
10 set(ADDONS_TO_BUILD "all")
11else()
12 string(STRIP "${ADDONS_TO_BUILD}" ADDONS_TO_BUILD)
13 message(STATUS "Bootstrapping following addons: ${ADDONS_TO_BUILD}")
14 string(REPLACE " " ";" ADDONS_TO_BUILD ${ADDONS_TO_BUILD})
15endif()
16
17# find all addon definitions and go through them
18file(GLOB_RECURSE ADDON_DEFINITIONS ${PROJECT_SOURCE_DIR}/*.txt)
19foreach(ADDON_DEFINITION_FILE ${ADDON_DEFINITIONS})
20 # ignore platforms.txt
21 if(NOT (ADDON_DEFINITION_FILE MATCHES platforms.txt))
22 # read the addon definition file
23 file(STRINGS ${ADDON_DEFINITION_FILE} ADDON_DEFINITION)
24 string(REPLACE " " ";" ADDON_DEFINITION ${ADDON_DEFINITION})
25
26 # extract the addon definition's identifier
27 list(GET ADDON_DEFINITION 0 ADDON_ID)
28
29 # check if the addon definition should be built
30 if(ADDON_ID MATCHES "^${ADDONS_TO_BUILD}" OR ADDONS_TO_BUILD STREQUAL all)
31 # get the path to the addon definition directory
32 get_filename_component(ADDON_DEFINITION_DIR ${ADDON_DEFINITION_FILE} DIRECTORY)
33
34 # install the addon definition
35 message(STATUS "Bootstrapping ${ADDON_ID} addon...")
36 file(INSTALL ${ADDON_DEFINITION_DIR} DESTINATION ${CMAKE_INSTALL_PREFIX})
37 endif()
38 endif()
39endforeach()
diff --git a/cmake/addons/bootstrap/CMakeLists.txt b/cmake/addons/bootstrap/CMakeLists.txt
new file mode 100644
index 0000000..66b7e3d
--- /dev/null
+++ b/cmake/addons/bootstrap/CMakeLists.txt
@@ -0,0 +1,93 @@
1cmake_minimum_required(VERSION 3.1)
2project(kodi-addons-bootstrap)
3
4list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
5
6# make sure CMAKE_INSTALL_PREFIX is properly set
7if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR NOT CMAKE_INSTALL_PREFIX)
8 set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/../addons")
9endif()
10list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX})
11
12# figure out where the build directory is located
13if(NOT BUILD_DIR)
14 set(BUILD_DIR "${CMAKE_BINARY_DIR}/build")
15else()
16 file(TO_CMAKE_PATH "${BUILD_DIR}" BUILD_DIR)
17endif()
18get_filename_component(BUILD_DIR "${BUILD_DIR}" ABSOLUTE)
19
20# make sure that the repositories to build have been specified
21if(NOT REPOSITORY_TO_BUILD)
22 set(REPOSITORY_TO_BUILD_DEFAULT ON)
23 set(REPOSITORY_TO_BUILD "all")
24 set(REPOSITORY_REVISION "")
25 message(STATUS "Bootstrapping all repositories")
26else()
27 set(REPOSITORY_TO_BUILD_DEFAULT OFF)
28 message(STATUS "Bootstrapping following repository: ${REPOSITORY_TO_BUILD}")
29endif()
30
31# figure out which addons to bootstrap (defaults to all)
32if(NOT ADDONS_TO_BUILD)
33 set(ADDONS_TO_BUILD "all")
34 message(STATUS "Bootstrapping all addons")
35else()
36 message(STATUS "Bootstrapping following addons: ${ADDONS_TO_BUILD}")
37endif()
38
39include(ExternalProject)
40
41function(bootstrap_repo repo_id repo_url repo_revision)
42 message(STATUS "Bootstrapping addons from ${repo_id} (${repo_url} ${repo_revision})...")
43 externalproject_add(${repo_id}
44 GIT_REPOSITORY ${repo_url}
45 GIT_TAG ${repo_revision}
46 PREFIX ${BUILD_DIR}/${repo_id}
47 CONFIGURE_COMMAND ""
48 BUILD_COMMAND ""
49 INSTALL_COMMAND ${CMAKE_COMMAND}
50 -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
51 -DPROJECT_SOURCE_DIR=<SOURCE_DIR>
52 -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
53 -P ${PROJECT_SOURCE_DIR}/Bootstrap.cmake
54 )
55endfunction()
56
57# look for all addons repository definitions
58set(REPOSITORY_TO_BUILD_FOUND OFF)
59file(GLOB repos repositories/*.txt)
60foreach(repo ${repos})
61 file(STRINGS ${repo} repo_definition)
62 string(REPLACE " " ";" repo_definition ${repo_definition})
63 list(GET repo_definition 0 repo_id)
64
65 list(FIND REPOSITORY_TO_BUILD ${repo_id} idx)
66 if(idx GREATER -1 OR REPOSITORY_TO_BUILD STREQUAL "all")
67 set(REPOSITORY_TO_BUILD_FOUND ON)
68
69 # get the URL of the repository
70 list(GET repo_definition 1 repo_url)
71
72 # get the revision of the repository if not provided as an argument
73 if(NOT REPOSITORY_REVISION)
74 list(GET repo_definition 2 repo_revision)
75 else()
76 set(repo_revision "${REPOSITORY_REVISION}")
77 endif()
78
79 bootstrap_repo(${repo_id} ${repo_url} ${repo_revision})
80 endif()
81endforeach()
82
83# if we have been asked to bootstrap a specific repository (not the default one) and
84# it couldn't be found in the predefined repository definitions we assume that it's a
85# URL to a specific repository
86if(NOT REPOSITORY_TO_BUILD_DEFAULT AND NOT REPOSITORY_TO_BUILD_FOUND)
87 # default to the master branch if no revision has been provided
88 if(NOT REPOSITORY_REVISION)
89 set(REPOSITORY_REVISION "master")
90 endif()
91
92 bootstrap_repo(binary-addons-custom ${REPOSITORY_TO_BUILD} ${REPOSITORY_REVISION})
93endif()
diff --git a/cmake/addons/bootstrap/README.md b/cmake/addons/bootstrap/README.md
new file mode 100644
index 0000000..b886b5b
--- /dev/null
+++ b/cmake/addons/bootstrap/README.md
@@ -0,0 +1,48 @@
1# KODI ADDON DEFINITIONS BOOTSTRAPPING
2This directory contains the cmake-based buildsystem for addon definitions
3bootstrapping which downloads the addon definitions from one or more addon
4definitions repositories. These addon definitions are then used by the addon
5buildsystem to figure out which addons and which versions to build. It looks
6into the "repositories" sub-directory and parses all *.txt files recursively.
7Each addon definitions repository must have its own <repository>.txt file which
8must follow the following defined format:
9```
10<repository> <git-url> <git-revision>
11```
12where
13* `<repository>` is the identification of the repository.
14* `<git-url>` must be the URL of the git repository containing the addon
15 definitions
16* `<git-revision>` must be a valid git tag/branch/commit in the addon
17 definitions repository's git repository which will be used for the build
18
19The buildsystem uses the following variables (which can be passed into it when
20executing cmake with the `-D<variable-name>=<value>` option):
21* `CMAKE_INSTALL_PREFIX` points to the directory where the downloaded addon
22definitions will be installed to (defaults to `../addons`).
23* `BUILD_DIR` points to the directory where the addon definitions repositories
24will be downloaded to.
25* `REPOSITORY_TO_BUILD` specifies a single addon definitions repository to be
26downloaded and processed (defaults to `"all"`).
27* `REPOSITORY_REVISION` specifies the git revision in the addon definitions
28repository which will be used for the build. This option is only valid in
29combination with the `REPOSITORY_TO_BUILD` option (defaults to the git
30revision specified in the repository's definition file).
31* `ADDONS_TO_BUILD` is a quoted, space delimited list of `<addon-id>`s that
32should be bootstrapped (default is `"all"`).
33
34To trigger the cmake-based buildsystem the following command must be executed
35with <path> being the path to this directory (absolute or relative, allowing for
36in-source and out-of-source builds).
37```
38cmake <path> -G <generator>
39```
40
41cmake supports multiple generators, see
42http://www.cmake.org/cmake/help/v2.8.8/cmake.html#section_Generators for a list.
43
44In case of additional options the call might look like this
45```
46cmake <path> [-G <generator>] \
47 -DCMAKE_INSTALL_PREFIX="<path-to-install-directory>"
48``` \ No newline at end of file
diff --git a/cmake/addons/bootstrap/repositories/binary-addons.txt b/cmake/addons/bootstrap/repositories/binary-addons.txt
new file mode 100644
index 0000000..8674f06
--- /dev/null
+++ b/cmake/addons/bootstrap/repositories/binary-addons.txt
@@ -0,0 +1 @@
binary-addons https://github.com/xbmc/repo-binary-addons.git master \ No newline at end of file
diff --git a/cmake/addons/depends/CMakeLists.txt b/cmake/addons/depends/CMakeLists.txt
new file mode 100644
index 0000000..831e0ed
--- /dev/null
+++ b/cmake/addons/depends/CMakeLists.txt
@@ -0,0 +1,41 @@
1cmake_minimum_required(VERSION 3.1)
2project(kodi-addons-depends)
3
4list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
5
6if(NOT CMAKE_BUILD_TYPE)
7 set(CMAKE_BUILD_TYPE Release)
8endif()
9
10if(NOT CORE_SYSTEM_NAME)
11 string(TOLOWER ${CMAKE_SYSTEM_NAME} CORE_SYSTEM_NAME)
12endif()
13
14include(ExternalProject)
15
16if(NOT ADDON_DEPENDS_PATH)
17 set(ADDON_DEPENDS_PATH ${PROJECT_SOURCE_DIR}/../build/depends)
18else()
19 file(TO_CMAKE_PATH "${ADDON_DEPENDS_PATH}" ADDON_DEPENDS_PATH)
20endif()
21get_filename_component(ADDON_DEPENDS_PATH "${ADDON_DEPENDS_PATH}" ABSOLUTE)
22list(APPEND CMAKE_PREFIX_PATH ${ADDON_DEPENDS_PATH})
23
24if(NOT BUILD_DIR)
25 set(BUILD_DIR "${CMAKE_BINARY_DIR}/build")
26else()
27 file(TO_CMAKE_PATH "${BUILD_DIR}" BUILD_DIR)
28endif()
29get_filename_component(BUILD_DIR "${BUILD_DIR}" ABSOLUTE)
30
31## use add_addon_depends to handle the cmake based dependencies
32include(${CORE_SOURCE_DIR}/cmake/scripts/common/HandleDepends.cmake)
33add_addon_depends(depends "${PROJECT_SOURCE_DIR}")
34
35## if there's a platform-specific sub-directory containing a CMakeLists.txt, add it to the build as well
36if(EXISTS ${PROJECT_SOURCE_DIR}/${CORE_SYSTEM_NAME}/CMakeLists.txt)
37 message(STATUS "Processing ${CORE_SYSTEM_NAME}")
38 add_subdirectory(${CORE_SYSTEM_NAME})
39else()
40 message(STATUS "No platform specific file ${PROJECT_SOURCE_DIR}/${CORE_SYSTEM_NAME}/CMakeLists.txt found")
41endif()
diff --git a/cmake/addons/depends/README b/cmake/addons/depends/README
new file mode 100644
index 0000000..584a167
--- /dev/null
+++ b/cmake/addons/depends/README
@@ -0,0 +1,61 @@
1KODI ADDON DEPENDENCIES
2=======================
3This directory contains the cmake-based buildsystem for addon dependencies. It
4looks into the "common" and the "<platform>/cmake" sub-directories and parses
5all *.txt files recursively. Each dependency must have its own <dependency>.txt
6file (either in the main sub-directory or in a separate subdirectory of the main
7subdirectory) which must follow one of the defined formats:
8 * an empty file means that no extra downloads are necessary
9 * <dependency>
10 * <dependency> <url>
11 * <dependency> <git-url> <git-revision>
12where
13 * <dependency> must be identical to the filename
14 * <url> must be the URL to an archive that is downloaded and extracted.
15 * <git-url> must be the URL of the git repository containing the
16 dependency.
17 * <git-revision> must be a valid git tag/branch/commit in the dependency's git
18 repository which will be used for the build.
19
20Reserved filenames (for additional information on how to build a dependency)
21are:
22 * CMakeLists.txt: build instructions for the dependency
23 * install.txt: instructions on how to install the dependency's built files
24 * noinstall.txt: no installation step required (content is ignored)
25 * flags.txt: additional build flags
26 * deps.txt: whitespace separated list of dependencies of this dependency
27
28The buildsystem uses the following variables (which can be passed into it when
29executing cmake with the -D<variable-name>=<value> option) to e.g. access
30specific paths:
31 * CMAKE_BUILD_TYPE specifies the type of the build. This can be either "Debug"
32 or "Release" (default is "Release").
33 * CMAKE_TOOLCHAIN_FILE can be used to pass a toolchain file into the add-on
34 builds.
35 * CORE_SYSTEM_NAME is the name of the platform (e.g. "linux" or "android") in
36 lower-case (defaults to lowercase(CMAKE_SYSTEM_NAME)).
37 * CORE_SOURCE_DIR points to the root directory of the project (default is the
38 absolute representation of ../../.. starting from this directory).
39 * ADDON_DEPENDS_PATH points to the directory where the built dependencies
40 (their include and library file) will be installed to.
41 * ARCH_DEFINES specifies the platform-specific C/C++ preprocessor defines
42 (defaults to empty).
43 * DEPENDS_TO_BUILD is a quoted, space delimited list of <dependency>s that
44 you want to build (default is "all").
45
46To trigger the cmake-based buildsystem the following command must be executed
47with <path> being the path to this directory (absolute or relative, allowing for
48in-source and out-of-source builds).
49
50 cmake <path> -G <generator>
51
52cmake supports multiple generators, see
53http://www.cmake.org/cmake/help/v2.8.8/cmake.html#section_Generators for a list.
54
55In case of additional options the call might look like this
56
57 cmake <path> [-G <generator>] \
58 -DCMAKE_BUILD_TYPE=Release \
59 -DCORE_SOURCE_DIR="<path-to-project-root>" \
60 -DARCH_DEFINES="-DTARGET_LINUX" \
61 -DCMAKE_INSTALL_PREFIX="<path-to-install-directory"
diff --git a/cmake/addons/depends/common/kodi-platform/deps.txt b/cmake/addons/depends/common/kodi-platform/deps.txt
new file mode 100644
index 0000000..b953815
--- /dev/null
+++ b/cmake/addons/depends/common/kodi-platform/deps.txt
@@ -0,0 +1,2 @@
1tinyxml
2p8-platform
diff --git a/cmake/addons/depends/common/kodi-platform/kodi-platform.txt b/cmake/addons/depends/common/kodi-platform/kodi-platform.txt
new file mode 100644
index 0000000..1b5c8bf
--- /dev/null
+++ b/cmake/addons/depends/common/kodi-platform/kodi-platform.txt
@@ -0,0 +1 @@
kodi-platform https://github.com/xbmc/kodi-platform 36fb49371dbce49bf470a5bb1fc51b74b4a3612d
diff --git a/cmake/addons/depends/common/p8-platform/p8-platform.txt b/cmake/addons/depends/common/p8-platform/p8-platform.txt
new file mode 100644
index 0000000..ae7a370
--- /dev/null
+++ b/cmake/addons/depends/common/p8-platform/p8-platform.txt
@@ -0,0 +1 @@
p8-platform https://github.com/xbmc/platform.git 32190045c7eb6883c0662db2f91b4ceeab904fc2
diff --git a/cmake/addons/depends/common/tinyxml/CMakeLists.txt b/cmake/addons/depends/common/tinyxml/CMakeLists.txt
new file mode 100644
index 0000000..ec396ee
--- /dev/null
+++ b/cmake/addons/depends/common/tinyxml/CMakeLists.txt
@@ -0,0 +1,22 @@
1cmake_minimum_required(VERSION 3.1)
2project(tinyxml)
3
4set(SOURCES src/tinystr.cpp
5 src/tinyxml.cpp
6 src/tinyxmlerror.cpp
7 src/tinyxmlparser.cpp)
8
9if(WIN32)
10 add_definitions(-DWIN32 -D_LIB)
11endif()
12add_definitions(-DTIXML_USE_STL)
13
14add_library(tinyxml ${SOURCES})
15
16include_directories(${PROJECT_SOURCE_DIR}/include)
17
18set(HEADERS ${PROJECT_SOURCE_DIR}/include/tinystr.h
19 ${PROJECT_SOURCE_DIR}/include/tinyxml.h)
20
21install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
22install(TARGETS tinyxml DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
diff --git a/cmake/addons/depends/common/tinyxml/tinyxml.txt b/cmake/addons/depends/common/tinyxml/tinyxml.txt
new file mode 100644
index 0000000..f8e05e8
--- /dev/null
+++ b/cmake/addons/depends/common/tinyxml/tinyxml.txt
@@ -0,0 +1 @@
tinyxml http://mirrors.kodi.tv/build-deps/sources/tinyxml-2.6.2_2.tar.gz
diff --git a/cmake/addons/depends/windows/CMakeLists.txt b/cmake/addons/depends/windows/CMakeLists.txt
new file mode 100644
index 0000000..c8739c0
--- /dev/null
+++ b/cmake/addons/depends/windows/CMakeLists.txt
@@ -0,0 +1,52 @@
1cmake_minimum_required(VERSION 3.1)
2project(kodi-addons-depends-windows)
3
4list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
5
6if(NOT CMAKE_BUILD_TYPE)
7 set(CMAKE_BUILD_TYPE Release)
8endif()
9
10include(ExternalProject)
11
12if(NOT ADDON_DEPENDS_PATH)
13 message(FATAL_ERROR "ADDON_DEPENDS_PATH (${ADDON_DEPENDS_PATH}) is not a valid target directory.")
14else()
15 file(TO_CMAKE_PATH "${ADDON_DEPENDS_PATH}" ADDON_DEPENDS_PATH)
16endif()
17get_filename_component(ADDON_DEPENDS_PATH "${ADDON_DEPENDS_PATH}" ABSOLUTE)
18list(APPEND CMAKE_PREFIX_PATH ${ADDON_DEPENDS_PATH})
19
20if(NOT DEPENDS_TO_BUILD)
21 set(DEPENDS_TO_BUILD "all")
22endif()
23
24function(add_internal id url inputfile)
25 externalproject_add(${id}
26 URL ${url}
27 PREFIX build/${id}
28 CONFIGURE_COMMAND ""
29 BUILD_COMMAND ""
30 INSTALL_COMMAND ${CMAKE_COMMAND}
31 -DINPUTDIR=${PROJECT_BINARY_DIR}/build/${id}/src/${id}
32 -DINPUTFILE=${inputfile}
33 -DDESTDIR=${ADDON_DEPENDS_PATH}
34 -P ${PROJECT_SOURCE_DIR}/Install.cmake
35 )
36endfunction()
37
38file(GLOB_RECURSE download_input_files prebuilt/*.txt)
39foreach(file ${download_input_files})
40 if(NOT file MATCHES install.txt)
41 file(STRINGS ${file} def)
42 get_filename_component(dir ${file} DIRECTORY)
43 string(REPLACE " " ";" def ${def})
44 list(GET def 0 id)
45
46 list(FIND DEPENDS_TO_BUILD ${id} idx)
47 if(idx GREATER -1 OR DEPENDS_TO_BUILD STREQUAL "all")
48 list(GET def 1 url)
49 add_internal(${id} ${url} ${dir}/install.txt)
50 endif()
51 endif()
52endforeach()
diff --git a/cmake/addons/depends/windows/Install.cmake b/cmake/addons/depends/windows/Install.cmake
new file mode 100644
index 0000000..9a3adbb
--- /dev/null
+++ b/cmake/addons/depends/windows/Install.cmake
@@ -0,0 +1,24 @@
1if(EXISTS "${INPUTFILE}")
2 # if there's an input file we use it to determine which files to copy where
3 file(STRINGS ${INPUTFILE} FILES)
4 string(REPLACE "\n" ";" FILES "${FILES}")
5 foreach(file ${FILES})
6 string(REPLACE " " ";" file "${file}")
7 list(GET file 0 dir)
8 list(GET file 1 dest)
9 list(LENGTH file deflength)
10 if(deflength GREATER 2)
11 list(GET file 2 copy)
12 endif()
13 file(GLOB files ${INPUTDIR}/${dir})
14 foreach(instfile ${files})
15 file(COPY ${instfile} DESTINATION ${DESTDIR}/${dest})
16 if(copy)
17 file(COPY ${instfile} DESTINATION ${DESTDIR}/${copy})
18 endif()
19 endforeach()
20 endforeach()
21else()
22 # otherwise we assume that the content of the extracted archive is already well-formed and can just be copied
23 file(COPY ${INPUTDIR}/${dir} DESTINATION ${DESTDIR})
24endif() \ No newline at end of file
diff --git a/cmake/addons/depends/windows/README b/cmake/addons/depends/windows/README
new file mode 100644
index 0000000..67dc594
--- /dev/null
+++ b/cmake/addons/depends/windows/README
@@ -0,0 +1,19 @@
1KODI WIN32 ADDON DEPENDENCIES
2=============================
3This directory contains the cmake-based buildsystem for dependencies (currently
4only prebuilt) used by one or multiple addons. The buildsystem looks into the
5"prebuilt" sub-directory, downloads all the specified dependencies, extracts
6them and places them into the "depends" sub-directory.
7
8To trigger the cmake-based buildsystem the following command must be executed
9with <path> being the path to this directory (absolute or relative, allowing for
10in-source and out-of-source builds).
11
12 cmake <path> [-G <generator>]
13
14cmake supports multiple generators, see
15http://www.cmake.org/cmake/help/v2.8.8/cmake.html#section_Generators for a list.
16For win32 builds one of the "Visual Studio XX" or the "NMake Makefiles"
17generators is preferred. For the "NMake Makefiles" generator to work the above
18command must be called from an environment prepared for VC++ builds (see
19http://msdn.microsoft.com/en-us/library/f2ccy3wt.aspx).
diff --git a/cmake/addons/depends/windows/cmake/mingw/CMakeLists.txt b/cmake/addons/depends/windows/cmake/mingw/CMakeLists.txt
new file mode 100644
index 0000000..02d9724
--- /dev/null
+++ b/cmake/addons/depends/windows/cmake/mingw/CMakeLists.txt
@@ -0,0 +1,37 @@
1cmake_minimum_required(VERSION 3.1)
2project(mingw)
3
4function(generate_mingw32_wrapper cmd)
5 set(CMD ${cmd})
6 configure_file(${PROJECT_SOURCE_DIR}/mingw32-cmd.bat.in ${MINGW_PATH}/bin/${CMD}.bat @ONLY)
7endfunction()
8
9get_filename_component(CORE_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../../../../../.. REALPATH)
10
11set(MSYS_PATH "${CORE_SOURCE_DIR}/project/BuildDependencies/msys64")
12if(CMAKE_SIZEOF_VOID_P EQUAL 4)
13 set(MINGW_PATH "${MSYS_PATH}/mingw32")
14elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
15 set(MINGW_PATH "${MSYS_PATH}/mingw64")
16endif()
17
18# configure the MinGW toolchain file
19configure_file(${PROJECT_SOURCE_DIR}/Toolchain_mingw32.cmake.in ${CMAKE_INSTALL_PREFIX}/Toolchain_mingw32.cmake @ONLY)
20
21# configure MinGWConfig.cmake
22configure_file(${PROJECT_SOURCE_DIR}/MinGWConfig.cmake.in ${CMAKE_INSTALL_PREFIX}/MinGWConfig.cmake)
23
24# TODO: MinGW GCC 5.3.0-1 comes without cc.exe, Remove this once package is bumped to 5.3.0-p2
25# See https://github.com/Alexpux/MINGW-packages/pull/1034
26if(NOT EXISTS ${MINGW_PATH}/bin/cc.exe)
27 execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${MINGW_PATH}/bin/gcc.exe ${MINGW_PATH}/bin/cc.exe)
28endif()
29
30# configure the MinGW wrapper batch scripts
31generate_mingw32_wrapper("make")
32generate_mingw32_wrapper("gcc")
33generate_mingw32_wrapper("cc")
34generate_mingw32_wrapper("g++")
35generate_mingw32_wrapper("ar")
36generate_mingw32_wrapper("ld")
37generate_mingw32_wrapper("windres")
diff --git a/cmake/addons/depends/windows/cmake/mingw/MinGWConfig.cmake.in b/cmake/addons/depends/windows/cmake/mingw/MinGWConfig.cmake.in
new file mode 100644
index 0000000..2d6baa7
--- /dev/null
+++ b/cmake/addons/depends/windows/cmake/mingw/MinGWConfig.cmake.in
@@ -0,0 +1,3 @@
1set(MINGW_INCLUDE_DIRS @MINGW_PATH@/include)
2set(MINGW_MAKE @MINGW_PATH@/bin/make.bat -j$ENV{NUMBER_OF_PROCESSORS})
3set(MINGW_FOUND 1)
diff --git a/cmake/addons/depends/windows/cmake/mingw/Toolchain_mingw32.cmake.in b/cmake/addons/depends/windows/cmake/mingw/Toolchain_mingw32.cmake.in
new file mode 100644
index 0000000..01d281d
--- /dev/null
+++ b/cmake/addons/depends/windows/cmake/mingw/Toolchain_mingw32.cmake.in
@@ -0,0 +1,17 @@
1set(CMAKE_SYSTEM_VERSION 1)
2set(CMAKE_SYSTEM_NAME Windows)
3
4set(CMAKE_FIND_ROOT_PATH @CMAKE_FIND_ROOT_PATH@ @CMAKE_INSTALL_PREFIX@ @MSYS_PATH@ @MINGW_PATH@)
5
6# specify the cross compiler
7set(CMAKE_C_COMPILER @MINGW_PATH@/bin/gcc.bat)
8set(CMAKE_CXX_COMPILER @MINGW_PATH@/bin/g++.bat)
9set(CMAKE_AR @MINGW_PATH@/bin/ar.bat CACHE FILEPATH "Archiver")
10set(CMAKE_LINKER @MINGW_PATH@/bin/ld.bat CACHE FILEPATH "Linker")
11SET(CMAKE_RC_COMPILER @MINGW_PATH@/bin/windres.bat)
12
13# search for programs in the build host directories
14set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
15# for libraries and headers in the target directories
16set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
17set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/cmake/addons/depends/windows/cmake/mingw/mingw.txt b/cmake/addons/depends/windows/cmake/mingw/mingw.txt
new file mode 100644
index 0000000..90aa6ae
--- /dev/null
+++ b/cmake/addons/depends/windows/cmake/mingw/mingw.txt
@@ -0,0 +1 @@
mingw
diff --git a/cmake/addons/depends/windows/cmake/mingw/mingw32-cmd.bat.in b/cmake/addons/depends/windows/cmake/mingw/mingw32-cmd.bat.in
new file mode 100644
index 0000000..44a0ea2
--- /dev/null
+++ b/cmake/addons/depends/windows/cmake/mingw/mingw32-cmd.bat.in
@@ -0,0 +1,6 @@
1@ECHO OFF
2SETLOCAL
3
4SET PATH=@MINGW_PATH@/bin;@MSYS_PATH@/usr/bin;%PATH%
5@CMD@.exe %*
6
diff --git a/cmake/addons/depends/windows/cmake/mingw/noinstall.txt b/cmake/addons/depends/windows/cmake/mingw/noinstall.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/cmake/addons/depends/windows/cmake/mingw/noinstall.txt
diff --git a/cmake/addons/depends/windows/cmake/msys/CMakeLists.txt b/cmake/addons/depends/windows/cmake/msys/CMakeLists.txt
new file mode 100644
index 0000000..1c0536e
--- /dev/null
+++ b/cmake/addons/depends/windows/cmake/msys/CMakeLists.txt
@@ -0,0 +1,5 @@
1cmake_minimum_required(VERSION 3.1)
2project(msys LANGUAGES NONE)
3
4# This is an empty dummy dependency because a lot of game addons depend on it.
5# After they got fixed, this can be removed.
diff --git a/cmake/addons/depends/windows/cmake/msys/msys.txt b/cmake/addons/depends/windows/cmake/msys/msys.txt
new file mode 100644
index 0000000..00de9c2
--- /dev/null
+++ b/cmake/addons/depends/windows/cmake/msys/msys.txt
@@ -0,0 +1 @@
msys
diff --git a/cmake/addons/depends/windows/cmake/msys/noinstall.txt b/cmake/addons/depends/windows/cmake/msys/noinstall.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/cmake/addons/depends/windows/cmake/msys/noinstall.txt
diff --git a/cmake/addons/depends/windows/prebuilt/README b/cmake/addons/depends/windows/prebuilt/README
new file mode 100644
index 0000000..a0c70d6
--- /dev/null
+++ b/cmake/addons/depends/windows/prebuilt/README
@@ -0,0 +1,21 @@
1KODI WIN32 PREBUILT ADDON DEPENDENCIES
2======================================
3This directory contains a file or sub-directory for every prebuilt dependency
4used by one of the addons being built. There are two different modes supported.
5Both include a file named <library-id>.txt which must follow the defined format
6 <library-id> <download-url>
7
8If the archive, which the <download-url> points at, contains
9 * only the necessary files and in the proper directory structure (i.e. an
10 "include" and a "lib" directory) then the file must be put into this
11 directory and nothing else is needed.
12 * unnecessary files and/or does not follow the defined directory structure
13 (i.e. an "include" and a "lib" directory) then the file must be put into a
14 sub-directory named <library-id>. Furthermore an additional file called
15 "install.txt" must be placed in that sub-directory. install.txt contains a
16 line for every path/directory/file with a destination where it must be copied
17 to. It must follow the defined format
18 <source> <destination> [<copy-destination>]
19 where <source> must be an existing file, directory or a path containing
20 wildcards, <destination> and the optional <copy-destination> must be existing
21 directories.