@@ -202,30 +202,26 @@ function(cpm_package_name_from_git_uri URI RESULT)
202202 endif ()
203203endfunction ()
204204
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
211214#
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.
220217function (cpm_get_shortest_hash source_cache_dir origin_hash short_hash_output_var)
221218 foreach (len RANGE 4 40 4)
222219 string (SUBSTRING "${origin_hash} " 0 ${len} short_hash)
223220 set (hash_lock ${source_cache_dir} /${short_hash} .lock)
224221 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.
229225 file (LOCK ${hash_lock} GUARD FUNCTION)
230226
231227 # 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
244240 file (LOCK ${hash_lock} RELEASE)
245241 endif ()
246242 endforeach ()
247- set (${short_hash_output_var} "${short_hash} " PARENT_SCOPE)
243+ set (${short_hash_output_var}
244+ "${short_hash} "
245+ PARENT_SCOPE
246+ )
248247endfunction ()
249248
250-
251249# Try to infer package name and version from a url
252250function (cpm_package_name_and_ver_from_url url outName outVer)
253251 if (url MATCHES "[/\\ ?]([a-zA-Z0-9_\\ .-]+)\\ .(tar|tar\\ .gz|tar\\ .bz2|zip|ZIP)(\\ ?|/|$)" )
@@ -845,17 +843,17 @@ function(CPMAddPackage)
845843 elseif (CPM_USE_NAMED_CACHE_DIRECTORIES)
846844 string (SHA1 origin_hash "${origin_parameters} ;NEW_CACHE_STRUCTURE_TAG" )
847845 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
851849 )
852850 set (download_directory ${CPM_SOURCE_CACHE} /${lower_case_name} /${origin_hash} /${CPM_ARGS_NAME} )
853851 else ()
854852 string (SHA1 origin_hash "${origin_parameters} " )
855853 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
859857 )
860858 set (download_directory ${CPM_SOURCE_CACHE} /${lower_case_name} /${origin_hash} )
861859 endif ()
0 commit comments