summaryrefslogtreecommitdiffstats
path: root/project/cmake/scripts/common/prepare-env.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'project/cmake/scripts/common/prepare-env.cmake')
-rw-r--r--project/cmake/scripts/common/prepare-env.cmake88
1 files changed, 88 insertions, 0 deletions
diff --git a/project/cmake/scripts/common/prepare-env.cmake b/project/cmake/scripts/common/prepare-env.cmake
new file mode 100644
index 0000000..7df421c
--- /dev/null
+++ b/project/cmake/scripts/common/prepare-env.cmake
@@ -0,0 +1,88 @@
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()
15endif()
16
17# bail if we can't parse versions
18if(NOT DEFINED APP_VERSION_MAJOR OR NOT DEFINED APP_VERSION_MINOR)
19 message(FATAL_ERROR "Could not determine app version! make sure that ${APP_ROOT}/version.txt exists")
20endif()
21
22### copy all the addon binding header files to include/kodi
23# make sure include/kodi exists and is empty
24set(KODI_LIB_DIR ${DEPENDS_PATH}/lib/kodi)
25if(NOT EXISTS "${KODI_LIB_DIR}/")
26 file(MAKE_DIRECTORY ${KODI_LIB_DIR})
27endif()
28
29set(KODI_INCLUDE_DIR ${DEPENDS_PATH}/include/kodi)
30if(NOT EXISTS "${KODI_INCLUDE_DIR}/")
31 file(MAKE_DIRECTORY ${KODI_INCLUDE_DIR})
32endif()
33
34# we still need XBMC_INCLUDE_DIR and XBMC_LIB_DIR for backwards compatibility to xbmc
35set(XBMC_LIB_DIR ${DEPENDS_PATH}/lib/xbmc)
36if(NOT EXISTS "${XBMC_LIB_DIR}/")
37 file(MAKE_DIRECTORY ${XBMC_LIB_DIR})
38endif()
39set(XBMC_INCLUDE_DIR ${DEPENDS_PATH}/include/xbmc)
40if(NOT EXISTS "${XBMC_INCLUDE_DIR}/")
41 file(MAKE_DIRECTORY ${XBMC_INCLUDE_DIR})
42endif()
43
44# make sure C++11 is always set
45if(NOT WIN32)
46 string(REGEX MATCH "-std=(gnu|c)\\+\\+11" cxx11flag "${CMAKE_CXX_FLAGS}")
47 if(NOT cxx11flag)
48 set(CXX11_SWITCH "-std=c++11")
49 endif()
50endif()
51
52# kodi-config.cmake.in (further down) expects a "prefix" variable
53get_filename_component(prefix "${DEPENDS_PATH}" ABSOLUTE)
54
55# generate the proper kodi-config.cmake file
56configure_file(${APP_ROOT}/project/cmake/kodi-config.cmake.in ${KODI_LIB_DIR}/kodi-config.cmake @ONLY)
57# copy cmake helpers to lib/kodi
58file(COPY ${APP_ROOT}/project/cmake/scripts/common/addon-helpers.cmake ${APP_ROOT}/project/cmake/scripts/common/addoptions.cmake DESTINATION ${KODI_LIB_DIR})
59
60# generate xbmc-config.cmake for backwards compatibility to xbmc
61configure_file(${APP_ROOT}/project/cmake/xbmc-config.cmake.in ${XBMC_LIB_DIR}/xbmc-config.cmake @ONLY)
62
63### copy all the addon binding header files to include/kodi
64# parse addon-bindings.mk to get the list of header files to copy
65file(STRINGS ${APP_ROOT}/xbmc/addons/addon-bindings.mk bindings)
66string(REPLACE "\n" ";" bindings "${bindings}")
67foreach(binding ${bindings})
68 string(REPLACE " =" ";" binding "${binding}")
69 string(REPLACE "+=" ";" binding "${binding}")
70 list(GET binding 1 header)
71 # copy the header file to include/kodi
72 file(COPY ${APP_ROOT}/${header} DESTINATION ${KODI_INCLUDE_DIR})
73
74 # auto-generate header files for backwards compatibility to xbmc with deprecation warning
75 # but only do it if the file doesn't already exist
76 get_filename_component(headerfile ${header} NAME)
77 if (NOT EXISTS "${XBMC_INCLUDE_DIR}/${headerfile}")
78 file(WRITE ${XBMC_INCLUDE_DIR}/${headerfile}
79"#pragma once
80#define DEPRECATION_WARNING \"Including xbmc/${headerfile} has been deprecated, please use kodi/${headerfile}\"
81#ifdef _MSC_VER
82 #pragma message(\"WARNING: \" DEPRECATION_WARNING)
83#else
84 #warning DEPRECATION_WARNING
85#endif
86#include \"kodi/${headerfile}\"")
87 endif()
88endforeach()