Skip to content

Commit 752f1a2

Browse files
committed
Updates HunterGate
1 parent 197ae49 commit 752f1a2

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

tests/cmake/HunterGate.cmake

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2013-2017, Ruslan Baratov
1+
# Copyright (c) 2013-2018, Ruslan Baratov
22
# All rights reserved.
33
#
44
# Redistribution and use in source and binary forms, with or without
@@ -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.0)
28+
# cmake_minimum_required(VERSION 3.2)
2929
#
3030
# include("cmake/HunterGate.cmake")
3131
# HunterGate(
@@ -43,35 +43,40 @@
4343
# * https://github.com/ruslo/hunter
4444

4545
option(HUNTER_ENABLED "Enable Hunter package manager support" ON)
46+
4647
if(HUNTER_ENABLED)
47-
if(CMAKE_VERSION VERSION_LESS "3.0")
48-
message(FATAL_ERROR "At least CMake version 3.0 required for hunter dependency management."
49-
" Update CMake or set HUNTER_ENABLED to OFF.")
48+
if(CMAKE_VERSION VERSION_LESS "3.2")
49+
message(
50+
FATAL_ERROR
51+
"At least CMake version 3.2 required for Hunter dependency management."
52+
" Update CMake or set HUNTER_ENABLED to OFF."
53+
)
5054
endif()
5155
endif()
5256

5357
include(CMakeParseArguments) # cmake_parse_arguments
5458

5559
option(HUNTER_STATUS_PRINT "Print working status" ON)
5660
option(HUNTER_STATUS_DEBUG "Print a lot info" OFF)
61+
option(HUNTER_TLS_VERIFY "Enable/disable TLS certificate checking on downloads" ON)
5762

5863
set(HUNTER_WIKI "https://github.com/ruslo/hunter/wiki")
5964

6065
function(hunter_gate_status_print)
61-
foreach(print_message ${ARGV})
62-
if(HUNTER_STATUS_PRINT OR HUNTER_STATUS_DEBUG)
66+
if(HUNTER_STATUS_PRINT OR HUNTER_STATUS_DEBUG)
67+
foreach(print_message ${ARGV})
6368
message(STATUS "[hunter] ${print_message}")
64-
endif()
65-
endforeach()
69+
endforeach()
70+
endif()
6671
endfunction()
6772

6873
function(hunter_gate_status_debug)
69-
foreach(print_message ${ARGV})
70-
if(HUNTER_STATUS_DEBUG)
74+
if(HUNTER_STATUS_DEBUG)
75+
foreach(print_message ${ARGV})
7176
string(TIMESTAMP timestamp)
7277
message(STATUS "[hunter *** DEBUG *** ${timestamp}] ${print_message}")
73-
endif()
74-
endforeach()
78+
endforeach()
79+
endif()
7580
endfunction()
7681

7782
function(hunter_gate_wiki wiki_page)
@@ -194,20 +199,6 @@ function(hunter_gate_detect_root)
194199
)
195200
endfunction()
196201

197-
macro(hunter_gate_lock dir)
198-
if(NOT HUNTER_SKIP_LOCK)
199-
if("${CMAKE_VERSION}" VERSION_LESS "3.2")
200-
hunter_gate_fatal_error(
201-
"Can't lock, upgrade to CMake 3.2 or use HUNTER_SKIP_LOCK"
202-
WIKI "error.can.not.lock"
203-
)
204-
endif()
205-
hunter_gate_status_debug("Locking directory: ${dir}")
206-
file(LOCK "${dir}" DIRECTORY GUARD FUNCTION)
207-
hunter_gate_status_debug("Lock done")
208-
endif()
209-
endmacro()
210-
211202
function(hunter_gate_download dir)
212203
string(
213204
COMPARE
@@ -247,7 +238,10 @@ function(hunter_gate_download dir)
247238
set(build_dir "${dir}/Build")
248239
set(cmakelists "${dir}/CMakeLists.txt")
249240

250-
hunter_gate_lock("${dir}")
241+
hunter_gate_status_debug("Locking directory: ${dir}")
242+
file(LOCK "${dir}" DIRECTORY GUARD FUNCTION)
243+
hunter_gate_status_debug("Lock done")
244+
251245
if(EXISTS "${done_location}")
252246
# while waiting for lock other instance can do all the job
253247
hunter_gate_status_debug("File '${done_location}' found, skip install")
@@ -264,7 +258,7 @@ function(hunter_gate_download dir)
264258
file(
265259
WRITE
266260
"${cmakelists}"
267-
"cmake_minimum_required(VERSION 3.0)\n"
261+
"cmake_minimum_required(VERSION 3.2)\n"
268262
"project(HunterDownload LANGUAGES NONE)\n"
269263
"include(ExternalProject)\n"
270264
"ExternalProject_Add(\n"
@@ -275,6 +269,8 @@ function(hunter_gate_download dir)
275269
" SHA1=${HUNTER_GATE_SHA1}\n"
276270
" DOWNLOAD_DIR\n"
277271
" \"${dir}\"\n"
272+
" TLS_VERIFY\n"
273+
" ${HUNTER_TLS_VERIFY}\n"
278274
" SOURCE_DIR\n"
279275
" \"${dir}/Unpacked\"\n"
280276
" CONFIGURE_COMMAND\n"
@@ -327,7 +323,11 @@ function(hunter_gate_download dir)
327323
)
328324

329325
if(NOT download_result EQUAL 0)
330-
hunter_gate_internal_error("Configure project failed")
326+
hunter_gate_internal_error(
327+
"Configure project failed."
328+
"To reproduce the error run: ${CMAKE_COMMAND} -H${dir} -B${build_dir} -G${CMAKE_GENERATOR} ${toolchain_arg} ${make_arg}"
329+
"In directory ${dir}"
330+
)
331331
endif()
332332

333333
hunter_gate_status_print(
@@ -393,7 +393,7 @@ macro(HunterGate)
393393
)
394394
include("${_hunter_self}/cmake/Hunter")
395395
else()
396-
set(HUNTER_GATE_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
396+
set(HUNTER_GATE_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}")
397397

398398
string(COMPARE NOTEQUAL "${PROJECT_NAME}" "" _have_project_name)
399399
if(_have_project_name)
@@ -537,4 +537,4 @@ macro(HunterGate)
537537
include("${_master_location}")
538538
set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES)
539539
endif()
540-
endmacro()
540+
endmacro()

0 commit comments

Comments
 (0)