From a040b361157098324f5728af73e7427d127ba70a Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 10 Apr 2020 03:21:06 +0800 Subject: [PATCH] Update cmake for Hunter --- CMakeLists.txt | 4 +- cmake/HunterGate.cmake | 91 +++++++++++++++++++++--------------------- 2 files changed, 47 insertions(+), 48 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb337e5122..cd1db37894 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,8 +5,8 @@ option(USE_HUNTER "Use hunter" OFF) if (USE_HUNTER) include("cmake/HunterGate.cmake") HunterGate( - URL "https://github.com/ruslo/hunter/archive/v0.19.102.tar.gz" - SHA1 "49a8333d7efc24c531aed97159fe58a68374185f" + URL "https://github.com/cpp-pm/hunter/archive/v0.23.253.tar.gz" + SHA1 "88ea6d37c897a81a080eb9ae0f69d7807bbb3c73" ) endif() diff --git a/cmake/HunterGate.cmake b/cmake/HunterGate.cmake index 3a8043d2b1..6d9cc24019 100644 --- a/cmake/HunterGate.cmake +++ b/cmake/HunterGate.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2013-2017, Ruslan Baratov +# Copyright (c) 2013-2019, Ruslan Baratov # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -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.0) +# cmake_minimum_required(VERSION 3.2) # # include("cmake/HunterGate.cmake") # HunterGate( @@ -43,10 +43,14 @@ # * https://github.com/ruslo/hunter option(HUNTER_ENABLED "Enable Hunter package manager support" ON) + if(HUNTER_ENABLED) - if(CMAKE_VERSION VERSION_LESS "3.0") - message(FATAL_ERROR "At least CMake version 3.0 required for hunter dependency management." - " Update CMake or set HUNTER_ENABLED to OFF.") + if(CMAKE_VERSION VERSION_LESS "3.2") + message( + FATAL_ERROR + "At least CMake version 3.2 required for Hunter dependency management." + " Update CMake or set HUNTER_ENABLED to OFF." + ) endif() endif() @@ -54,29 +58,30 @@ 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_WIKI "https://github.com/ruslo/hunter/wiki") +set(HUNTER_ERROR_PAGE "https://docs.hunter.sh/en/latest/reference/errors") function(hunter_gate_status_print) - foreach(print_message ${ARGV}) - if(HUNTER_STATUS_PRINT OR HUNTER_STATUS_DEBUG) + if(HUNTER_STATUS_PRINT OR HUNTER_STATUS_DEBUG) + foreach(print_message ${ARGV}) message(STATUS "[hunter] ${print_message}") - endif() - endforeach() + endforeach() + endif() endfunction() function(hunter_gate_status_debug) - foreach(print_message ${ARGV}) - if(HUNTER_STATUS_DEBUG) + if(HUNTER_STATUS_DEBUG) + foreach(print_message ${ARGV}) string(TIMESTAMP timestamp) message(STATUS "[hunter *** DEBUG *** ${timestamp}] ${print_message}") - endif() - endforeach() + endforeach() + endif() endfunction() -function(hunter_gate_wiki wiki_page) - message("------------------------------ WIKI -------------------------------") - message(" ${HUNTER_WIKI}/${wiki_page}") +function(hunter_gate_error_page error_page) + message("------------------------------ ERROR ------------------------------") + message(" ${HUNTER_ERROR_PAGE}/${error_page}.html") message("-------------------------------------------------------------------") message("") message(FATAL_ERROR "") @@ -89,14 +94,13 @@ function(hunter_gate_internal_error) endforeach() message("[hunter ** INTERNAL **] [Directory:${CMAKE_CURRENT_LIST_DIR}]") message("") - hunter_gate_wiki("error.internal") + hunter_gate_error_page("error.internal") endfunction() function(hunter_gate_fatal_error) - cmake_parse_arguments(hunter "" "WIKI" "" "${ARGV}") - string(COMPARE EQUAL "${hunter_WIKI}" "" have_no_wiki) - if(have_no_wiki) - hunter_gate_internal_error("Expected wiki") + cmake_parse_arguments(hunter "" "ERROR_PAGE" "" "${ARGV}") + if("${hunter_ERROR_PAGE}" STREQUAL "") + hunter_gate_internal_error("Expected ERROR_PAGE") endif() message("") foreach(x ${hunter_UNPARSED_ARGUMENTS}) @@ -104,11 +108,11 @@ function(hunter_gate_fatal_error) endforeach() message("[hunter ** FATAL ERROR **] [Directory:${CMAKE_CURRENT_LIST_DIR}]") message("") - hunter_gate_wiki("${hunter_WIKI}") + hunter_gate_error_page("${hunter_ERROR_PAGE}") endfunction() function(hunter_gate_user_error) - hunter_gate_fatal_error(${ARGV} WIKI "error.incorrect.input.data") + hunter_gate_fatal_error(${ARGV} ERROR_PAGE "error.incorrect.input.data") endfunction() function(hunter_gate_self root version sha1 result) @@ -190,24 +194,10 @@ function(hunter_gate_detect_root) hunter_gate_fatal_error( "Can't detect HUNTER_ROOT" - WIKI "error.detect.hunter.root" + ERROR_PAGE "error.detect.hunter.root" ) endfunction() -macro(hunter_gate_lock dir) - if(NOT HUNTER_SKIP_LOCK) - if("${CMAKE_VERSION}" VERSION_LESS "3.2") - hunter_gate_fatal_error( - "Can't lock, upgrade to CMake 3.2 or use HUNTER_SKIP_LOCK" - WIKI "error.can.not.lock" - ) - endif() - hunter_gate_status_debug("Locking directory: ${dir}") - file(LOCK "${dir}" DIRECTORY GUARD FUNCTION) - hunter_gate_status_debug("Lock done") - endif() -endmacro() - function(hunter_gate_download dir) string( COMPARE @@ -223,7 +213,7 @@ function(hunter_gate_download dir) "Settings:" " HUNTER_ROOT: ${HUNTER_GATE_ROOT}" " HUNTER_SHA1: ${HUNTER_GATE_SHA1}" - WIKI "error.run.install" + ERROR_PAGE "error.run.install" ) endif() string(COMPARE EQUAL "${dir}" "" is_bad) @@ -247,7 +237,10 @@ function(hunter_gate_download dir) set(build_dir "${dir}/Build") set(cmakelists "${dir}/CMakeLists.txt") - hunter_gate_lock("${dir}") + hunter_gate_status_debug("Locking directory: ${dir}") + file(LOCK "${dir}" DIRECTORY GUARD FUNCTION) + hunter_gate_status_debug("Lock done") + if(EXISTS "${done_location}") # while waiting for lock other instance can do all the job hunter_gate_status_debug("File '${done_location}' found, skip install") @@ -264,7 +257,7 @@ function(hunter_gate_download dir) file( WRITE "${cmakelists}" - "cmake_minimum_required(VERSION 3.0)\n" + "cmake_minimum_required(VERSION 3.2)\n" "project(HunterDownload LANGUAGES NONE)\n" "include(ExternalProject)\n" "ExternalProject_Add(\n" @@ -275,6 +268,8 @@ function(hunter_gate_download dir) " SHA1=${HUNTER_GATE_SHA1}\n" " DOWNLOAD_DIR\n" " \"${dir}\"\n" + " TLS_VERIFY\n" + " ${HUNTER_TLS_VERIFY}\n" " SOURCE_DIR\n" " \"${dir}/Unpacked\"\n" " CONFIGURE_COMMAND\n" @@ -327,7 +322,11 @@ function(hunter_gate_download dir) ) if(NOT download_result EQUAL 0) - hunter_gate_internal_error("Configure project failed") + hunter_gate_internal_error( + "Configure project failed." + "To reproduce the error run: ${CMAKE_COMMAND} -H${dir} -B${build_dir} -G${CMAKE_GENERATOR} ${toolchain_arg} ${make_arg}" + "In directory ${dir}" + ) endif() hunter_gate_status_print( @@ -393,14 +392,14 @@ macro(HunterGate) ) include("${_hunter_self}/cmake/Hunter") else() - set(HUNTER_GATE_LOCATION "${CMAKE_CURRENT_LIST_DIR}") + set(HUNTER_GATE_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}") string(COMPARE NOTEQUAL "${PROJECT_NAME}" "" _have_project_name) if(_have_project_name) hunter_gate_fatal_error( "Please set HunterGate *before* 'project' command. " "Detected project: ${PROJECT_NAME}" - WIKI "error.huntergate.before.project" + ERROR_PAGE "error.huntergate.before.project" ) endif() @@ -470,7 +469,7 @@ macro(HunterGate) "HUNTER_ROOT (${HUNTER_GATE_ROOT}) contains spaces." "Set HUNTER_ALLOW_SPACES_IN_PATH=ON to skip this error" "(Use at your own risk!)" - WIKI "error.spaces.in.hunter.root" + ERROR_PAGE "error.spaces.in.hunter.root" ) endif() endif()