From 1e5bdca69f7676b2dbcd64f0f44f31b12b337b7c Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 13 Dec 2016 13:45:04 +0100 Subject: sync with upstream --- project/cmake/scripts/common/HandleDepends.cmake | 43 +++++++++++++++++++++--- 1 file changed, 38 insertions(+), 5 deletions(-) (limited to 'project/cmake/scripts/common/HandleDepends.cmake') 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) 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) @@ -49,7 +50,11 @@ 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() @@ -103,11 +108,18 @@ 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) - set(PATCH_PROGRAM "\"${PATCH_PROGRAM}\" --binary") + 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() endif() endif() @@ -131,8 +143,11 @@ function(add_addon_depends addon searchpath) set(INSTALL_COMMAND INSTALL_COMMAND "") endif() - # check if there's a deps.txt containing dependencies on other libraries - if(EXISTS ${dir}/deps.txt) + # 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) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${dir}/deps.txt) file(STRINGS ${dir}/deps.txt deps) message(STATUS "${id} depends: ${deps}") @@ -161,6 +176,10 @@ 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 @@ -172,6 +191,20 @@ 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) -- cgit v1.2.3