Skip to content
This repository was archived by the owner on Nov 17, 2025. It is now read-only.

Commit 82d298b

Browse files
authored
Improve compatibility with CMake 3.27 (#701)
- Set CMake policy settings to 3.27. - Upgrade Hunter to v0.25.3 (with HunterGate).
1 parent 24f939e commit 82d298b

File tree

4 files changed

+76
-57
lines changed

4 files changed

+76
-57
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ Documentation of all notable changes to the **EVMC** project.
55
The format is based on [Keep a Changelog],
66
and this project adheres to [Semantic Versioning].
77

8+
## [11.0.1] — unreleased
9+
10+
### Changed
11+
12+
- Improved compatibility with CMake 3.27.
13+
[#701](https://github.com/ethereum/evmc/pull/701)
14+
815
## [11.0.0] — 2023-11-29
916

1017
### Added
@@ -704,6 +711,7 @@ removed.
704711
[#52](https://github.com/ethereum/evmc/pull/52)
705712

706713

714+
[11.0.1]: https://github.com/ethereum/evmc/compare/v11.0.0..master
707715
[11.0.0]: https://github.com/ethereum/evmc/releases/tag/v11.0.0
708716
[10.1.1]: https://github.com/ethereum/evmc/releases/tag/v10.1.1
709717
[10.1.0]: https://github.com/ethereum/evmc/releases/tag/v10.1.0

CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
# Copyright 2016 The EVMC Authors.
33
# Licensed under the Apache License, Version 2.0.
44

5-
cmake_minimum_required(VERSION 3.16...3.24)
6-
7-
if(POLICY CMP0074)
8-
cmake_policy(SET CMP0074 NEW)
9-
endif()
5+
cmake_minimum_required(VERSION 3.16...3.27)
106

117
if(TARGET evmc)
128
# The evmc library has been already created (probably by other submodule).

cmake/Hunter/init.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
# Hunter is going to be initialized only if building with tests,
77
# where it is needed to get dependencies.
88
HunterGate(
9-
URL "https://github.com/cpp-pm/hunter/archive/v0.24.3.tar.gz"
10-
SHA1 "10738b59e539818a01090e64c2d09896247530c7"
9+
URL "https://github.com/cpp-pm/hunter/archive/v0.25.3.tar.gz"
10+
SHA1 "0dfbc2cb5c4cf7e83533733bdfd2125ff96680cb"
1111
)

cmake/cable/HunterGate.cmake

Lines changed: 65 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# This is a gate file to Hunter package manager.
2626
# Include this file using `include` command and add package you need, example:
2727
#
28-
# cmake_minimum_required(VERSION 3.2)
28+
# cmake_minimum_required(VERSION 3.5)
2929
#
3030
# include("cmake/HunterGate.cmake")
3131
# HunterGate(
@@ -39,16 +39,16 @@
3939
# hunter_add_package(Boo COMPONENTS Bar Baz)
4040
#
4141
# Projects:
42-
# * https://github.com/hunter-packages/gate/
43-
# * https://github.com/ruslo/hunter
42+
# * https://github.com/cpp-pm/gate/
43+
# * https://github.com/cpp-pm/hunter
4444

4545
option(HUNTER_ENABLED "Enable Hunter package manager support" ON)
4646

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

63-
set(HUNTER_ERROR_PAGE "https://docs.hunter.sh/en/latest/reference/errors")
64+
set(HUNTER_ERROR_PAGE "https://hunter.readthedocs.io/en/latest/reference/errors")
6465

6566
function(hunter_gate_status_print)
6667
if(HUNTER_STATUS_PRINT OR HUNTER_STATUS_DEBUG)
@@ -133,53 +134,52 @@ function(hunter_gate_self root version sha1 result)
133134

134135
string(SUBSTRING "${sha1}" 0 7 archive_id)
135136

136-
set(
137-
hunter_self
138-
"${root}/_Base/Download/Hunter/${version}/${archive_id}/Unpacked"
139-
)
137+
if(EXISTS "${root}/cmake/Hunter")
138+
set(hunter_self "${root}")
139+
else()
140+
set(
141+
hunter_self
142+
"${root}/_Base/Download/Hunter/${version}/${archive_id}/Unpacked"
143+
)
144+
endif()
140145

141146
set("${result}" "${hunter_self}" PARENT_SCOPE)
142147
endfunction()
143148

144149
# Set HUNTER_GATE_ROOT cmake variable to suitable value.
145150
function(hunter_gate_detect_root)
146151
# Check CMake variable
147-
string(COMPARE NOTEQUAL "${HUNTER_ROOT}" "" not_empty)
148-
if(not_empty)
152+
if(HUNTER_ROOT)
149153
set(HUNTER_GATE_ROOT "${HUNTER_ROOT}" PARENT_SCOPE)
150154
hunter_gate_status_debug("HUNTER_ROOT detected by cmake variable")
151155
return()
152156
endif()
153157

154158
# Check environment variable
155-
string(COMPARE NOTEQUAL "$ENV{HUNTER_ROOT}" "" not_empty)
156-
if(not_empty)
159+
if(DEFINED ENV{HUNTER_ROOT})
157160
set(HUNTER_GATE_ROOT "$ENV{HUNTER_ROOT}" PARENT_SCOPE)
158161
hunter_gate_status_debug("HUNTER_ROOT detected by environment variable")
159162
return()
160163
endif()
161164

162165
# Check HOME environment variable
163-
string(COMPARE NOTEQUAL "$ENV{HOME}" "" result)
164-
if(result)
166+
if(DEFINED ENV{HOME})
165167
set(HUNTER_GATE_ROOT "$ENV{HOME}/.hunter" PARENT_SCOPE)
166168
hunter_gate_status_debug("HUNTER_ROOT set using HOME environment variable")
167169
return()
168170
endif()
169171

170172
# Check SYSTEMDRIVE and USERPROFILE environment variable (windows only)
171173
if(WIN32)
172-
string(COMPARE NOTEQUAL "$ENV{SYSTEMDRIVE}" "" result)
173-
if(result)
174+
if(DEFINED ENV{SYSTEMDRIVE})
174175
set(HUNTER_GATE_ROOT "$ENV{SYSTEMDRIVE}/.hunter" PARENT_SCOPE)
175176
hunter_gate_status_debug(
176177
"HUNTER_ROOT set using SYSTEMDRIVE environment variable"
177178
)
178179
return()
179180
endif()
180181

181-
string(COMPARE NOTEQUAL "$ENV{USERPROFILE}" "" result)
182-
if(result)
182+
if(DEFINED ENV{USERPROFILE})
183183
set(HUNTER_GATE_ROOT "$ENV{USERPROFILE}/.hunter" PARENT_SCOPE)
184184
hunter_gate_status_debug(
185185
"HUNTER_ROOT set using USERPROFILE environment variable"
@@ -253,7 +253,13 @@ function(hunter_gate_download dir)
253253
file(
254254
WRITE
255255
"${cmakelists}"
256-
"cmake_minimum_required(VERSION 3.2)\n"
256+
"cmake_minimum_required(VERSION 3.5)\n"
257+
"if(POLICY CMP0114)\n"
258+
" cmake_policy(SET CMP0114 NEW)\n"
259+
"endif()\n"
260+
"if(POLICY CMP0135)\n"
261+
" cmake_policy(SET CMP0135 NEW)\n"
262+
"endif()\n"
257263
"project(HunterDownload LANGUAGES NONE)\n"
258264
"include(ExternalProject)\n"
259265
"ExternalProject_Add(\n"
@@ -490,37 +496,46 @@ macro(HunterGate)
490496
)
491497

492498
set(_master_location "${_hunter_self}/cmake/Hunter")
493-
get_filename_component(_archive_id_location "${_hunter_self}/.." ABSOLUTE)
494-
set(_done_location "${_archive_id_location}/DONE")
495-
set(_sha1_location "${_archive_id_location}/SHA1")
496-
497-
# Check Hunter already downloaded by HunterGate
498-
if(NOT EXISTS "${_done_location}")
499-
hunter_gate_download("${_archive_id_location}")
500-
endif()
499+
if(EXISTS "${HUNTER_GATE_ROOT}/cmake/Hunter")
500+
# Hunter downloaded manually (e.g. by 'git clone')
501+
set(_unused "xxxxxxxxxx")
502+
set(HUNTER_GATE_SHA1 "${_unused}")
503+
set(HUNTER_GATE_VERSION "${_unused}")
504+
else()
505+
get_filename_component(_archive_id_location "${_hunter_self}/.." ABSOLUTE)
506+
set(_done_location "${_archive_id_location}/DONE")
507+
set(_sha1_location "${_archive_id_location}/SHA1")
508+
509+
# Check Hunter already downloaded by HunterGate
510+
if(NOT EXISTS "${_done_location}")
511+
hunter_gate_download("${_archive_id_location}")
512+
endif()
501513

502-
if(NOT EXISTS "${_done_location}")
503-
hunter_gate_internal_error("hunter_gate_download failed")
504-
endif()
514+
if(NOT EXISTS "${_done_location}")
515+
hunter_gate_internal_error("hunter_gate_download failed")
516+
endif()
505517

506-
if(NOT EXISTS "${_sha1_location}")
507-
hunter_gate_internal_error("${_sha1_location} not found")
508-
endif()
509-
file(READ "${_sha1_location}" _sha1_value)
510-
string(COMPARE EQUAL "${_sha1_value}" "${HUNTER_GATE_SHA1}" _is_equal)
511-
if(NOT _is_equal)
512-
hunter_gate_internal_error(
513-
"Short SHA1 collision:"
514-
" ${_sha1_value} (from ${_sha1_location})"
515-
" ${HUNTER_GATE_SHA1} (HunterGate)"
516-
)
517-
endif()
518-
if(NOT EXISTS "${_master_location}")
519-
hunter_gate_user_error(
520-
"Master file not found:"
521-
" ${_master_location}"
522-
"try to update Hunter/HunterGate"
523-
)
518+
if(NOT EXISTS "${_sha1_location}")
519+
hunter_gate_internal_error("${_sha1_location} not found")
520+
endif()
521+
file(READ "${_sha1_location}" _sha1_value)
522+
string(TOLOWER "${_sha1_value}" _sha1_value_lower)
523+
string(TOLOWER "${HUNTER_GATE_SHA1}" _HUNTER_GATE_SHA1_lower)
524+
string(COMPARE EQUAL "${_sha1_value_lower}" "${_HUNTER_GATE_SHA1_lower}" _is_equal)
525+
if(NOT _is_equal)
526+
hunter_gate_internal_error(
527+
"Short SHA1 collision:"
528+
" ${_sha1_value} (from ${_sha1_location})"
529+
" ${HUNTER_GATE_SHA1} (HunterGate)"
530+
)
531+
endif()
532+
if(NOT EXISTS "${_master_location}")
533+
hunter_gate_user_error(
534+
"Master file not found:"
535+
" ${_master_location}"
536+
"try to update Hunter/HunterGate"
537+
)
538+
endif()
524539
endif()
525540
include("${_master_location}")
526541
set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES)

0 commit comments

Comments
 (0)