@@ -202,30 +202,26 @@ function(cpm_package_name_from_git_uri URI RESULT)
202
202
endif ()
203
203
endfunction ()
204
204
205
-
206
- # Find the shortest hash that can be used
207
- # eg, if origin_hash is cccb77ae9609d2768ed80dd42cec54f77b1f1455
208
- # the following files will be checked, until one is found that
209
- # is either empty (allowing us to assign origin_hash), or whose contents matches
210
- # ${origin_hash}
205
+ # Find the shortest hash that can be used eg, if origin_hash is
206
+ # cccb77ae9609d2768ed80dd42cec54f77b1f1455 the following files will be checked, until one is found
207
+ # that is either empty (allowing us to assign origin_hash), or whose contents matches ${origin_hash}
208
+ #
209
+ # * .../cccb.hash
210
+ # * .../cccb77ae.hash
211
+ # * .../cccb77ae9609.hash
212
+ # * .../cccb77ae9609d276.hash
213
+ # * etc
211
214
#
212
- # - .../cccb.hash
213
- # - .../cccb77ae.hash
214
- # - .../cccb77ae9609.hash
215
- # - .../cccb77ae9609d276.hash
216
- # etc
217
- # We will be able to use a shorter path with very high probability, but in the
218
- # (rare) event that the first couple characters collide, we will check
219
- # longer and longer substrings.
215
+ # We will be able to use a shorter path with very high probability, but in the (rare) event that the
216
+ # first couple characters collide, we will check longer and longer substrings.
220
217
function (cpm_get_shortest_hash source_cache_dir origin_hash short_hash_output_var)
221
218
foreach (len RANGE 4 40 4)
222
219
string (SUBSTRING "${origin_hash} " 0 ${len} short_hash)
223
220
set (hash_lock ${source_cache_dir} /${short_hash} .lock)
224
221
set (hash_fp ${source_cache_dir} /${short_hash} .hash)
225
- # Take a lock, so we don't have a race condition with another instance
226
- # of cmake. We will release this lock when we can, however, if there
227
- # is an error, we want to ensure it gets released on it's own on exit
228
- # from the function.
222
+ # Take a lock, so we don't have a race condition with another instance of cmake. We will release
223
+ # this lock when we can, however, if there is an error, we want to ensure it gets released on
224
+ # it's own on exit from the function.
229
225
file (LOCK ${hash_lock} GUARD FUNCTION)
230
226
231
227
# Load the contents of .../${short_hash}.hash
@@ -244,10 +240,12 @@ function(cpm_get_shortest_hash source_cache_dir origin_hash short_hash_output_va
244
240
file (LOCK ${hash_lock} RELEASE)
245
241
endif ()
246
242
endforeach ()
247
- set (${short_hash_output_var} "${short_hash} " PARENT_SCOPE)
243
+ set (${short_hash_output_var}
244
+ "${short_hash} "
245
+ PARENT_SCOPE
246
+ )
248
247
endfunction ()
249
248
250
-
251
249
# Try to infer package name and version from a url
252
250
function (cpm_package_name_and_ver_from_url url outName outVer)
253
251
if (url MATCHES "[/\\ ?]([a-zA-Z0-9_\\ .-]+)\\ .(tar|tar\\ .gz|tar\\ .bz2|zip|ZIP)(\\ ?|/|$)" )
@@ -845,17 +843,17 @@ function(CPMAddPackage)
845
843
elseif (CPM_USE_NAMED_CACHE_DIRECTORIES)
846
844
string (SHA1 origin_hash "${origin_parameters} ;NEW_CACHE_STRUCTURE_TAG" )
847
845
cpm_get_shortest_hash(
848
- "${CPM_SOURCE_CACHE} /${lower_case_name} " # source cache directory
849
- "${origin_hash} " # Input hash
850
- origin_hash # Computed hash
846
+ "${CPM_SOURCE_CACHE} /${lower_case_name} " # source cache directory
847
+ "${origin_hash} " # Input hash
848
+ origin_hash # Computed hash
851
849
)
852
850
set (download_directory ${CPM_SOURCE_CACHE} /${lower_case_name} /${origin_hash} /${CPM_ARGS_NAME} )
853
851
else ()
854
852
string (SHA1 origin_hash "${origin_parameters} " )
855
853
cpm_get_shortest_hash(
856
- "${CPM_SOURCE_CACHE} /${lower_case_name} " # source cache directory
857
- "${origin_hash} " # Input hash
858
- origin_hash # Computed hash
854
+ "${CPM_SOURCE_CACHE} /${lower_case_name} " # source cache directory
855
+ "${origin_hash} " # Input hash
856
+ origin_hash # Computed hash
859
857
)
860
858
set (download_directory ${CPM_SOURCE_CACHE} /${lower_case_name} /${origin_hash} )
861
859
endif ()
0 commit comments