From a662ba767a6444b76b0394eb60380eee3e839db7 Mon Sep 17 00:00:00 2001 From: manuel Date: Wed, 14 Dec 2016 02:24:46 +0100 Subject: Sync with Krypton branch --- project/cmake/scripts/common/HandleDepends.cmake | 43 +++------------------- project/cmake/scripts/common/Macros.cmake | 9 ++--- project/cmake/scripts/common/PrepareEnv.cmake | 47 +++++++++++++++++++----- 3 files changed, 46 insertions(+), 53 deletions(-) (limited to 'project/cmake/scripts/common') diff --git a/project/cmake/scripts/common/HandleDepends.cmake b/project/cmake/scripts/common/HandleDepends.cmake index adc105b..880ccdf 100644 --- a/project/cmake/scripts/common/HandleDepends.cmake +++ b/project/cmake/scripts/common/HandleDepends.cmake @@ -17,7 +17,6 @@ function(add_addon_depends addon searchpath) file MATCHES noinstall.txt OR file MATCHES flags.txt OR file MATCHES deps.txt OR - file MATCHES "[a-z]+-deps[.]txt" OR file MATCHES platforms.txt)) message(STATUS "Processing ${file}") file(STRINGS ${file} def) @@ -50,11 +49,7 @@ function(add_addon_depends addon searchpath) if(EXISTS ${dir}/flags.txt) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${dir}/flags.txt) file(STRINGS ${dir}/flags.txt extraflags) - - # replace some custom placeholders - string(REPLACE "@MINGW_TOOLCHAIN_FILE@" "${OUTPUT_DIR}/Toolchain_mingw32.cmake" extraflags "${extraflags}") string(REPLACE " " ";" extraflags ${extraflags}) - message(STATUS "${id} extraflags: ${extraflags}") endif() @@ -108,18 +103,11 @@ function(add_addon_depends addon searchpath) endif() endif() + # on windows "patch.exe" can only handle CR-LF line-endings so we + # need to force it to also handle LF-only line endings set(PATCH_PROGRAM ${PATCH_EXECUTABLE}) - - # On Windows "patch.exe" can only handle CR-LF line-endings. - # Our patches have LF-only line endings - except when they - # have been checked out as part of a dependency hosted on Git - # and core.autocrlf=true. if(WIN32) - file(READ ${patch} patch_content_hex HEX) - # Force handle LF-only line endings - if(NOT patch_content_hex MATCHES "0d0a") - set(PATCH_PROGRAM "\"${PATCH_PROGRAM}\" --binary") - endif() + set(PATCH_PROGRAM "\"${PATCH_PROGRAM}\" --binary") endif() endif() @@ -143,11 +131,8 @@ function(add_addon_depends addon searchpath) set(INSTALL_COMMAND INSTALL_COMMAND "") endif() - # check if there's a platform-specific or generic deps.txt containing dependencies on other libraries - if(EXISTS ${dir}/${CORE_SYSTEM_NAME}-deps.txt) - file(STRINGS ${dir}/${CORE_SYSTEM_NAME}-deps.txt deps) - message(STATUS "${id} depends: ${deps}") - elseif(EXISTS ${dir}/deps.txt) + # check if there's a deps.txt containing dependencies on other libraries + if(EXISTS ${dir}/deps.txt) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${dir}/deps.txt) file(STRINGS ${dir}/deps.txt deps) message(STATUS "${id} depends: ${deps}") @@ -176,10 +161,6 @@ function(add_addon_depends addon searchpath) PATCH_COMMAND ${PATCH_COMMAND} "${INSTALL_COMMAND}") - if(CMAKE_VERSION VERSION_GREATER 3.5.9) - list(APPEND EXTERNALPROJECT_SETUP GIT_SHALLOW 1) - endif() - # if there's an url defined we need to pass that to externalproject_add() if(DEFINED url AND NOT "${url}" STREQUAL "") # check if there's a third parameter in the file @@ -191,20 +172,6 @@ function(add_addon_depends addon searchpath) GIT_REPOSITORY ${url} GIT_TAG ${revision} "${EXTERNALPROJECT_SETUP}") - - # For patchfiles to work, disable (users globally set) autocrlf=true - if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_GREATER 3.7) - message(AUTHOR_WARNING "Make use of GIT_CONFIG") - endif() - if(WIN32 AND patches) - externalproject_add_step(${id} gitconfig - COMMAND git config core.autocrlf false - COMMAND git rm -rf --cached . - COMMAND git reset --hard HEAD - COMMENT "Performing gitconfig step: Disabling autocrlf to enable patching for '${id}'" - DEPENDERS patch - WORKING_DIRECTORY ) - endif() else() set(CONFIGURE_COMMAND "") if(NOT WIN32) diff --git a/project/cmake/scripts/common/Macros.cmake b/project/cmake/scripts/common/Macros.cmake index cce3245..71c39ef 100644 --- a/project/cmake/scripts/common/Macros.cmake +++ b/project/cmake/scripts/common/Macros.cmake @@ -155,12 +155,9 @@ function(core_add_shared_library name) add_library(${name} SHARED ${SOURCES} ${HEADERS} ${OTHERS}) set_target_properties(${name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY} RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY} + RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY} + RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY} OUTPUT_NAME ${OUTPUT_NAME} PREFIX "") - foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) - string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG) - set_target_properties(${name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY} - RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY}) - endforeach() set(LIBRARY_FILES ${LIBRARY_FILES} ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY}/${OUTPUT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX} CACHE STRING "" FORCE) add_dependencies(${APP_NAME_LC}-libraries ${name}) @@ -598,9 +595,9 @@ macro(core_find_versions) set(APP_VERSION ${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}) if(APP_VERSION_TAG) set(APP_VERSION ${APP_VERSION}-${APP_VERSION_TAG}) - string(TOLOWER ${APP_VERSION_TAG} APP_VERSION_TAG_LC) endif() string(REPLACE "." "," FILE_VERSION ${APP_ADDON_API}.0) + string(TOLOWER ${APP_VERSION_TAG} APP_VERSION_TAG_LC) file(STRINGS ${CORE_SOURCE_DIR}/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h guilib_version REGEX "^.*GUILIB_API_VERSION (.*)$") string(REGEX REPLACE ".*\"(.*)\"" "\\1" guilib_version ${guilib_version}) 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 51be739..8e02382 100644 --- a/project/cmake/scripts/common/PrepareEnv.cmake +++ b/project/cmake/scripts/common/PrepareEnv.cmake @@ -51,14 +51,43 @@ foreach(binding ${bindings}) configure_file(${CORE_SOURCE_DIR}/${header} ${APP_INCLUDE_DIR} COPYONLY) endforeach() -### processing additional tools required by the platform -if(EXISTS ${CORE_SOURCE_DIR}/project/cmake/scripts/${CORE_SYSTEM_NAME}/tools/) - file(GLOB platform_tools ${CORE_SOURCE_DIR}/project/cmake/scripts/${CORE_SYSTEM_NAME}/tools/*.cmake) - foreach(platform_tool ${platform_tools}) - get_filename_component(platform_tool_name ${platform_tool} NAME_WE) - message(STATUS "Processing ${CORE_SYSTEM_NAME} specific tool: ${platform_tool_name}") +### on windows we need a "patch" binary to be able to patch 3rd party sources +if(WIN32) + find_program(PATCH_FOUND NAMES patch patch.exe) + if(PATCH_FOUND) + message(STATUS "patch utility found at ${PATCH_FOUND}") + else() + set(PATCH_ARCHIVE_NAME "patch-2.5.9-7-bin-3") + set(PATCH_ARCHIVE "${PATCH_ARCHIVE_NAME}.zip") + set(PATCH_URL "${KODI_MIRROR}/build-deps/win32/${PATCH_ARCHIVE}") + set(PATCH_DOWNLOAD ${BUILD_DIR}/download/${PATCH_ARCHIVE}) - # include the file - include(${platform_tool}) - endforeach() + # download the archive containing patch.exe + message(STATUS "Downloading patch utility from ${PATCH_URL}...") + file(DOWNLOAD "${PATCH_URL}" "${PATCH_DOWNLOAD}" STATUS PATCH_DL_STATUS LOG PATCH_LOG SHOW_PROGRESS) + list(GET PATCH_DL_STATUS 0 PATCH_RETCODE) + if(NOT ${PATCH_RETCODE} EQUAL 0) + message(FATAL_ERROR "ERROR downloading ${PATCH_URL} - status: ${PATCH_DL_STATUS} log: ${PATCH_LOG}") + endif() + + # extract the archive containing patch.exe + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzvf ${PATCH_DOWNLOAD} + WORKING_DIRECTORY ${BUILD_DIR}) + + # make sure the extraction worked and that patch.exe is there + set(PATCH_PATH ${BUILD_DIR}/${PATCH_ARCHIVE_NAME}) + set(PATCH_BINARY_PATH ${PATCH_PATH}/bin/patch.exe) + if(NOT EXISTS ${PATCH_PATH} OR NOT EXISTS ${PATCH_BINARY_PATH}) + message(FATAL_ERROR "ERROR extracting patch utility from ${PATCH_DOWNLOAD_DIR}") + endif() + + # copy patch.exe into the output directory + file(INSTALL ${PATCH_BINARY_PATH} DESTINATION ${ADDON_DEPENDS_PATH}/bin) + + # make sure that cmake can find the copied patch.exe + find_program(PATCH_FOUND NAMES patch patch.exe) + if(NOT PATCH_FOUND) + message(FATAL_ERROR "ERROR installing patch utility from ${PATCH_BINARY_PATH} to ${ADDON_DEPENDS_PATH}/bin") + endif() + endif() endif() -- cgit v1.2.3