Skip to content

Commit

Permalink
Merge pull request #126 from jlblancoc/hunter_v0.25.3
Browse files Browse the repository at this point in the history
Update Hunter to v0.25.3 to fix CMake 3.25 deprecation warning
  • Loading branch information
jlblancoc authored Jan 22, 2024
2 parents 1e07daa + 3c34082 commit 667a5a5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ endif()

include(cmake/HunterGate.cmake)
HunterGate(
URL "https://github.com/cpp-pm/hunter/archive/v0.24.9.tar.gz"
SHA1 "09b7e533d3da57eec51765aa73041ecd5ec94e60"
URL "https://github.com/cpp-pm/hunter/archive/v0.25.3.tar.gz"
SHA1 "0dfbc2cb5c4cf7e83533733bdfd2125ff96680cb"
)
cmake_minimum_required(VERSION 3.5)

Expand Down
36 changes: 20 additions & 16 deletions cmake/HunterGate.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# This is a gate file to Hunter package manager.
# Include this file using `include` command and add package you need, example:
#
# cmake_minimum_required(VERSION 3.2)
# cmake_minimum_required(VERSION 3.5)
#
# include("cmake/HunterGate.cmake")
# HunterGate(
Expand All @@ -45,10 +45,10 @@
option(HUNTER_ENABLED "Enable Hunter package manager support" ON)

if(HUNTER_ENABLED)
if(CMAKE_VERSION VERSION_LESS "3.2")
if(CMAKE_VERSION VERSION_LESS "3.5")
message(
FATAL_ERROR
"At least CMake version 3.2 required for Hunter dependency management."
"At least CMake version 3.5 required for Hunter dependency management."
" Update CMake or set HUNTER_ENABLED to OFF."
)
endif()
Expand All @@ -59,8 +59,9 @@ include(CMakeParseArguments) # cmake_parse_arguments
option(HUNTER_STATUS_PRINT "Print working status" ON)
option(HUNTER_STATUS_DEBUG "Print a lot info" OFF)
option(HUNTER_TLS_VERIFY "Enable/disable TLS certificate checking on downloads" ON)
set(HUNTER_ROOT "" CACHE FILEPATH "Override the HUNTER_ROOT.")

set(HUNTER_ERROR_PAGE "https://docs.hunter.sh/en/latest/reference/errors")
set(HUNTER_ERROR_PAGE "https://hunter.readthedocs.io/en/latest/reference/errors")

function(hunter_gate_status_print)
if(HUNTER_STATUS_PRINT OR HUNTER_STATUS_DEBUG)
Expand Down Expand Up @@ -148,42 +149,37 @@ endfunction()
# Set HUNTER_GATE_ROOT cmake variable to suitable value.
function(hunter_gate_detect_root)
# Check CMake variable
string(COMPARE NOTEQUAL "${HUNTER_ROOT}" "" not_empty)
if(not_empty)
if(HUNTER_ROOT)
set(HUNTER_GATE_ROOT "${HUNTER_ROOT}" PARENT_SCOPE)
hunter_gate_status_debug("HUNTER_ROOT detected by cmake variable")
return()
endif()

# Check environment variable
string(COMPARE NOTEQUAL "$ENV{HUNTER_ROOT}" "" not_empty)
if(not_empty)
if(DEFINED ENV{HUNTER_ROOT})
set(HUNTER_GATE_ROOT "$ENV{HUNTER_ROOT}" PARENT_SCOPE)
hunter_gate_status_debug("HUNTER_ROOT detected by environment variable")
return()
endif()

# Check HOME environment variable
string(COMPARE NOTEQUAL "$ENV{HOME}" "" result)
if(result)
if(DEFINED ENV{HOME})
set(HUNTER_GATE_ROOT "$ENV{HOME}/.hunter" PARENT_SCOPE)
hunter_gate_status_debug("HUNTER_ROOT set using HOME environment variable")
return()
endif()

# Check SYSTEMDRIVE and USERPROFILE environment variable (windows only)
if(WIN32)
string(COMPARE NOTEQUAL "$ENV{SYSTEMDRIVE}" "" result)
if(result)
if(DEFINED ENV{SYSTEMDRIVE})
set(HUNTER_GATE_ROOT "$ENV{SYSTEMDRIVE}/.hunter" PARENT_SCOPE)
hunter_gate_status_debug(
"HUNTER_ROOT set using SYSTEMDRIVE environment variable"
)
return()
endif()

string(COMPARE NOTEQUAL "$ENV{USERPROFILE}" "" result)
if(result)
if(DEFINED ENV{USERPROFILE})
set(HUNTER_GATE_ROOT "$ENV{USERPROFILE}/.hunter" PARENT_SCOPE)
hunter_gate_status_debug(
"HUNTER_ROOT set using USERPROFILE environment variable"
Expand Down Expand Up @@ -257,7 +253,13 @@ function(hunter_gate_download dir)
file(
WRITE
"${cmakelists}"
"cmake_minimum_required(VERSION 3.2)\n"
"cmake_minimum_required(VERSION 3.5)\n"
"if(POLICY CMP0114)\n"
" cmake_policy(SET CMP0114 NEW)\n"
"endif()\n"
"if(POLICY CMP0135)\n"
" cmake_policy(SET CMP0135 NEW)\n"
"endif()\n"
"project(HunterDownload LANGUAGES NONE)\n"
"include(ExternalProject)\n"
"ExternalProject_Add(\n"
Expand Down Expand Up @@ -517,7 +519,9 @@ macro(HunterGate)
hunter_gate_internal_error("${_sha1_location} not found")
endif()
file(READ "${_sha1_location}" _sha1_value)
string(COMPARE EQUAL "${_sha1_value}" "${HUNTER_GATE_SHA1}" _is_equal)
string(TOLOWER "${_sha1_value}" _sha1_value_lower)
string(TOLOWER "${HUNTER_GATE_SHA1}" _HUNTER_GATE_SHA1_lower)
string(COMPARE EQUAL "${_sha1_value_lower}" "${_HUNTER_GATE_SHA1_lower}" _is_equal)
if(NOT _is_equal)
hunter_gate_internal_error(
"Short SHA1 collision:"
Expand Down

0 comments on commit 667a5a5

Please sign in to comment.