summaryrefslogtreecommitdiffstats
path: root/project/cmake/scripts/common/prepare-env.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/prepare-env.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/prepare-env.cmake')
-rw-r--r--project/cmake/scripts/common/prepare-env.cmake136
1 files changed, 0 insertions, 136 deletions
diff --git a/project/cmake/scripts/common/prepare-env.cmake b/project/cmake/scripts/common/prepare-env.cmake
deleted file mode 100644
index 8e9bd1c..0000000
--- a/project/cmake/scripts/common/prepare-env.cmake
+++ /dev/null
@@ -1,136 +0,0 @@
1# parse version.txt to get the version info
2if(EXISTS "${APP_ROOT}/version.txt")
3 file(STRINGS "${APP_ROOT}/version.txt" versions)
4 foreach (version ${versions})
5 if(version MATCHES "^VERSION_.*")
6 string(REGEX MATCH "^[^ ]+" version_name ${version})
7 string(REPLACE "${version_name} " "" version_value ${version})
8 set(APP_${version_name} "${version_value}")
9 else()
10 string(REGEX MATCH "^[^ ]+" name ${version})
11 string(REPLACE "${name} " "" value ${version})
12 set(${name} "${value}")
13 endif()
14 endforeach()
15 string(TOLOWER ${APP_NAME} APP_NAME_LC)
16 string(TOUPPER ${APP_NAME} APP_NAME_UC)
17endif()
18
19# bail if we can't parse versions
20if(NOT DEFINED APP_VERSION_MAJOR OR NOT DEFINED APP_VERSION_MINOR)
21 message(FATAL_ERROR "Could not determine app version! make sure that ${APP_ROOT}/version.txt exists")
22endif()
23
24# in case we need to download something, set KODI_MIRROR to the default if not alread set
25if(NOT DEFINED KODI_MIRROR)
26 set(KODI_MIRROR "http://mirrors.kodi.tv")
27endif()
28
29### copy all the addon binding header files to include/kodi
30# make sure include/kodi exists and is empty
31set(APP_LIB_DIR ${DEPENDS_PATH}/lib/${APP_NAME_LC})
32if(NOT EXISTS "${APP_LIB_DIR}/")
33 file(MAKE_DIRECTORY ${APP_LIB_DIR})
34endif()
35
36set(APP_INCLUDE_DIR ${DEPENDS_PATH}/include/${APP_NAME_LC})
37if(NOT EXISTS "${APP_INCLUDE_DIR}/")
38 file(MAKE_DIRECTORY ${APP_INCLUDE_DIR})
39endif()
40
41# we still need XBMC_INCLUDE_DIR and XBMC_LIB_DIR for backwards compatibility to xbmc
42set(XBMC_LIB_DIR ${DEPENDS_PATH}/lib/xbmc)
43if(NOT EXISTS "${XBMC_LIB_DIR}/")
44 file(MAKE_DIRECTORY ${XBMC_LIB_DIR})
45endif()
46set(XBMC_INCLUDE_DIR ${DEPENDS_PATH}/include/xbmc)
47if(NOT EXISTS "${XBMC_INCLUDE_DIR}/")
48 file(MAKE_DIRECTORY ${XBMC_INCLUDE_DIR})
49endif()
50
51# make sure C++11 is always set
52if(NOT WIN32)
53 string(REGEX MATCH "-std=(gnu|c)\\+\\+11" cxx11flag "${CMAKE_CXX_FLAGS}")
54 if(NOT cxx11flag)
55 set(CXX11_SWITCH "-std=c++11")
56 endif()
57endif()
58
59# generate the proper kodi-config.cmake file
60configure_file(${APP_ROOT}/project/cmake/kodi-config.cmake.in ${APP_LIB_DIR}/kodi-config.cmake @ONLY)
61
62# copy cmake helpers to lib/kodi
63file(COPY ${APP_ROOT}/project/cmake/scripts/common/addon-helpers.cmake
64 ${APP_ROOT}/project/cmake/scripts/common/addoptions.cmake
65 DESTINATION ${APP_LIB_DIR})
66
67# generate xbmc-config.cmake for backwards compatibility to xbmc
68configure_file(${APP_ROOT}/project/cmake/xbmc-config.cmake.in ${XBMC_LIB_DIR}/xbmc-config.cmake @ONLY)
69
70### copy all the addon binding header files to include/kodi
71# parse addon-bindings.mk to get the list of header files to copy
72file(STRINGS ${APP_ROOT}/xbmc/addons/addon-bindings.mk bindings)
73string(REPLACE "\n" ";" bindings "${bindings}")
74foreach(binding ${bindings})
75 string(REPLACE " =" ";" binding "${binding}")
76 string(REPLACE "+=" ";" binding "${binding}")
77 list(GET binding 1 header)
78 # copy the header file to include/kodi
79 file(COPY ${APP_ROOT}/${header} DESTINATION ${APP_INCLUDE_DIR})
80
81 # auto-generate header files for backwards compatibility to xbmc with deprecation warning
82 # but only do it if the file doesn't already exist
83 get_filename_component(headerfile ${header} NAME)
84 if (NOT EXISTS "${XBMC_INCLUDE_DIR}/${headerfile}")
85 file(WRITE ${XBMC_INCLUDE_DIR}/${headerfile}
86"#pragma once
87#define DEPRECATION_WARNING \"Including xbmc/${headerfile} has been deprecated, please use kodi/${headerfile}\"
88#ifdef _MSC_VER
89 #pragma message(\"WARNING: \" DEPRECATION_WARNING)
90#else
91 #warning DEPRECATION_WARNING
92#endif
93#include \"kodi/${headerfile}\"")
94 endif()
95endforeach()
96
97### on windows we need a "patch" binary to be able to patch 3rd party sources
98if(WIN32)
99 find_program(PATCH_FOUND NAMES patch patch.exe)
100 if(PATCH_FOUND)
101 message(STATUS "patch utility found at ${PATCH_FOUND}")
102 else()
103 set(PATCH_ARCHIVE_NAME "patch-2.5.9-7-bin-3")
104 set(PATCH_ARCHIVE "${PATCH_ARCHIVE_NAME}.zip")
105 set(PATCH_URL "${KODI_MIRROR}/build-deps/win32/${PATCH_ARCHIVE}")
106 set(PATCH_DOWNLOAD ${BUILD_DIR}/download/${PATCH_ARCHIVE})
107
108 # download the archive containing patch.exe
109 message(STATUS "Downloading patch utility from ${PATCH_URL}...")
110 file(DOWNLOAD "${PATCH_URL}" "${PATCH_DOWNLOAD}" STATUS PATCH_DL_STATUS LOG PATCH_LOG SHOW_PROGRESS)
111 list(GET PATCH_DL_STATUS 0 PATCH_RETCODE)
112 if(NOT ${PATCH_RETCODE} EQUAL 0)
113 message(FATAL_ERROR "ERROR downloading ${PATCH_URL} - status: ${PATCH_DL_STATUS} log: ${PATCH_LOG}")
114 endif()
115
116 # extract the archive containing patch.exe
117 execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzvf ${PATCH_DOWNLOAD}
118 WORKING_DIRECTORY ${BUILD_DIR})
119
120 # make sure the extraction worked and that patch.exe is there
121 set(PATCH_PATH ${BUILD_DIR}/${PATCH_ARCHIVE_NAME})
122 set(PATCH_BINARY_PATH ${PATCH_PATH}/bin/patch.exe)
123 if(NOT EXISTS ${PATCH_PATH} OR NOT EXISTS ${PATCH_BINARY_PATH})
124 message(FATAL_ERROR "ERROR extracting patch utility from ${PATCH_DOWNLOAD_DIR}")
125 endif()
126
127 # copy patch.exe into the output directory
128 file(INSTALL ${PATCH_BINARY_PATH} DESTINATION ${DEPENDS_PATH}/bin)
129
130 # make sure that cmake can find the copied patch.exe
131 find_program(PATCH_FOUND NAMES patch patch.exe)
132 if(NOT PATCH_FOUND)
133 message(FATAL_ERROR "ERROR installing patch utility from ${PATCH_BINARY_PATH} to ${DEPENDS_PATH}/bin")
134 endif()
135 endif()
136endif()