diff options
Diffstat (limited to 'project/cmake/scripts/common/HandleDepends.cmake')
| -rw-r--r-- | project/cmake/scripts/common/HandleDepends.cmake | 43 |
1 files changed, 38 insertions, 5 deletions
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) |
