summaryrefslogtreecommitdiffstats
path: root/project/cmake/scripts/common/PrepareEnv.cmake
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2016-11-24 21:27:41 +0100
committermanuel <manuel@mausz.at>2016-11-24 21:27:41 +0100
commit8cdf8dec703d882b46ca50a769fabb95ffc48e2c (patch)
treef7fe8233508f79d3dc94f8f445ce6342e7dfbdbb /project/cmake/scripts/common/PrepareEnv.cmake
parent5823b05feb29a59510c32a9c28ca18b50b9b6399 (diff)
downloadkodi-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.cmake93
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
2include(${CORE_SOURCE_DIR}/project/cmake/scripts/common/Macros.cmake)
3core_find_versions()
4
5# in case we need to download something, set KODI_MIRROR to the default if not alread set
6if(NOT DEFINED KODI_MIRROR)
7 set(KODI_MIRROR "http://mirrors.kodi.tv")
8endif()
9
10### copy all the addon binding header files to include/kodi
11# make sure include/kodi exists and is empty
12set(APP_LIB_DIR ${ADDON_DEPENDS_PATH}/lib/${APP_NAME_LC})
13if(NOT EXISTS "${APP_LIB_DIR}/")
14 file(MAKE_DIRECTORY ${APP_LIB_DIR})
15endif()
16
17set(APP_DATA_DIR ${ADDON_DEPENDS_PATH}/share/${APP_NAME_LC})
18if(NOT EXISTS "${APP_DATA_DIR}/")
19 file(MAKE_DIRECTORY ${APP_DATA_DIR})
20endif()
21
22set(APP_INCLUDE_DIR ${ADDON_DEPENDS_PATH}/include/${APP_NAME_LC})
23if(NOT EXISTS "${APP_INCLUDE_DIR}/")
24 file(MAKE_DIRECTORY ${APP_INCLUDE_DIR})
25endif()
26
27# make sure C++11 is always set
28if(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()
33endif()
34
35# generate the proper KodiConfig.cmake file
36configure_file(${CORE_SOURCE_DIR}/project/cmake/KodiConfig.cmake.in ${APP_LIB_DIR}/KodiConfig.cmake @ONLY)
37
38# copy cmake helpers to lib/kodi
39file(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
45core_file_read_filtered(bindings ${CORE_SOURCE_DIR}/xbmc/addons/addon-bindings.mk)
46foreach(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)
52endforeach()
53
54### on windows we need a "patch" binary to be able to patch 3rd party sources
55if(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()
93endif()