summaryrefslogtreecommitdiffstats
path: root/cmake/addons/bootstrap/CMakeLists.txt
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/bootstrap/CMakeLists.txt
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/bootstrap/CMakeLists.txt')
-rw-r--r--cmake/addons/bootstrap/CMakeLists.txt93
1 files changed, 93 insertions, 0 deletions
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()