Skip to content

Commit 33b6d07

Browse files
committed
Fix toolchain collision
Hunter computes a toolchain-id using the compiler vendor, version, and compile flags. The idea is that if you change some flag that will change the ABI, it will compute a new toolchain-id which will rebuild dependencies. This toolchain-id is computed by taking all of those inputs and computing a SHA1 digest, and then truncating it to the first 7 characeters. On Debian 12 I'm finding that this constantly collides when switching branches, which requires me to delete the build directory every time I change to a new branch. This change truncates the CONFIG-ID, TOOLCHAIN-ID and HUNTER-ID to 9 characters instead of 7, which resolves the problem for me.
1 parent f619c3e commit 33b6d07

7 files changed

+11
-11
lines changed

cmake/modules/hunter_apply_gate_settings.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ function(hunter_apply_gate_settings)
5656
if(gate_done)
5757
if(cache_init)
5858
# set *_ID_PATH variables in parent scope
59-
string(SUBSTRING "${HUNTER_SHA1}" 0 7 HUNTER_ID)
60-
string(SUBSTRING "${HUNTER_CONFIG_SHA1}" 0 7 HUNTER_CONFIG_ID)
61-
string(SUBSTRING "${HUNTER_TOOLCHAIN_SHA1}" 0 7 HUNTER_TOOLCHAIN_ID)
59+
string(SUBSTRING "${HUNTER_SHA1}" 0 9 HUNTER_ID)
60+
string(SUBSTRING "${HUNTER_CONFIG_SHA1}" 0 9 HUNTER_CONFIG_ID)
61+
string(SUBSTRING "${HUNTER_TOOLCHAIN_SHA1}" 0 9 HUNTER_TOOLCHAIN_ID)
6262
set(HUNTER_ID_PATH "${HUNTER_CACHED_ROOT}/_Base/${HUNTER_ID}")
6363
set(HUNTER_TOOLCHAIN_ID_PATH "${HUNTER_ID_PATH}/${HUNTER_TOOLCHAIN_ID}")
6464
set(HUNTER_CONFIG_ID_PATH "${HUNTER_TOOLCHAIN_ID_PATH}/${HUNTER_CONFIG_ID}")

cmake/modules/hunter_calculate_self.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function(hunter_calculate_self root version sha1 result)
1212
hunter_assert_not_empty_string("${sha1}")
1313
hunter_assert_not_empty_string("${result}")
1414

15-
string(SUBSTRING "${sha1}" 0 7 archive_id)
15+
string(SUBSTRING "${sha1}" 0 9 archive_id)
1616

1717
if(EXISTS "${root}/cmake/Hunter")
1818
set(hunter_self "${root}")

cmake/modules/hunter_download.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ function(hunter_download)
195195
endif()
196196

197197
if(HUNTER_PACKAGE_SCHEME_UNPACK)
198-
string(SUBSTRING "${HUNTER_PACKAGE_SHA1}" 0 7 x)
198+
string(SUBSTRING "${HUNTER_PACKAGE_SHA1}" 0 9 x)
199199
set(hunter_lock_sources TRUE)
200200
set(
201201
hunter_lock_sources_dir

cmake/modules/hunter_download_cache_raw_file.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function(hunter_download_cache_raw_file)
9696
if(NOT is_github)
9797
set(url "${server}/raw/${suffix}")
9898
else()
99-
string(SUBSTRING "${suffix}" 0 7 cache_tag)
99+
string(SUBSTRING "${suffix}" 0 9 cache_tag)
100100
set(url "${server}/releases/download/cache-${cache_tag}/${suffix}")
101101
endif()
102102

cmake/modules/hunter_download_server_url.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function(hunter_download_server_url)
6363
set(hunter_url_list) # list of URLs to try downloading from
6464

6565
# extract archive-ID from archive SHA1
66-
string(SUBSTRING "${x_SHA1}" 0 7 archive_id)
66+
string(SUBSTRING "${x_SHA1}" 0 9 archive_id)
6767

6868
# get filename from download URL
6969
get_filename_component(package_filename_raw "${x_URL}" NAME)

cmake/modules/hunter_finalize.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ macro(hunter_finalize)
7272
# * define HUNTER_CONFIG_ID_PATH
7373
hunter_apply_gate_settings()
7474

75-
string(SUBSTRING "${HUNTER_SHA1}" 0 7 HUNTER_ID)
76-
string(SUBSTRING "${HUNTER_CONFIG_SHA1}" 0 7 HUNTER_CONFIG_ID)
77-
string(SUBSTRING "${HUNTER_TOOLCHAIN_SHA1}" 0 7 HUNTER_TOOLCHAIN_ID)
75+
string(SUBSTRING "${HUNTER_SHA1}" 0 9 HUNTER_ID)
76+
string(SUBSTRING "${HUNTER_CONFIG_SHA1}" 0 9 HUNTER_CONFIG_ID)
77+
string(SUBSTRING "${HUNTER_TOOLCHAIN_SHA1}" 0 9 HUNTER_TOOLCHAIN_ID)
7878

7979
set(HUNTER_INSTALL_PREFIX "${HUNTER_CONFIG_ID_PATH}/Install")
8080
list(APPEND CMAKE_PREFIX_PATH "${HUNTER_INSTALL_PREFIX}")

cmake/modules/hunter_make_directory.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function(hunter_make_directory parent sha1 result)
1212
hunter_assert_not_empty_string("${sha1}")
1313
hunter_assert_not_empty_string("${result}")
1414

15-
string(SUBSTRING "${sha1}" 0 7 dir_id)
15+
string(SUBSTRING "${sha1}" 0 9 dir_id)
1616

1717
set(dir_path "${parent}/${dir_id}")
1818
set(done_path "${dir_path}/DONE")

0 commit comments

Comments
 (0)