summaryrefslogtreecommitdiffstats
path: root/project/cmake/scripts/common
diff options
context:
space:
mode:
Diffstat (limited to 'project/cmake/scripts/common')
-rw-r--r--project/cmake/scripts/common/ArchSetup.cmake5
-rw-r--r--project/cmake/scripts/common/CheckTargetPlatform.cmake6
-rw-r--r--project/cmake/scripts/common/HandleDepends.cmake43
-rw-r--r--project/cmake/scripts/common/Macros.cmake9
-rw-r--r--project/cmake/scripts/common/PrepareEnv.cmake47
5 files changed, 63 insertions, 47 deletions
diff --git a/project/cmake/scripts/common/ArchSetup.cmake b/project/cmake/scripts/common/ArchSetup.cmake
index 438e3bd..538fcaf 100644
--- a/project/cmake/scripts/common/ArchSetup.cmake
+++ b/project/cmake/scripts/common/ArchSetup.cmake
@@ -14,6 +14,7 @@
14include(CheckCXXSourceCompiles) 14include(CheckCXXSourceCompiles)
15include(CheckSymbolExists) 15include(CheckSymbolExists)
16include(CheckFunctionExists) 16include(CheckFunctionExists)
17include(CheckIncludeFile)
17 18
18# Macro to check if a given type exists in a given header 19# Macro to check if a given type exists in a given header
19# Arguments: 20# Arguments:
@@ -109,6 +110,10 @@ check_symbol_exists(PRIdMAX inttypes.h HAVE_INTTYPES_H)
109check_builtin("long* temp=0; long ret=__sync_add_and_fetch(temp, 1)" HAS_BUILTIN_SYNC_ADD_AND_FETCH) 110check_builtin("long* temp=0; long ret=__sync_add_and_fetch(temp, 1)" HAS_BUILTIN_SYNC_ADD_AND_FETCH)
110check_builtin("long* temp=0; long ret=__sync_sub_and_fetch(temp, 1)" HAS_BUILTIN_SYNC_SUB_AND_FETCH) 111check_builtin("long* temp=0; long ret=__sync_sub_and_fetch(temp, 1)" HAS_BUILTIN_SYNC_SUB_AND_FETCH)
111check_builtin("long* temp=0; long ret=__sync_val_compare_and_swap(temp, 1, 1)" HAS_BUILTIN_SYNC_VAL_COMPARE_AND_SWAP) 112check_builtin("long* temp=0; long ret=__sync_val_compare_and_swap(temp, 1, 1)" HAS_BUILTIN_SYNC_VAL_COMPARE_AND_SWAP)
113check_include_file(sys/inotify.h HAVE_INOTIFY)
114if(HAVE_INOTIFY)
115 list(APPEND SYSTEM_DEFINES -DHAVE_INOTIFY=1)
116endif()
112if(HAVE_POSIX_FADVISE) 117if(HAVE_POSIX_FADVISE)
113 list(APPEND SYSTEM_DEFINES -DHAVE_POSIX_FADVISE=1) 118 list(APPEND SYSTEM_DEFINES -DHAVE_POSIX_FADVISE=1)
114endif() 119endif()
diff --git a/project/cmake/scripts/common/CheckTargetPlatform.cmake b/project/cmake/scripts/common/CheckTargetPlatform.cmake
index 5b5d9a1..82ee668 100644
--- a/project/cmake/scripts/common/CheckTargetPlatform.cmake
+++ b/project/cmake/scripts/common/CheckTargetPlatform.cmake
@@ -9,7 +9,11 @@ function(check_target_platform dir target_platform build)
9 if(EXISTS ${dir} AND EXISTS ${dir}/platforms.txt) 9 if(EXISTS ${dir} AND EXISTS ${dir}/platforms.txt)
10 # get all the specified platforms 10 # get all the specified platforms
11 file(STRINGS ${dir}/platforms.txt platforms) 11 file(STRINGS ${dir}/platforms.txt platforms)
12 string(REPLACE " " ";" platforms ${platforms}) 12
13 list( LENGTH platforms listlen )
14 if(${listlen} EQUAL 1)
15 string(REPLACE " " ";" platforms ${platforms})
16 endif()
13 17
14 # check if the addon/dependency should be built for the current platform 18 # check if the addon/dependency should be built for the current platform
15 foreach(platform ${platforms}) 19 foreach(platform ${platforms})
diff --git a/project/cmake/scripts/common/HandleDepends.cmake b/project/cmake/scripts/common/HandleDepends.cmake
index 880ccdf..adc105b 100644
--- a/project/cmake/scripts/common/HandleDepends.cmake
+++ b/project/cmake/scripts/common/HandleDepends.cmake
@@ -17,6 +17,7 @@ function(add_addon_depends addon searchpath)
17 file MATCHES noinstall.txt OR 17 file MATCHES noinstall.txt OR
18 file MATCHES flags.txt OR 18 file MATCHES flags.txt OR
19 file MATCHES deps.txt OR 19 file MATCHES deps.txt OR
20 file MATCHES "[a-z]+-deps[.]txt" OR
20 file MATCHES platforms.txt)) 21 file MATCHES platforms.txt))
21 message(STATUS "Processing ${file}") 22 message(STATUS "Processing ${file}")
22 file(STRINGS ${file} def) 23 file(STRINGS ${file} def)
@@ -49,7 +50,11 @@ function(add_addon_depends addon searchpath)
49 if(EXISTS ${dir}/flags.txt) 50 if(EXISTS ${dir}/flags.txt)
50 set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${dir}/flags.txt) 51 set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${dir}/flags.txt)
51 file(STRINGS ${dir}/flags.txt extraflags) 52 file(STRINGS ${dir}/flags.txt extraflags)
53
54 # replace some custom placeholders
55 string(REPLACE "@MINGW_TOOLCHAIN_FILE@" "${OUTPUT_DIR}/Toolchain_mingw32.cmake" extraflags "${extraflags}")
52 string(REPLACE " " ";" extraflags ${extraflags}) 56 string(REPLACE " " ";" extraflags ${extraflags})
57
53 message(STATUS "${id} extraflags: ${extraflags}") 58 message(STATUS "${id} extraflags: ${extraflags}")
54 endif() 59 endif()
55 60
@@ -103,11 +108,18 @@ function(add_addon_depends addon searchpath)
103 endif() 108 endif()
104 endif() 109 endif()
105 110
106 # on windows "patch.exe" can only handle CR-LF line-endings so we
107 # need to force it to also handle LF-only line endings
108 set(PATCH_PROGRAM ${PATCH_EXECUTABLE}) 111 set(PATCH_PROGRAM ${PATCH_EXECUTABLE})
112
113 # On Windows "patch.exe" can only handle CR-LF line-endings.
114 # Our patches have LF-only line endings - except when they
115 # have been checked out as part of a dependency hosted on Git
116 # and core.autocrlf=true.
109 if(WIN32) 117 if(WIN32)
110 set(PATCH_PROGRAM "\"${PATCH_PROGRAM}\" --binary") 118 file(READ ${patch} patch_content_hex HEX)
119 # Force handle LF-only line endings
120 if(NOT patch_content_hex MATCHES "0d0a")
121 set(PATCH_PROGRAM "\"${PATCH_PROGRAM}\" --binary")
122 endif()
111 endif() 123 endif()
112 endif() 124 endif()
113 125
@@ -131,8 +143,11 @@ function(add_addon_depends addon searchpath)
131 set(INSTALL_COMMAND INSTALL_COMMAND "") 143 set(INSTALL_COMMAND INSTALL_COMMAND "")
132 endif() 144 endif()
133 145
134 # check if there's a deps.txt containing dependencies on other libraries 146 # check if there's a platform-specific or generic deps.txt containing dependencies on other libraries
135 if(EXISTS ${dir}/deps.txt) 147 if(EXISTS ${dir}/${CORE_SYSTEM_NAME}-deps.txt)
148 file(STRINGS ${dir}/${CORE_SYSTEM_NAME}-deps.txt deps)
149 message(STATUS "${id} depends: ${deps}")
150 elseif(EXISTS ${dir}/deps.txt)
136 set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${dir}/deps.txt) 151 set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${dir}/deps.txt)
137 file(STRINGS ${dir}/deps.txt deps) 152 file(STRINGS ${dir}/deps.txt deps)
138 message(STATUS "${id} depends: ${deps}") 153 message(STATUS "${id} depends: ${deps}")
@@ -161,6 +176,10 @@ function(add_addon_depends addon searchpath)
161 PATCH_COMMAND ${PATCH_COMMAND} 176 PATCH_COMMAND ${PATCH_COMMAND}
162 "${INSTALL_COMMAND}") 177 "${INSTALL_COMMAND}")
163 178
179 if(CMAKE_VERSION VERSION_GREATER 3.5.9)
180 list(APPEND EXTERNALPROJECT_SETUP GIT_SHALLOW 1)
181 endif()
182
164 # if there's an url defined we need to pass that to externalproject_add() 183 # if there's an url defined we need to pass that to externalproject_add()
165 if(DEFINED url AND NOT "${url}" STREQUAL "") 184 if(DEFINED url AND NOT "${url}" STREQUAL "")
166 # check if there's a third parameter in the file 185 # check if there's a third parameter in the file
@@ -172,6 +191,20 @@ function(add_addon_depends addon searchpath)
172 GIT_REPOSITORY ${url} 191 GIT_REPOSITORY ${url}
173 GIT_TAG ${revision} 192 GIT_TAG ${revision}
174 "${EXTERNALPROJECT_SETUP}") 193 "${EXTERNALPROJECT_SETUP}")
194
195 # For patchfiles to work, disable (users globally set) autocrlf=true
196 if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_GREATER 3.7)
197 message(AUTHOR_WARNING "Make use of GIT_CONFIG")
198 endif()
199 if(WIN32 AND patches)
200 externalproject_add_step(${id} gitconfig
201 COMMAND git config core.autocrlf false
202 COMMAND git rm -rf --cached .
203 COMMAND git reset --hard HEAD
204 COMMENT "Performing gitconfig step: Disabling autocrlf to enable patching for '${id}'"
205 DEPENDERS patch
206 WORKING_DIRECTORY <SOURCE_DIR>)
207 endif()
175 else() 208 else()
176 set(CONFIGURE_COMMAND "") 209 set(CONFIGURE_COMMAND "")
177 if(NOT WIN32) 210 if(NOT WIN32)
diff --git a/project/cmake/scripts/common/Macros.cmake b/project/cmake/scripts/common/Macros.cmake
index 71c39ef..cce3245 100644
--- a/project/cmake/scripts/common/Macros.cmake
+++ b/project/cmake/scripts/common/Macros.cmake
@@ -155,9 +155,12 @@ function(core_add_shared_library name)
155 add_library(${name} SHARED ${SOURCES} ${HEADERS} ${OTHERS}) 155 add_library(${name} SHARED ${SOURCES} ${HEADERS} ${OTHERS})
156 set_target_properties(${name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY} 156 set_target_properties(${name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY}
157 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY} 157 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY}
158 RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY}
159 RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY}
160 OUTPUT_NAME ${OUTPUT_NAME} PREFIX "") 158 OUTPUT_NAME ${OUTPUT_NAME} PREFIX "")
159 foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
160 string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
161 set_target_properties(${name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY}
162 RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY})
163 endforeach()
161 164
162 set(LIBRARY_FILES ${LIBRARY_FILES} ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY}/${OUTPUT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX} CACHE STRING "" FORCE) 165 set(LIBRARY_FILES ${LIBRARY_FILES} ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY}/${OUTPUT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX} CACHE STRING "" FORCE)
163 add_dependencies(${APP_NAME_LC}-libraries ${name}) 166 add_dependencies(${APP_NAME_LC}-libraries ${name})
@@ -595,9 +598,9 @@ macro(core_find_versions)
595 set(APP_VERSION ${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}) 598 set(APP_VERSION ${APP_VERSION_MAJOR}.${APP_VERSION_MINOR})
596 if(APP_VERSION_TAG) 599 if(APP_VERSION_TAG)
597 set(APP_VERSION ${APP_VERSION}-${APP_VERSION_TAG}) 600 set(APP_VERSION ${APP_VERSION}-${APP_VERSION_TAG})
601 string(TOLOWER ${APP_VERSION_TAG} APP_VERSION_TAG_LC)
598 endif() 602 endif()
599 string(REPLACE "." "," FILE_VERSION ${APP_ADDON_API}.0) 603 string(REPLACE "." "," FILE_VERSION ${APP_ADDON_API}.0)
600 string(TOLOWER ${APP_VERSION_TAG} APP_VERSION_TAG_LC)
601 file(STRINGS ${CORE_SOURCE_DIR}/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h guilib_version REGEX "^.*GUILIB_API_VERSION (.*)$") 604 file(STRINGS ${CORE_SOURCE_DIR}/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h guilib_version REGEX "^.*GUILIB_API_VERSION (.*)$")
602 string(REGEX REPLACE ".*\"(.*)\"" "\\1" guilib_version ${guilib_version}) 605 string(REGEX REPLACE ".*\"(.*)\"" "\\1" guilib_version ${guilib_version})
603 file(STRINGS ${CORE_SOURCE_DIR}/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h guilib_version_min REGEX "^.*GUILIB_MIN_API_VERSION (.*)$") 606 file(STRINGS ${CORE_SOURCE_DIR}/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h guilib_version_min REGEX "^.*GUILIB_MIN_API_VERSION (.*)$")
diff --git a/project/cmake/scripts/common/PrepareEnv.cmake b/project/cmake/scripts/common/PrepareEnv.cmake
index 8e02382..51be739 100644
--- a/project/cmake/scripts/common/PrepareEnv.cmake
+++ b/project/cmake/scripts/common/PrepareEnv.cmake
@@ -51,43 +51,14 @@ foreach(binding ${bindings})
51 configure_file(${CORE_SOURCE_DIR}/${header} ${APP_INCLUDE_DIR} COPYONLY) 51 configure_file(${CORE_SOURCE_DIR}/${header} ${APP_INCLUDE_DIR} COPYONLY)
52endforeach() 52endforeach()
53 53
54### on windows we need a "patch" binary to be able to patch 3rd party sources 54### processing additional tools required by the platform
55if(WIN32) 55if(EXISTS ${CORE_SOURCE_DIR}/project/cmake/scripts/${CORE_SYSTEM_NAME}/tools/)
56 find_program(PATCH_FOUND NAMES patch patch.exe) 56 file(GLOB platform_tools ${CORE_SOURCE_DIR}/project/cmake/scripts/${CORE_SYSTEM_NAME}/tools/*.cmake)
57 if(PATCH_FOUND) 57 foreach(platform_tool ${platform_tools})
58 message(STATUS "patch utility found at ${PATCH_FOUND}") 58 get_filename_component(platform_tool_name ${platform_tool} NAME_WE)
59 else() 59 message(STATUS "Processing ${CORE_SYSTEM_NAME} specific tool: ${platform_tool_name}")
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 60
65 # download the archive containing patch.exe 61 # include the file
66 message(STATUS "Downloading patch utility from ${PATCH_URL}...") 62 include(${platform_tool})
67 file(DOWNLOAD "${PATCH_URL}" "${PATCH_DOWNLOAD}" STATUS PATCH_DL_STATUS LOG PATCH_LOG SHOW_PROGRESS) 63 endforeach()
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() 64endif()