diff options
Diffstat (limited to 'project/cmake/addons/bootstrap/CMakeLists.txt')
| -rw-r--r-- | project/cmake/addons/bootstrap/CMakeLists.txt | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/project/cmake/addons/bootstrap/CMakeLists.txt b/project/cmake/addons/bootstrap/CMakeLists.txt new file mode 100644 index 0000000..86950b8 --- /dev/null +++ b/project/cmake/addons/bootstrap/CMakeLists.txt | |||
| @@ -0,0 +1,95 @@ | |||
| 1 | project(kodi-addons-bootstrap) | ||
| 2 | |||
| 3 | cmake_minimum_required(VERSION 2.8) | ||
| 4 | |||
| 5 | list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) | ||
| 6 | |||
| 7 | # make sure CMAKE_INSTALL_PREFIX is properly set | ||
| 8 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR NOT CMAKE_INSTALL_PREFIX) | ||
| 9 | set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/../addons") | ||
| 10 | endif() | ||
| 11 | list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}) | ||
| 12 | |||
| 13 | # figure out where the build directory is located | ||
| 14 | if(NOT BUILD_DIR) | ||
| 15 | set(BUILD_DIR "${CMAKE_BINARY_DIR}/build") | ||
| 16 | else() | ||
| 17 | file(TO_CMAKE_PATH "${BUILD_DIR}" BUILD_DIR) | ||
| 18 | endif() | ||
| 19 | get_filename_component(BUILD_DIR "${BUILD_DIR}" ABSOLUTE) | ||
| 20 | |||
| 21 | # make sure that the repositories to build have been specified | ||
| 22 | if(NOT REPOSITORY_TO_BUILD) | ||
| 23 | set(REPOSITORY_TO_BUILD_DEFAULT ON) | ||
| 24 | set(REPOSITORY_TO_BUILD "all") | ||
| 25 | set(REPOSITORY_REVISION "") | ||
| 26 | message(STATUS "Bootstrapping all repositories") | ||
| 27 | else() | ||
| 28 | set(REPOSITORY_TO_BUILD_DEFAULT OFF) | ||
| 29 | message(STATUS "Bootstrapping following repository: ${REPOSITORY_TO_BUILD}") | ||
| 30 | endif() | ||
| 31 | |||
| 32 | # figure out which addons to bootstrap (defaults to all) | ||
| 33 | if(NOT ADDONS_TO_BUILD) | ||
| 34 | set(ADDONS_TO_BUILD "all") | ||
| 35 | message(STATUS "Bootstrapping all addons") | ||
| 36 | else() | ||
| 37 | message(STATUS "Bootstrapping following addons: ${ADDONS_TO_BUILD}") | ||
| 38 | endif() | ||
| 39 | |||
| 40 | include(ExternalProject) | ||
| 41 | |||
| 42 | function(bootstrap_repo repo_id repo_url repo_revision) | ||
| 43 | message(STATUS "Bootstrapping addons from ${repo_id} (${repo_url} ${repo_revision})...") | ||
| 44 | externalproject_add(${repo_id} | ||
| 45 | GIT_REPOSITORY ${repo_url} | ||
| 46 | GIT_TAG ${repo_revision} | ||
| 47 | PREFIX ${BUILD_DIR}/${repo_id} | ||
| 48 | CONFIGURE_COMMAND "" | ||
| 49 | BUILD_COMMAND "" | ||
| 50 | INSTALL_COMMAND ${CMAKE_COMMAND} | ||
| 51 | -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} | ||
| 52 | -DPROJECT_SOURCE_DIR=<SOURCE_DIR> | ||
| 53 | -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} | ||
| 54 | -DADDONS_TO_BUILD=${ADDONS_TO_BUILD} | ||
| 55 | -P ${PROJECT_SOURCE_DIR}/bootstrap.cmake | ||
| 56 | ) | ||
| 57 | endfunction() | ||
| 58 | |||
| 59 | # look for all addons repository definitions | ||
| 60 | set(REPOSITORY_TO_BUILD_FOUND OFF) | ||
| 61 | file(GLOB repos repositories/*.txt) | ||
| 62 | foreach(repo ${repos}) | ||
| 63 | file(STRINGS ${repo} repo_definition) | ||
| 64 | separate_arguments(repo_definition) | ||
| 65 | list(GET repo_definition 0 repo_id) | ||
| 66 | |||
| 67 | list(FIND REPOSITORY_TO_BUILD ${repo_id} idx) | ||
| 68 | if(idx GREATER -1 OR REPOSITORY_TO_BUILD STREQUAL "all") | ||
| 69 | set(REPOSITORY_TO_BUILD_FOUND ON) | ||
| 70 | |||
| 71 | # get the URL of the repository | ||
| 72 | list(GET repo_definition 1 repo_url) | ||
| 73 | |||
| 74 | # get the revision of the repository if not provided as an argument | ||
| 75 | if(NOT REPOSITORY_REVISION) | ||
| 76 | list(GET repo_definition 2 repo_revision) | ||
| 77 | else() | ||
| 78 | set(repo_revision "${REPOSITORY_REVISION}") | ||
| 79 | endif() | ||
| 80 | |||
| 81 | bootstrap_repo(${repo_id} ${repo_url} ${repo_revision}) | ||
| 82 | endif() | ||
| 83 | endforeach() | ||
| 84 | |||
| 85 | # if we have been asked to bootstrap a specific repository (not the default one) and | ||
| 86 | # it couldn't be found in the predefined repository definitions we assume that it's a | ||
| 87 | # URL to a specific repository | ||
| 88 | if(NOT REPOSITORY_TO_BUILD_DEFAULT AND NOT REPOSITORY_TO_BUILD_FOUND) | ||
| 89 | # default to the master branch if no revision has been provided | ||
| 90 | if(NOT REPOSITORY_REVISION) | ||
| 91 | set(REPOSITORY_REVISION "master") | ||
| 92 | endif() | ||
| 93 | |||
| 94 | bootstrap_repo(binary-addons-custom ${REPOSITORY_TO_BUILD} ${REPOSITORY_REVISION}) | ||
| 95 | endif() | ||
