Skip to content
This repository was archived by the owner on Mar 22, 2020. It is now read-only.

Commit 6330fa5

Browse files
Merge pull request #31 from hunter-packages/pr.ffmpeg.new
Pr.ffmpeg.new
2 parents cf1bf8a + fc1a3ae commit 6330fa5

File tree

3 files changed

+149
-99
lines changed

3 files changed

+149
-99
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ endif()
128128

129129
include("cmake/HunterGate.cmake")
130130
HunterGate(
131-
URL "https://github.com/ruslo/hunter/archive/v0.19.68.tar.gz"
132-
SHA1 "ad0d042d8ec56a3c6a4bda1e657f1f65b494ab12"
131+
URL "https://github.com/ruslo/hunter/archive/v0.23.158.tar.gz"
132+
SHA1 "4f3d8287a546091d1968ee80e02f121b312fceea"
133133
)
134134

135135
project(OpenCV CXX C)

cmake/HunterGate.cmake

Lines changed: 128 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2013-2015, Ruslan Baratov
1+
# Copyright (c) 2013-2019, 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(
@@ -42,35 +42,46 @@
4242
# * https://github.com/hunter-packages/gate/
4343
# * https://github.com/ruslo/hunter
4444

45-
cmake_minimum_required(VERSION 3.0) # Minimum for Hunter
45+
option(HUNTER_ENABLED "Enable Hunter package manager support" ON)
46+
47+
if(HUNTER_ENABLED)
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+
)
54+
endif()
55+
endif()
56+
4657
include(CMakeParseArguments) # cmake_parse_arguments
4758

48-
option(HUNTER_ENABLED "Enable Hunter package manager support" ON)
4959
option(HUNTER_STATUS_PRINT "Print working status" ON)
5060
option(HUNTER_STATUS_DEBUG "Print a lot info" OFF)
61+
option(HUNTER_TLS_VERIFY "Enable/disable TLS certificate checking on downloads" ON)
5162

52-
set(HUNTER_WIKI "https://github.com/ruslo/hunter/wiki")
63+
set(HUNTER_ERROR_PAGE "https://docs.hunter.sh/en/latest/reference/errors")
5364

5465
function(hunter_gate_status_print)
55-
foreach(print_message ${ARGV})
56-
if(HUNTER_STATUS_PRINT OR HUNTER_STATUS_DEBUG)
66+
if(HUNTER_STATUS_PRINT OR HUNTER_STATUS_DEBUG)
67+
foreach(print_message ${ARGV})
5768
message(STATUS "[hunter] ${print_message}")
58-
endif()
59-
endforeach()
69+
endforeach()
70+
endif()
6071
endfunction()
6172

6273
function(hunter_gate_status_debug)
63-
foreach(print_message ${ARGV})
64-
if(HUNTER_STATUS_DEBUG)
74+
if(HUNTER_STATUS_DEBUG)
75+
foreach(print_message ${ARGV})
6576
string(TIMESTAMP timestamp)
6677
message(STATUS "[hunter *** DEBUG *** ${timestamp}] ${print_message}")
67-
endif()
68-
endforeach()
78+
endforeach()
79+
endif()
6980
endfunction()
7081

71-
function(hunter_gate_wiki wiki_page)
72-
message("------------------------------ WIKI -------------------------------")
73-
message(" ${HUNTER_WIKI}/${wiki_page}")
82+
function(hunter_gate_error_page error_page)
83+
message("------------------------------ ERROR ------------------------------")
84+
message(" ${HUNTER_ERROR_PAGE}/${error_page}.html")
7485
message("-------------------------------------------------------------------")
7586
message("")
7687
message(FATAL_ERROR "")
@@ -83,26 +94,25 @@ function(hunter_gate_internal_error)
8394
endforeach()
8495
message("[hunter ** INTERNAL **] [Directory:${CMAKE_CURRENT_LIST_DIR}]")
8596
message("")
86-
hunter_gate_wiki("error.internal")
97+
hunter_gate_error_page("error.internal")
8798
endfunction()
8899

89100
function(hunter_gate_fatal_error)
90-
cmake_parse_arguments(hunter "" "WIKI" "" "${ARGV}")
91-
string(COMPARE EQUAL "${hunter_WIKI}" "" have_no_wiki)
92-
if(have_no_wiki)
93-
hunter_gate_internal_error("Expected wiki")
101+
cmake_parse_arguments(hunter "" "ERROR_PAGE" "" "${ARGV}")
102+
if("${hunter_ERROR_PAGE}" STREQUAL "")
103+
hunter_gate_internal_error("Expected ERROR_PAGE")
94104
endif()
95105
message("")
96106
foreach(x ${hunter_UNPARSED_ARGUMENTS})
97107
message("[hunter ** FATAL ERROR **] ${x}")
98108
endforeach()
99109
message("[hunter ** FATAL ERROR **] [Directory:${CMAKE_CURRENT_LIST_DIR}]")
100110
message("")
101-
hunter_gate_wiki("${hunter_WIKI}")
111+
hunter_gate_error_page("${hunter_ERROR_PAGE}")
102112
endfunction()
103113

104114
function(hunter_gate_user_error)
105-
hunter_gate_fatal_error(${ARGV} WIKI "error.incorrect.input.data")
115+
hunter_gate_fatal_error(${ARGV} ERROR_PAGE "error.incorrect.input.data")
106116
endfunction()
107117

108118
function(hunter_gate_self root version sha1 result)
@@ -123,14 +133,10 @@ function(hunter_gate_self root version sha1 result)
123133

124134
string(SUBSTRING "${sha1}" 0 7 archive_id)
125135

126-
if(EXISTS "${root}/cmake/Hunter")
127-
set(hunter_self "${root}")
128-
else()
129-
set(
130-
hunter_self
131-
"${root}/_Base/Download/Hunter/${version}/${archive_id}/Unpacked"
132-
)
133-
endif()
136+
set(
137+
hunter_self
138+
"${root}/_Base/Download/Hunter/${version}/${archive_id}/Unpacked"
139+
)
134140

135141
set("${result}" "${hunter_self}" PARENT_SCOPE)
136142
endfunction()
@@ -184,24 +190,10 @@ function(hunter_gate_detect_root)
184190

185191
hunter_gate_fatal_error(
186192
"Can't detect HUNTER_ROOT"
187-
WIKI "error.detect.hunter.root"
193+
ERROR_PAGE "error.detect.hunter.root"
188194
)
189195
endfunction()
190196

191-
macro(hunter_gate_lock dir)
192-
if(NOT HUNTER_SKIP_LOCK)
193-
if("${CMAKE_VERSION}" VERSION_LESS "3.2")
194-
hunter_gate_fatal_error(
195-
"Can't lock, upgrade to CMake 3.2 or use HUNTER_SKIP_LOCK"
196-
WIKI "error.can.not.lock"
197-
)
198-
endif()
199-
hunter_gate_status_debug("Locking directory: ${dir}")
200-
file(LOCK "${dir}" DIRECTORY GUARD FUNCTION)
201-
hunter_gate_status_debug("Lock done")
202-
endif()
203-
endmacro()
204-
205197
function(hunter_gate_download dir)
206198
string(
207199
COMPARE
@@ -217,7 +209,7 @@ function(hunter_gate_download dir)
217209
"Settings:"
218210
" HUNTER_ROOT: ${HUNTER_GATE_ROOT}"
219211
" HUNTER_SHA1: ${HUNTER_GATE_SHA1}"
220-
WIKI "error.run.install"
212+
ERROR_PAGE "error.run.install"
221213
)
222214
endif()
223215
string(COMPARE EQUAL "${dir}" "" is_bad)
@@ -241,7 +233,10 @@ function(hunter_gate_download dir)
241233
set(build_dir "${dir}/Build")
242234
set(cmakelists "${dir}/CMakeLists.txt")
243235

244-
hunter_gate_lock("${dir}")
236+
hunter_gate_status_debug("Locking directory: ${dir}")
237+
file(LOCK "${dir}" DIRECTORY GUARD FUNCTION)
238+
hunter_gate_status_debug("Lock done")
239+
245240
if(EXISTS "${done_location}")
246241
# while waiting for lock other instance can do all the job
247242
hunter_gate_status_debug("File '${done_location}' found, skip install")
@@ -258,7 +253,7 @@ function(hunter_gate_download dir)
258253
file(
259254
WRITE
260255
"${cmakelists}"
261-
"cmake_minimum_required(VERSION 3.0)\n"
256+
"cmake_minimum_required(VERSION 3.2)\n"
262257
"project(HunterDownload LANGUAGES NONE)\n"
263258
"include(ExternalProject)\n"
264259
"ExternalProject_Add(\n"
@@ -269,6 +264,8 @@ function(hunter_gate_download dir)
269264
" SHA1=${HUNTER_GATE_SHA1}\n"
270265
" DOWNLOAD_DIR\n"
271266
" \"${dir}\"\n"
267+
" TLS_VERIFY\n"
268+
" ${HUNTER_TLS_VERIFY}\n"
272269
" SOURCE_DIR\n"
273270
" \"${dir}/Unpacked\"\n"
274271
" CONFIGURE_COMMAND\n"
@@ -287,15 +284,45 @@ function(hunter_gate_download dir)
287284
endif()
288285

289286
hunter_gate_status_debug("Run generate")
287+
288+
# Need to add toolchain file too.
289+
# Otherwise on Visual Studio + MDD this will fail with error:
290+
# "Could not find an appropriate version of the Windows 10 SDK installed on this machine"
291+
if(EXISTS "${CMAKE_TOOLCHAIN_FILE}")
292+
get_filename_component(absolute_CMAKE_TOOLCHAIN_FILE "${CMAKE_TOOLCHAIN_FILE}" ABSOLUTE)
293+
set(toolchain_arg "-DCMAKE_TOOLCHAIN_FILE=${absolute_CMAKE_TOOLCHAIN_FILE}")
294+
else()
295+
# 'toolchain_arg' can't be empty
296+
set(toolchain_arg "-DCMAKE_TOOLCHAIN_FILE=")
297+
endif()
298+
299+
string(COMPARE EQUAL "${CMAKE_MAKE_PROGRAM}" "" no_make)
300+
if(no_make)
301+
set(make_arg "")
302+
else()
303+
# Test case: remove Ninja from PATH but set it via CMAKE_MAKE_PROGRAM
304+
set(make_arg "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}")
305+
endif()
306+
290307
execute_process(
291-
COMMAND "${CMAKE_COMMAND}" "-H${dir}" "-B${build_dir}"
308+
COMMAND
309+
"${CMAKE_COMMAND}"
310+
"-H${dir}"
311+
"-B${build_dir}"
312+
"-G${CMAKE_GENERATOR}"
313+
"${toolchain_arg}"
314+
${make_arg}
292315
WORKING_DIRECTORY "${dir}"
293316
RESULT_VARIABLE download_result
294317
${logging_params}
295318
)
296319

297320
if(NOT download_result EQUAL 0)
298-
hunter_gate_internal_error("Configure project failed")
321+
hunter_gate_internal_error(
322+
"Configure project failed."
323+
"To reproduce the error run: ${CMAKE_COMMAND} -H${dir} -B${build_dir} -G${CMAKE_GENERATOR} ${toolchain_arg} ${make_arg}"
324+
"In directory ${dir}"
325+
)
299326
endif()
300327

301328
hunter_gate_status_print(
@@ -340,6 +367,17 @@ macro(HunterGate)
340367
# Empty function to avoid error "unknown function"
341368
function(hunter_add_package)
342369
endfunction()
370+
371+
set(
372+
_hunter_gate_disabled_mode_dir
373+
"${CMAKE_CURRENT_LIST_DIR}/cmake/Hunter/disabled-mode"
374+
)
375+
if(EXISTS "${_hunter_gate_disabled_mode_dir}")
376+
hunter_gate_status_debug(
377+
"Adding \"disabled-mode\" modules: ${_hunter_gate_disabled_mode_dir}"
378+
)
379+
list(APPEND CMAKE_PREFIX_PATH "${_hunter_gate_disabled_mode_dir}")
380+
endif()
343381
elseif(_hunter_gate_done)
344382
hunter_gate_status_debug("Secondary HunterGate (use old settings)")
345383
hunter_gate_self(
@@ -350,14 +388,14 @@ macro(HunterGate)
350388
)
351389
include("${_hunter_self}/cmake/Hunter")
352390
else()
353-
set(HUNTER_GATE_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
391+
set(HUNTER_GATE_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}")
354392

355393
string(COMPARE NOTEQUAL "${PROJECT_NAME}" "" _have_project_name)
356394
if(_have_project_name)
357395
hunter_gate_fatal_error(
358396
"Please set HunterGate *before* 'project' command. "
359397
"Detected project: ${PROJECT_NAME}"
360-
WIKI "error.huntergate.before.project"
398+
ERROR_PAGE "error.huntergate.before.project"
361399
)
362400
endif()
363401

@@ -377,17 +415,17 @@ macro(HunterGate)
377415
string(COMPARE NOTEQUAL "${HUNTER_GATE_GLOBAL}" "" _have_global)
378416
string(COMPARE NOTEQUAL "${HUNTER_GATE_FILEPATH}" "" _have_filepath)
379417

418+
if(_have_unparsed)
419+
hunter_gate_user_error(
420+
"HunterGate unparsed arguments: ${HUNTER_GATE_UNPARSED_ARGUMENTS}"
421+
)
422+
endif()
380423
if(_empty_sha1)
381424
hunter_gate_user_error("SHA1 suboption of HunterGate is mandatory")
382425
endif()
383426
if(_empty_url)
384427
hunter_gate_user_error("URL suboption of HunterGate is mandatory")
385428
endif()
386-
if(_have_unparsed)
387-
hunter_gate_user_error(
388-
"HunterGate unparsed arguments: ${HUNTER_GATE_UNPARSED_ARGUMENTS}"
389-
)
390-
endif()
391429
if(_have_global)
392430
if(HUNTER_GATE_LOCAL)
393431
hunter_gate_user_error("Unexpected LOCAL (already has GLOBAL)")
@@ -427,7 +465,7 @@ macro(HunterGate)
427465
"HUNTER_ROOT (${HUNTER_GATE_ROOT}) contains spaces."
428466
"Set HUNTER_ALLOW_SPACES_IN_PATH=ON to skip this error"
429467
"(Use at your own risk!)"
430-
WIKI "error.spaces.in.hunter.root"
468+
ERROR_PAGE "error.spaces.in.hunter.root"
431469
)
432470
endif()
433471
endif()
@@ -448,48 +486,41 @@ macro(HunterGate)
448486
"${HUNTER_GATE_ROOT}"
449487
"${HUNTER_GATE_VERSION}"
450488
"${HUNTER_GATE_SHA1}"
451-
hunter_self_
489+
_hunter_self
452490
)
453491

454-
set(_master_location "${hunter_self_}/cmake/Hunter")
455-
if(EXISTS "${HUNTER_GATE_ROOT}/cmake/Hunter")
456-
# Hunter downloaded manually (e.g. by 'git clone')
457-
set(_unused "xxxxxxxxxx")
458-
set(HUNTER_GATE_SHA1 "${_unused}")
459-
set(HUNTER_GATE_VERSION "${_unused}")
460-
else()
461-
get_filename_component(_archive_id_location "${hunter_self_}/.." ABSOLUTE)
462-
set(_done_location "${_archive_id_location}/DONE")
463-
set(_sha1_location "${_archive_id_location}/SHA1")
464-
465-
# Check Hunter already downloaded by HunterGate
466-
if(NOT EXISTS "${_done_location}")
467-
hunter_gate_download("${_archive_id_location}")
468-
endif()
492+
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")
469496

470-
if(NOT EXISTS "${_done_location}")
471-
hunter_gate_internal_error("hunter_gate_download failed")
472-
endif()
497+
# Check Hunter already downloaded by HunterGate
498+
if(NOT EXISTS "${_done_location}")
499+
hunter_gate_download("${_archive_id_location}")
500+
endif()
473501

474-
if(NOT EXISTS "${_sha1_location}")
475-
hunter_gate_internal_error("${_sha1_location} not found")
476-
endif()
477-
file(READ "${_sha1_location}" _sha1_value)
478-
string(COMPARE EQUAL "${_sha1_value}" "${HUNTER_GATE_SHA1}" _is_equal)
479-
if(NOT _is_equal)
480-
hunter_gate_internal_error(
481-
"Short SHA1 collision:"
482-
" ${_sha1_value} (from ${_sha1_location})"
483-
" ${HUNTER_GATE_SHA1} (HunterGate)"
484-
)
485-
endif()
486-
if(NOT EXISTS "${_master_location}")
487-
hunter_gate_user_error(
488-
"Master file not found:"
489-
" ${_master_location}"
490-
"try to update Hunter/HunterGate"
491-
)
492-
endif()
502+
if(NOT EXISTS "${_done_location}")
503+
hunter_gate_internal_error("hunter_gate_download failed")
504+
endif()
505+
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+
)
493524
endif()
494525
include("${_master_location}")
495526
set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES)

0 commit comments

Comments
 (0)