diff options
| author | manuel <manuel@mausz.at> | 2016-11-24 21:27:41 +0100 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2016-11-24 21:27:41 +0100 |
| commit | 8cdf8dec703d882b46ca50a769fabb95ffc48e2c (patch) | |
| tree | f7fe8233508f79d3dc94f8f445ce6342e7dfbdbb /project/cmake/scripts/common/PrepareEnv.cmake | |
| parent | 5823b05feb29a59510c32a9c28ca18b50b9b6399 (diff) | |
| download | kodi-pvr-build-8cdf8dec703d882b46ca50a769fabb95ffc48e2c.tar.gz kodi-pvr-build-8cdf8dec703d882b46ca50a769fabb95ffc48e2c.tar.bz2 kodi-pvr-build-8cdf8dec703d882b46ca50a769fabb95ffc48e2c.zip | |
sync with upstream
Diffstat (limited to 'project/cmake/scripts/common/PrepareEnv.cmake')
| -rw-r--r-- | project/cmake/scripts/common/PrepareEnv.cmake | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/project/cmake/scripts/common/PrepareEnv.cmake b/project/cmake/scripts/common/PrepareEnv.cmake new file mode 100644 index 0000000..8e02382 --- /dev/null +++ b/project/cmake/scripts/common/PrepareEnv.cmake | |||
| @@ -0,0 +1,93 @@ | |||
| 1 | # parse version.txt and libKODI_guilib.h to get the version and API info | ||
| 2 | include(${CORE_SOURCE_DIR}/project/cmake/scripts/common/Macros.cmake) | ||
| 3 | core_find_versions() | ||
| 4 | |||
| 5 | # in case we need to download something, set KODI_MIRROR to the default if not alread set | ||
| 6 | if(NOT DEFINED KODI_MIRROR) | ||
| 7 | set(KODI_MIRROR "http://mirrors.kodi.tv") | ||
| 8 | endif() | ||
| 9 | |||
| 10 | ### copy all the addon binding header files to include/kodi | ||
| 11 | # make sure include/kodi exists and is empty | ||
| 12 | set(APP_LIB_DIR ${ADDON_DEPENDS_PATH}/lib/${APP_NAME_LC}) | ||
| 13 | if(NOT EXISTS "${APP_LIB_DIR}/") | ||
| 14 | file(MAKE_DIRECTORY ${APP_LIB_DIR}) | ||
| 15 | endif() | ||
| 16 | |||
| 17 | set(APP_DATA_DIR ${ADDON_DEPENDS_PATH}/share/${APP_NAME_LC}) | ||
| 18 | if(NOT EXISTS "${APP_DATA_DIR}/") | ||
| 19 | file(MAKE_DIRECTORY ${APP_DATA_DIR}) | ||
| 20 | endif() | ||
| 21 | |||
| 22 | set(APP_INCLUDE_DIR ${ADDON_DEPENDS_PATH}/include/${APP_NAME_LC}) | ||
| 23 | if(NOT EXISTS "${APP_INCLUDE_DIR}/") | ||
| 24 | file(MAKE_DIRECTORY ${APP_INCLUDE_DIR}) | ||
| 25 | endif() | ||
| 26 | |||
| 27 | # make sure C++11 is always set | ||
| 28 | if(NOT WIN32) | ||
| 29 | string(REGEX MATCH "-std=(gnu|c)\\+\\+11" cxx11flag "${CMAKE_CXX_FLAGS}") | ||
| 30 | if(NOT cxx11flag) | ||
| 31 | set(CXX11_SWITCH "-std=c++11") | ||
| 32 | endif() | ||
| 33 | endif() | ||
| 34 | |||
| 35 | # generate the proper KodiConfig.cmake file | ||
| 36 | configure_file(${CORE_SOURCE_DIR}/project/cmake/KodiConfig.cmake.in ${APP_LIB_DIR}/KodiConfig.cmake @ONLY) | ||
| 37 | |||
| 38 | # copy cmake helpers to lib/kodi | ||
| 39 | file(COPY ${CORE_SOURCE_DIR}/project/cmake/scripts/common/AddonHelpers.cmake | ||
| 40 | ${CORE_SOURCE_DIR}/project/cmake/scripts/common/AddOptions.cmake | ||
| 41 | DESTINATION ${APP_LIB_DIR}) | ||
| 42 | |||
| 43 | ### copy all the addon binding header files to include/kodi | ||
| 44 | # parse addon-bindings.mk to get the list of header files to copy | ||
| 45 | core_file_read_filtered(bindings ${CORE_SOURCE_DIR}/xbmc/addons/addon-bindings.mk) | ||
| 46 | foreach(binding ${bindings}) | ||
| 47 | string(REPLACE " =" ";" binding "${binding}") | ||
| 48 | string(REPLACE "+=" ";" binding "${binding}") | ||
| 49 | list(GET binding 1 header) | ||
| 50 | # copy the header file to include/kodi | ||
| 51 | configure_file(${CORE_SOURCE_DIR}/${header} ${APP_INCLUDE_DIR} COPYONLY) | ||
| 52 | endforeach() | ||
| 53 | |||
| 54 | ### on windows we need a "patch" binary to be able to patch 3rd party sources | ||
| 55 | if(WIN32) | ||
| 56 | find_program(PATCH_FOUND NAMES patch patch.exe) | ||
| 57 | if(PATCH_FOUND) | ||
| 58 | message(STATUS "patch utility found at ${PATCH_FOUND}") | ||
| 59 | else() | ||
| 60 | set(PATCH_ARCHIVE_NAME "patch-2.5.9-7-bin-3") | ||
| 61 | set(PATCH_ARCHIVE "${PATCH_ARCHIVE_NAME}.zip") | ||
| 62 | set(PATCH_URL "${KODI_MIRROR}/build-deps/win32/${PATCH_ARCHIVE}") | ||
| 63 | set(PATCH_DOWNLOAD ${BUILD_DIR}/download/${PATCH_ARCHIVE}) | ||
| 64 | |||
| 65 | # download the archive containing patch.exe | ||
| 66 | message(STATUS "Downloading patch utility from ${PATCH_URL}...") | ||
| 67 | file(DOWNLOAD "${PATCH_URL}" "${PATCH_DOWNLOAD}" STATUS PATCH_DL_STATUS LOG PATCH_LOG SHOW_PROGRESS) | ||
| 68 | list(GET PATCH_DL_STATUS 0 PATCH_RETCODE) | ||
| 69 | if(NOT ${PATCH_RETCODE} EQUAL 0) | ||
| 70 | message(FATAL_ERROR "ERROR downloading ${PATCH_URL} - status: ${PATCH_DL_STATUS} log: ${PATCH_LOG}") | ||
| 71 | endif() | ||
| 72 | |||
| 73 | # extract the archive containing patch.exe | ||
| 74 | execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzvf ${PATCH_DOWNLOAD} | ||
| 75 | WORKING_DIRECTORY ${BUILD_DIR}) | ||
| 76 | |||
| 77 | # make sure the extraction worked and that patch.exe is there | ||
| 78 | set(PATCH_PATH ${BUILD_DIR}/${PATCH_ARCHIVE_NAME}) | ||
| 79 | set(PATCH_BINARY_PATH ${PATCH_PATH}/bin/patch.exe) | ||
| 80 | if(NOT EXISTS ${PATCH_PATH} OR NOT EXISTS ${PATCH_BINARY_PATH}) | ||
| 81 | message(FATAL_ERROR "ERROR extracting patch utility from ${PATCH_DOWNLOAD_DIR}") | ||
| 82 | endif() | ||
| 83 | |||
| 84 | # copy patch.exe into the output directory | ||
| 85 | file(INSTALL ${PATCH_BINARY_PATH} DESTINATION ${ADDON_DEPENDS_PATH}/bin) | ||
| 86 | |||
| 87 | # make sure that cmake can find the copied patch.exe | ||
| 88 | find_program(PATCH_FOUND NAMES patch patch.exe) | ||
| 89 | if(NOT PATCH_FOUND) | ||
| 90 | message(FATAL_ERROR "ERROR installing patch utility from ${PATCH_BINARY_PATH} to ${ADDON_DEPENDS_PATH}/bin") | ||
| 91 | endif() | ||
| 92 | endif() | ||
| 93 | endif() | ||
