From 2ccc93e8e5d0e6ed02b55923dc222972dbbddf06 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Sat, 16 May 2015 20:38:24 +0200 Subject: [PATCH 01/25] Add HunterGate module --- cmake/HunterGate.cmake | 497 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 497 insertions(+) create mode 100644 cmake/HunterGate.cmake diff --git a/cmake/HunterGate.cmake b/cmake/HunterGate.cmake new file mode 100644 index 000000000000..acb6aeccaa18 --- /dev/null +++ b/cmake/HunterGate.cmake @@ -0,0 +1,497 @@ +# Copyright (c) 2013-2015, Ruslan Baratov +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# 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) +# +# include("cmake/HunterGate.cmake") +# HunterGate( +# URL "https://github.com/path/to/hunter/archive.tar.gz" +# SHA1 "798501e983f14b28b10cda16afa4de69eee1da1d" +# ) +# +# project(MyProject) +# +# hunter_add_package(Foo) +# hunter_add_package(Boo COMPONENTS Bar Baz) +# +# Projects: +# * https://github.com/hunter-packages/gate/ +# * https://github.com/ruslo/hunter + +cmake_minimum_required(VERSION 3.0) # Minimum for Hunter +include(CMakeParseArguments) # cmake_parse_arguments + +option(HUNTER_ENABLED "Enable Hunter package manager support" ON) +option(HUNTER_STATUS_PRINT "Print working status" ON) +option(HUNTER_STATUS_DEBUG "Print a lot info" OFF) + +set(HUNTER_WIKI "https://github.com/ruslo/hunter/wiki") + +function(hunter_gate_status_print) + foreach(print_message ${ARGV}) + if(HUNTER_STATUS_PRINT OR HUNTER_STATUS_DEBUG) + message(STATUS "[hunter] ${print_message}") + endif() + endforeach() +endfunction() + +function(hunter_gate_status_debug) + foreach(print_message ${ARGV}) + if(HUNTER_STATUS_DEBUG) + string(TIMESTAMP timestamp) + message(STATUS "[hunter *** DEBUG *** ${timestamp}] ${print_message}") + endif() + endforeach() +endfunction() + +function(hunter_gate_wiki wiki_page) + message("------------------------------ WIKI -------------------------------") + message(" ${HUNTER_WIKI}/${wiki_page}") + message("-------------------------------------------------------------------") + message("") + message(FATAL_ERROR "") +endfunction() + +function(hunter_gate_internal_error) + message("") + foreach(print_message ${ARGV}) + message("[hunter ** INTERNAL **] ${print_message}") + endforeach() + message("[hunter ** INTERNAL **] [Directory:${CMAKE_CURRENT_LIST_DIR}]") + message("") + hunter_gate_wiki("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") + endif() + message("") + foreach(x ${hunter_UNPARSED_ARGUMENTS}) + message("[hunter ** FATAL ERROR **] ${x}") + endforeach() + message("[hunter ** FATAL ERROR **] [Directory:${CMAKE_CURRENT_LIST_DIR}]") + message("") + hunter_gate_wiki("${hunter_WIKI}") +endfunction() + +function(hunter_gate_user_error) + hunter_gate_fatal_error(${ARGV} WIKI "error.incorrect.input.data") +endfunction() + +function(hunter_gate_self root version sha1 result) + string(COMPARE EQUAL "${root}" "" is_bad) + if(is_bad) + hunter_gate_internal_error("root is empty") + endif() + + string(COMPARE EQUAL "${version}" "" is_bad) + if(is_bad) + hunter_gate_internal_error("version is empty") + endif() + + string(COMPARE EQUAL "${sha1}" "" is_bad) + if(is_bad) + hunter_gate_internal_error("sha1 is empty") + endif() + + string(SUBSTRING "${sha1}" 0 7 archive_id) + + if(EXISTS "${root}/cmake/Hunter") + set(hunter_self "${root}") + else() + set( + hunter_self + "${root}/_Base/Download/Hunter/${version}/${archive_id}/Unpacked" + ) + endif() + + set("${result}" "${hunter_self}" PARENT_SCOPE) +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) + 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) + 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) + 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) + 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) + set(HUNTER_GATE_ROOT "$ENV{USERPROFILE}/.hunter" PARENT_SCOPE) + hunter_gate_status_debug( + "HUNTER_ROOT set using USERPROFILE environment variable" + ) + return() + endif() + endif() + + hunter_gate_fatal_error( + "Can't detect HUNTER_ROOT" + WIKI "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 + NOTEQUAL + "$ENV{HUNTER_DISABLE_AUTOINSTALL}" + "" + disable_autoinstall + ) + if(disable_autoinstall AND NOT HUNTER_RUN_INSTALL) + hunter_gate_fatal_error( + "Hunter not found in '${dir}'" + "Set HUNTER_RUN_INSTALL=ON to auto-install it from '${HUNTER_GATE_URL}'" + "Settings:" + " HUNTER_ROOT: ${HUNTER_GATE_ROOT}" + " HUNTER_SHA1: ${HUNTER_GATE_SHA1}" + WIKI "error.run.install" + ) + endif() + string(COMPARE EQUAL "${dir}" "" is_bad) + if(is_bad) + hunter_gate_internal_error("Empty 'dir' argument") + endif() + + string(COMPARE EQUAL "${HUNTER_GATE_SHA1}" "" is_bad) + if(is_bad) + hunter_gate_internal_error("HUNTER_GATE_SHA1 empty") + endif() + + string(COMPARE EQUAL "${HUNTER_GATE_URL}" "" is_bad) + if(is_bad) + hunter_gate_internal_error("HUNTER_GATE_URL empty") + endif() + + set(done_location "${dir}/DONE") + set(sha1_location "${dir}/SHA1") + + set(build_dir "${dir}/Build") + set(cmakelists "${dir}/CMakeLists.txt") + + hunter_gate_lock("${dir}") + 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") + return() + endif() + + file(REMOVE_RECURSE "${build_dir}") + file(REMOVE_RECURSE "${cmakelists}") + + file(MAKE_DIRECTORY "${build_dir}") # check directory permissions + + # Disabling languages speeds up a little bit, reduces noise in the output + # and avoids path too long windows error + file( + WRITE + "${cmakelists}" + "cmake_minimum_required(VERSION 3.0)\n" + "project(HunterDownload LANGUAGES NONE)\n" + "include(ExternalProject)\n" + "ExternalProject_Add(\n" + " Hunter\n" + " URL\n" + " \"${HUNTER_GATE_URL}\"\n" + " URL_HASH\n" + " SHA1=${HUNTER_GATE_SHA1}\n" + " DOWNLOAD_DIR\n" + " \"${dir}\"\n" + " SOURCE_DIR\n" + " \"${dir}/Unpacked\"\n" + " CONFIGURE_COMMAND\n" + " \"\"\n" + " BUILD_COMMAND\n" + " \"\"\n" + " INSTALL_COMMAND\n" + " \"\"\n" + ")\n" + ) + + if(HUNTER_STATUS_DEBUG) + set(logging_params "") + else() + set(logging_params OUTPUT_QUIET) + endif() + + hunter_gate_status_debug("Run generate") + execute_process( + COMMAND "${CMAKE_COMMAND}" "-H${dir}" "-B${build_dir}" + WORKING_DIRECTORY "${dir}" + RESULT_VARIABLE download_result + ${logging_params} + ) + + if(NOT download_result EQUAL 0) + hunter_gate_internal_error("Configure project failed") + endif() + + hunter_gate_status_print( + "Initializing Hunter workspace (${HUNTER_GATE_SHA1})" + " ${HUNTER_GATE_URL}" + " -> ${dir}" + ) + execute_process( + COMMAND "${CMAKE_COMMAND}" --build "${build_dir}" + WORKING_DIRECTORY "${dir}" + RESULT_VARIABLE download_result + ${logging_params} + ) + + if(NOT download_result EQUAL 0) + hunter_gate_internal_error("Build project failed") + endif() + + file(REMOVE_RECURSE "${build_dir}") + file(REMOVE_RECURSE "${cmakelists}") + + file(WRITE "${sha1_location}" "${HUNTER_GATE_SHA1}") + file(WRITE "${done_location}" "DONE") + + hunter_gate_status_debug("Finished") +endfunction() + +# Must be a macro so master file 'cmake/Hunter' can +# apply all variables easily just by 'include' command +# (otherwise PARENT_SCOPE magic needed) +macro(HunterGate) + if(HUNTER_GATE_DONE) + # variable HUNTER_GATE_DONE set explicitly for external project + # (see `hunter_download`) + set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES) + endif() + + # First HunterGate command will init Hunter, others will be ignored + get_property(_hunter_gate_done GLOBAL PROPERTY HUNTER_GATE_DONE SET) + + if(NOT HUNTER_ENABLED) + # Empty function to avoid error "unknown function" + function(hunter_add_package) + endfunction() + elseif(_hunter_gate_done) + hunter_gate_status_debug("Secondary HunterGate (use old settings)") + hunter_gate_self( + "${HUNTER_CACHED_ROOT}" + "${HUNTER_VERSION}" + "${HUNTER_SHA1}" + _hunter_self + ) + include("${_hunter_self}/cmake/Hunter") + else() + set(HUNTER_GATE_LOCATION "${CMAKE_CURRENT_LIST_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" + ) + endif() + + cmake_parse_arguments( + HUNTER_GATE "LOCAL" "URL;SHA1;GLOBAL;FILEPATH" "" ${ARGV} + ) + + string(COMPARE EQUAL "${HUNTER_GATE_SHA1}" "" _empty_sha1) + string(COMPARE EQUAL "${HUNTER_GATE_URL}" "" _empty_url) + string( + COMPARE + NOTEQUAL + "${HUNTER_GATE_UNPARSED_ARGUMENTS}" + "" + _have_unparsed + ) + string(COMPARE NOTEQUAL "${HUNTER_GATE_GLOBAL}" "" _have_global) + string(COMPARE NOTEQUAL "${HUNTER_GATE_FILEPATH}" "" _have_filepath) + + if(_empty_sha1) + hunter_gate_user_error("SHA1 suboption of HunterGate is mandatory") + endif() + if(_empty_url) + hunter_gate_user_error("URL suboption of HunterGate is mandatory") + endif() + if(_have_unparsed) + hunter_gate_user_error( + "HunterGate unparsed arguments: ${HUNTER_GATE_UNPARSED_ARGUMENTS}" + ) + endif() + if(_have_global) + if(HUNTER_GATE_LOCAL) + hunter_gate_user_error("Unexpected LOCAL (already has GLOBAL)") + endif() + if(_have_filepath) + hunter_gate_user_error("Unexpected FILEPATH (already has GLOBAL)") + endif() + endif() + if(HUNTER_GATE_LOCAL) + if(_have_global) + hunter_gate_user_error("Unexpected GLOBAL (already has LOCAL)") + endif() + if(_have_filepath) + hunter_gate_user_error("Unexpected FILEPATH (already has LOCAL)") + endif() + endif() + if(_have_filepath) + if(_have_global) + hunter_gate_user_error("Unexpected GLOBAL (already has FILEPATH)") + endif() + if(HUNTER_GATE_LOCAL) + hunter_gate_user_error("Unexpected LOCAL (already has FILEPATH)") + endif() + endif() + + hunter_gate_detect_root() # set HUNTER_GATE_ROOT + + # Beautify path, fix probable problems with windows path slashes + get_filename_component( + HUNTER_GATE_ROOT "${HUNTER_GATE_ROOT}" ABSOLUTE + ) + hunter_gate_status_debug("HUNTER_ROOT: ${HUNTER_GATE_ROOT}") + if(NOT HUNTER_ALLOW_SPACES_IN_PATH) + string(FIND "${HUNTER_GATE_ROOT}" " " _contain_spaces) + if(NOT _contain_spaces EQUAL -1) + hunter_gate_fatal_error( + "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" + ) + endif() + endif() + + string( + REGEX + MATCH + "[0-9]+\\.[0-9]+\\.[0-9]+[-_a-z0-9]*" + HUNTER_GATE_VERSION + "${HUNTER_GATE_URL}" + ) + string(COMPARE EQUAL "${HUNTER_GATE_VERSION}" "" _is_empty) + if(_is_empty) + set(HUNTER_GATE_VERSION "unknown") + endif() + + hunter_gate_self( + "${HUNTER_GATE_ROOT}" + "${HUNTER_GATE_VERSION}" + "${HUNTER_GATE_SHA1}" + hunter_self_ + ) + + set(_master_location "${hunter_self_}/cmake/Hunter") + if(EXISTS "${HUNTER_GATE_ROOT}/cmake/Hunter") + # Hunter downloaded manually (e.g. by 'git clone') + set(_unused "xxxxxxxxxx") + set(HUNTER_GATE_SHA1 "${_unused}") + set(HUNTER_GATE_VERSION "${_unused}") + else() + get_filename_component(_archive_id_location "${hunter_self_}/.." ABSOLUTE) + set(_done_location "${_archive_id_location}/DONE") + set(_sha1_location "${_archive_id_location}/SHA1") + + # Check Hunter already downloaded by HunterGate + if(NOT EXISTS "${_done_location}") + hunter_gate_download("${_archive_id_location}") + endif() + + if(NOT EXISTS "${_done_location}") + hunter_gate_internal_error("hunter_gate_download failed") + endif() + + if(NOT EXISTS "${_sha1_location}") + 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) + if(NOT _is_equal) + hunter_gate_internal_error( + "Short SHA1 collision:" + " ${_sha1_value} (from ${_sha1_location})" + " ${HUNTER_GATE_SHA1} (HunterGate)" + ) + endif() + if(NOT EXISTS "${_master_location}") + hunter_gate_user_error( + "Master file not found:" + " ${_master_location}" + "try to update Hunter/HunterGate" + ) + endif() + endif() + include("${_master_location}") + set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES) + endif() +endmacro() From 83c23d39e896bbfd42fa49698ccb65169dd96854 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Sat, 16 May 2015 20:41:20 +0200 Subject: [PATCH 02/25] Use HunterGate (without packages) --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c639e6067c16..3afc5ee24149 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,7 +130,11 @@ if(DEFINED CMAKE_BUILD_TYPE) set_property( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES} ) endif() -enable_testing() +include("cmake/HunterGate.cmake") +HunterGate( + URL "https://github.com/ruslo/hunter/archive/v0.10.4.tar.gz" + SHA1 "603c2b5f10c5b6e50628cd0b0cc5c1167cb36bfc" +) project(OpenCV CXX C) From bd288cdddb131aebcbf57b2b9db9916c153dd8f0 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Sat, 16 May 2015 22:02:02 +0200 Subject: [PATCH 03/25] hunter_add_package: ZLIB, TIFF, PNG, ippicv --- 3rdparty/ippicv/ippicv.cmake | 7 ++++++- cmake/OpenCVFindLibsGrfmt.cmake | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/3rdparty/ippicv/ippicv.cmake b/3rdparty/ippicv/ippicv.cmake index ae8748c28349..7a7fda4066f1 100644 --- a/3rdparty/ippicv/ippicv.cmake +++ b/3rdparty/ippicv/ippicv.cmake @@ -14,7 +14,7 @@ function(download_ippicv root_var) set(OPENCV_ICV_NAME "ippicv_2019_mac_ia32_general_20180723.tgz") set(OPENCV_ICV_HASH "b5dfa78c87eb75c64470cbe5ec876f4f") endif() - elseif((UNIX AND NOT ANDROID) OR (UNIX AND ANDROID_ABI MATCHES "x86")) + elseif((UNIX AND NOT ANDROID) OR (UNIX AND CMAKE_ANDROID_ARCH MATCHES "x86")) set(OPENCV_ICV_PLATFORM "linux") set(OPENCV_ICV_PACKAGE_SUBDIR "ippicv_lnx") if(X86_64) @@ -38,6 +38,11 @@ function(download_ippicv root_var) return() endif() + if(HUNTER_ENABLED) + hunter_add_package(ippicv) + set(OPENCV_ICV_URL "file://${IPPICV_ROOT}") + endif() + set(THE_ROOT "${OpenCV_BINARY_DIR}/3rdparty/ippicv") ocv_download(FILENAME ${OPENCV_ICV_NAME} HASH ${OPENCV_ICV_HASH} diff --git a/cmake/OpenCVFindLibsGrfmt.cmake b/cmake/OpenCVFindLibsGrfmt.cmake index 9f18e2bf6279..ea8b73307036 100644 --- a/cmake/OpenCVFindLibsGrfmt.cmake +++ b/cmake/OpenCVFindLibsGrfmt.cmake @@ -6,6 +6,7 @@ if(BUILD_ZLIB) ocv_clear_vars(ZLIB_FOUND) else() + hunter_add_package(ZLIB) find_package(ZLIB "${MIN_VER_ZLIB}") if(ZLIB_FOUND AND ANDROID) if(ZLIB_LIBRARIES MATCHES "/usr/(lib|lib32|lib64)/libz.so$") @@ -74,6 +75,7 @@ if(WITH_TIFF) if(BUILD_TIFF) ocv_clear_vars(TIFF_FOUND) else() + hunter_add_package(TIFF) include(FindTIFF) if(TIFF_FOUND) ocv_parse_header("${TIFF_INCLUDE_DIR}/tiff.h" TIFF_VERSION_LINES TIFF_VERSION_CLASSIC TIFF_VERSION_BIG TIFF_VERSION TIFF_BIGTIFF_VERSION) @@ -182,6 +184,7 @@ if(WITH_PNG) if(BUILD_PNG) ocv_clear_vars(PNG_FOUND) else() + hunter_add_package(PNG) include(FindPNG) if(PNG_FOUND) include(CheckIncludeFile) From aa24958e5367422cce7698dc8261c7fbc90bf319 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Fri, 15 May 2015 17:54:57 +0200 Subject: [PATCH 04/25] Force empty CMAKE_SYSTEM_PROCESSOR on iOS build Support for polly iOS toolchain --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3afc5ee24149..25e9352361fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,6 +138,10 @@ HunterGate( project(OpenCV CXX C) +if(IOS) + set(CMAKE_SYSTEM_PROCESSOR "") +endif() + if(MSVC) set(CMAKE_USE_RELATIVE_PATHS ON CACHE INTERNAL "" FORCE) endif() From 83a742a22d28488baf7d62ee56f6cfc226385b76 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Fri, 15 May 2015 18:30:47 +0200 Subject: [PATCH 05/25] Set CMAKE_CXX_FLAGS_RELEASE for iOS Support for polly iOS toolchain --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 25e9352361fc..d30db00d3262 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,6 +140,7 @@ project(OpenCV CXX C) if(IOS) set(CMAKE_SYSTEM_PROCESSOR "") + set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3 -fomit-frame-pointer -ffast-math") endif() if(MSVC) From 0bf8114c7df748fa536000acebacbb2d9a1dc708 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Sat, 16 May 2015 22:20:20 +0200 Subject: [PATCH 06/25] Add find_dependency to config (ZLIB, TIFF, PNG) Fix: https://github.com/ruslo/hunter/issues/81 --- cmake/templates/OpenCVConfig.cmake.in | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cmake/templates/OpenCVConfig.cmake.in b/cmake/templates/OpenCVConfig.cmake.in index fefa359e0a9d..cb7c4e4df55a 100644 --- a/cmake/templates/OpenCVConfig.cmake.in +++ b/cmake/templates/OpenCVConfig.cmake.in @@ -313,3 +313,17 @@ endmacro() # installation directory for the status. find_package_handle_standard_args(OpenCV REQUIRED_VARS OpenCV_INSTALL_PATH VERSION_VAR OpenCV_VERSION ${_OpenCV_FPHSA_ARGS}) + +include(CMakeFindDependencyMacro) + +if("@ZLIB_FOUND@") + find_dependency(ZLIB CONFIG) +endif() + +if("@TIFF_FOUND@") + find_dependency(TIFF CONFIG) +endif() + +if("@PNG_FOUND@") + find_dependency(PNG CONFIG) +endif() From ab253676504125adf1e01b360168d14977dc971b Mon Sep 17 00:00:00 2001 From: David Hirvonen Date: Fri, 26 Jun 2015 08:59:34 +0300 Subject: [PATCH 07/25] CMake touch ups for BUILD_opencv_world=ON --- modules/world/CMakeLists.txt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/modules/world/CMakeLists.txt b/modules/world/CMakeLists.txt index 269beb7bc302..4efc1232d769 100644 --- a/modules/world/CMakeLists.txt +++ b/modules/world/CMakeLists.txt @@ -70,3 +70,27 @@ endif() if(BUILD_opencv_highgui AND OPENCV_MODULE_opencv_highgui_IS_PART_OF_WORLD) ocv_highgui_configure_target() endif() + +if(IOS OR APPLE) + set(merge_libs "") + macro(ios_include_3party_libs) + foreach(l ${ARGN}) + add_dependencies(${the_module} ${l}) + list(APPEND merge_libs "$") + endforeach() + endmacro() + + if(WITH_PNG) + ios_include_3party_libs(${ZLIB_LIBRARIES} ${PNG_LIBRARIES}) + endif() + + if(WITH_JPEG) + ios_include_3party_libs(${JPEG_LIBRARIES}) + endif() + + add_custom_command(TARGET ${the_module} POST_BUILD + COMMAND /usr/bin/libtool -static -o ${CMAKE_CURRENT_BINARY_DIR}/${the_module}_fat.a $ ${merge_libs} + COMMAND mv ${CMAKE_CURRENT_BINARY_DIR}/${the_module}_fat.a $ + ) +endif() + From 4ad25906c63bd2dda784e88028040c5527c76bb8 Mon Sep 17 00:00:00 2001 From: David Hirvonen Date: Tue, 30 Jun 2015 19:55:58 -0400 Subject: [PATCH 08/25] Fix OpenCV_LIBS for when building opencv_world --- cmake/templates/OpenCVConfig.cmake.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/templates/OpenCVConfig.cmake.in b/cmake/templates/OpenCVConfig.cmake.in index cb7c4e4df55a..d1904757400e 100644 --- a/cmake/templates/OpenCVConfig.cmake.in +++ b/cmake/templates/OpenCVConfig.cmake.in @@ -250,8 +250,8 @@ foreach(__cvcomponent ${OpenCV_FIND_COMPONENTS}) endif() endforeach() -if(__remap_warnings AND NOT OpenCV_FIND_QUIETLY) - message("OpenCV: configurations remap warnings:\n${__remap_warnings}OpenCV: Check variable OPENCV_MAP_IMPORTED_CONFIG=${OPENCV_MAP_IMPORTED_CONFIG}") +if(TARGET opencv_world) + set(OpenCV_LIBS opencv_world) endif() # ============================================================== From 5ff2468ad266bf682a91af49b4b72a9f2762a635 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Sat, 11 Jul 2015 22:52:07 +0300 Subject: [PATCH 09/25] Add OPENCV_WITH_EXTRA_MODULES option Fix issue https://github.com/ruslo/hunter/issues/167 --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d30db00d3262..88640206a2b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -690,6 +690,10 @@ ocv_include_directories(${OPENCV_CONFIG_FILE_INCLUDE_DIR}) # Path for additional modules # ---------------------------------------------------------------------------- set(OPENCV_EXTRA_MODULES_PATH "" CACHE PATH "Where to look for additional OpenCV modules (can be ;-separated list of paths)") +if(OPENCV_WITH_EXTRA_MODULES) + hunter_add_package(OpenCV-Extra) + set(OPENCV_EXTRA_MODULES_PATH "${OPENCV-EXTRA_ROOT}/modules") +endif() # ---------------------------------------------------------------------------- # Autodetect if we are in a GIT repository From 9632abc57ba69d8aba9bd9f98c86d8a294cb4f57 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Sat, 11 Jul 2015 23:49:03 +0300 Subject: [PATCH 10/25] Use Eigen from Hunter Fix issue https://github.com/ruslo/hunter/issues/192 --- cmake/OpenCVFindLibsPerf.cmake | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/cmake/OpenCVFindLibsPerf.cmake b/cmake/OpenCVFindLibsPerf.cmake index 8b91a2d739b1..75dab6aa88e2 100644 --- a/cmake/OpenCVFindLibsPerf.cmake +++ b/cmake/OpenCVFindLibsPerf.cmake @@ -41,11 +41,21 @@ endif(WITH_CUDA) # --- Eigen --- if(WITH_EIGEN) - find_path(EIGEN_INCLUDE_PATH "Eigen/Core" - PATHS /usr/local /opt /usr $ENV{EIGEN_ROOT}/include ENV ProgramFiles ENV ProgramW6432 - PATH_SUFFIXES include/eigen3 include/eigen2 Eigen/include/eigen3 Eigen/include/eigen2 - DOC "The path to Eigen3/Eigen2 headers" - CMAKE_FIND_ROOT_PATH_BOTH) + if(HUNTER_ENABLED) + hunter_add_package(Eigen) + find_package(Eigen REQUIRED) + get_target_property( + EIGEN_INCLUDE_PATH + Eigen::eigen + INTERFACE_INCLUDE_DIRECTORIES + ) + else() + find_path(EIGEN_INCLUDE_PATH "Eigen/Core" + PATHS /usr/local /opt /usr $ENV{EIGEN_ROOT}/include ENV ProgramFiles ENV ProgramW6432 + PATH_SUFFIXES include/eigen3 include/eigen2 Eigen/include/eigen3 Eigen/include/eigen2 + DOC "The path to Eigen3/Eigen2 headers" + CMAKE_FIND_ROOT_PATH_BOTH) + endif() if(EIGEN_INCLUDE_PATH) ocv_include_directories(${EIGEN_INCLUDE_PATH}) From 75b1b2b69df3b17bec08c054c90b519a5b7d4fc7 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Mon, 21 Mar 2016 18:23:03 +0700 Subject: [PATCH 11/25] Add Jpeg from Hunter --- cmake/OpenCVFindLibsGrfmt.cmake | 1 + cmake/templates/OpenCVConfig.cmake.in | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/cmake/OpenCVFindLibsGrfmt.cmake b/cmake/OpenCVFindLibsGrfmt.cmake index ea8b73307036..402a4ff2e40f 100644 --- a/cmake/OpenCVFindLibsGrfmt.cmake +++ b/cmake/OpenCVFindLibsGrfmt.cmake @@ -31,6 +31,7 @@ if(WITH_JPEG) if(BUILD_JPEG) ocv_clear_vars(JPEG_FOUND) else() + hunter_add_package(Jpeg) include(FindJPEG) endif() diff --git a/cmake/templates/OpenCVConfig.cmake.in b/cmake/templates/OpenCVConfig.cmake.in index d1904757400e..ae2db05c150f 100644 --- a/cmake/templates/OpenCVConfig.cmake.in +++ b/cmake/templates/OpenCVConfig.cmake.in @@ -327,3 +327,7 @@ endif() if("@PNG_FOUND@") find_dependency(PNG CONFIG) endif() + +if("@JPEG_FOUND@") + find_dependency(JPEG CONFIG) +endif() From f3f5adbb710a4f5ef57c5e639bc431b9e6495e1d Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Mon, 21 Mar 2016 18:26:34 +0700 Subject: [PATCH 12/25] Update Hunter --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 88640206a2b5..4b9e679bbd40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -132,8 +132,8 @@ endif() include("cmake/HunterGate.cmake") HunterGate( - URL "https://github.com/ruslo/hunter/archive/v0.10.4.tar.gz" - SHA1 "603c2b5f10c5b6e50628cd0b0cc5c1167cb36bfc" + URL "https://github.com/ruslo/hunter/archive/v0.14.4.tar.gz" + SHA1 "7a8ec9a01204a294e44de37e800db41fda477af2" ) project(OpenCV CXX C) From ff0fd33bc99b29f3962463a90497077790ce8367 Mon Sep 17 00:00:00 2001 From: Alexandre Pretyman Date: Tue, 22 Mar 2016 23:38:54 -0400 Subject: [PATCH 13/25] Added the Qt backend with static link support When static linking, Qt resources must the initialized manually The file static_opencv_qt_resources.cpp initializes the resources for the highgui icons. This patch uses the QtCMakeExtra Hunter project to add it as an interface source file. --- cmake/OpenCVFindLibsGUI.cmake | 1 + cmake/templates/OpenCVConfig.cmake.in | 33 +++++++++++++++++++ modules/highgui/CMakeLists.txt | 11 +++++++ .../highgui/static_opencv_qt_resources.cpp | 22 +++++++++++++ 4 files changed, 67 insertions(+) create mode 100644 modules/highgui/static_opencv_qt_resources.cpp diff --git a/cmake/OpenCVFindLibsGUI.cmake b/cmake/OpenCVFindLibsGUI.cmake index efabb3ce158c..7f297393ab7a 100644 --- a/cmake/OpenCVFindLibsGUI.cmake +++ b/cmake/OpenCVFindLibsGUI.cmake @@ -15,6 +15,7 @@ endif() ocv_clear_vars(HAVE_QT HAVE_QT5) if(WITH_QT) if(NOT WITH_QT EQUAL 4) + hunter_add_package(Qt) find_package(Qt5Core) find_package(Qt5Gui) find_package(Qt5Widgets) diff --git a/cmake/templates/OpenCVConfig.cmake.in b/cmake/templates/OpenCVConfig.cmake.in index ae2db05c150f..5039cc3a4473 100644 --- a/cmake/templates/OpenCVConfig.cmake.in +++ b/cmake/templates/OpenCVConfig.cmake.in @@ -331,3 +331,36 @@ endif() if("@JPEG_FOUND@") find_dependency(JPEG CONFIG) endif() + +# AWP: Qt5 dependencies -- start +if("@Qt5Core_FOUND@") + find_dependency(Qt5Core) +endif() + +if("@Qt5Gui_FOUND@") + find_dependency(Qt5Gui) +endif() + +if("@Qt5Widgets_FOUND@") + find_dependency(Qt5Widgets) + if(NOT "@BUILD_SHARED_LIBS@") + # function from Hunter's QtCMakeExtra project + _qt_cmake_extra_helpers_add_source( + opencv_highgui "static_opencv_qt_resources.cpp" + ) + endif() +endif() + +if("@Qt5Test_FOUND@") + find_dependency(Qt5Test) +endif() + +if("@Qt5Concurrent_FOUND@") + find_dependency(Qt5Concurrent) +endif() + +if("@Qt5OpenGL_FOUND@") + find_dependency(Qt5OpenGL) +endif() +# AWP: Qt5 dependencies -- end + diff --git a/modules/highgui/CMakeLists.txt b/modules/highgui/CMakeLists.txt index af54d9c3a085..ed309846ad9b 100644 --- a/modules/highgui/CMakeLists.txt +++ b/modules/highgui/CMakeLists.txt @@ -55,6 +55,17 @@ if(HAVE_QT5) ${_MOC_OUTFILES} ${_RCC_OUTFILES}) + # Hunter patch to load qt resources when static linking + # Hunter has only Qt5, so its guarded by if(HAVE_QT5) + if(NOT BUILD_SHARED_LIBS) + install( + FILES + ${CMAKE_CURRENT_LIST_DIR}/static_opencv_qt_resources.cpp + DESTINATION + "src/qt/plugins" + ) + endif() + foreach(dt5_dep Core Gui Widgets Test Concurrent) add_definitions(${Qt5${dt5_dep}_DEFINITIONS}) include_directories(${Qt5${dt5_dep}_INCLUDE_DIRS}) diff --git a/modules/highgui/static_opencv_qt_resources.cpp b/modules/highgui/static_opencv_qt_resources.cpp new file mode 100644 index 000000000000..35c489436dcb --- /dev/null +++ b/modules/highgui/static_opencv_qt_resources.cpp @@ -0,0 +1,22 @@ +/** + * Part of the Hunter patch for static linking OpenCV with Qt + * Initializes the resources for the highgui window icons + */ + +#include + +inline void static_opencv_qt_resources() { + Q_INIT_RESOURCE(window_QT); +} + +namespace { + + struct static_opencv_qt_resources_initializer{ + static_opencv_qt_resources_initializer() { + static_opencv_qt_resources(); + } + }; + + static_opencv_qt_resources_initializer global_instance; +} + From a2ba272fa58a618a269adb3c072c4d083fd8ac37 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Sat, 24 Dec 2016 01:06:29 +0800 Subject: [PATCH 14/25] New Eigen interface --- cmake/OpenCVFindLibsPerf.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/OpenCVFindLibsPerf.cmake b/cmake/OpenCVFindLibsPerf.cmake index 75dab6aa88e2..06ec5adc7ae8 100644 --- a/cmake/OpenCVFindLibsPerf.cmake +++ b/cmake/OpenCVFindLibsPerf.cmake @@ -43,10 +43,10 @@ endif(WITH_CUDA) if(WITH_EIGEN) if(HUNTER_ENABLED) hunter_add_package(Eigen) - find_package(Eigen REQUIRED) + find_package(Eigen3 CONFIG REQUIRED) get_target_property( EIGEN_INCLUDE_PATH - Eigen::eigen + Eigen3::Eigen INTERFACE_INCLUDE_DIRECTORIES ) else() From 30e774b1223359da6fd344b69967b6acba7e9b4f Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Sat, 24 Dec 2016 01:07:28 +0800 Subject: [PATCH 15/25] Update Hunter --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b9e679bbd40..35ef0d9cecdf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -132,8 +132,8 @@ endif() include("cmake/HunterGate.cmake") HunterGate( - URL "https://github.com/ruslo/hunter/archive/v0.14.4.tar.gz" - SHA1 "7a8ec9a01204a294e44de37e800db41fda477af2" + URL "https://github.com/ruslo/hunter/archive/v0.17.7.tar.gz" + SHA1 "78219f42c3737adcc161c52b9f71ce65a3d775c2" ) project(OpenCV CXX C) From 0af2bdb315cc735f2f0543767aeac1d6933af1cb Mon Sep 17 00:00:00 2001 From: Sacha Date: Tue, 4 Apr 2017 11:48:32 +1000 Subject: [PATCH 16/25] Rename ANDROID_ vars to CMAKE_ vars. --- CMakeLists.txt | 19 ++++++++----------- cmake/OpenCVGenAndroidMK.cmake | 6 +++--- cmake/OpenCVGenConfig.cmake | 6 +++--- cmake/android/android_ant_projects.cmake | 12 ++++++------ cmake/templates/OpenCVConfig-ANDROID.cmake.in | 2 +- .../OpenCVConfig.root-ANDROID.cmake.in | 2 +- modules/java/CMakeLists.txt | 3 +-- modules/ts/misc/run_utils.py | 2 +- 8 files changed, 24 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 35ef0d9cecdf..b1bc6b688652 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -526,12 +526,9 @@ ocv_cmake_hook(POST_OPTIONS) set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin" CACHE PATH "Output directory for applications") if(ANDROID) - if(ANDROID_ABI MATCHES "NEON") + if(CMAKE_ANDROID_ARM_NEON) set(ENABLE_NEON ON) endif() - if(ANDROID_ABI MATCHES "VFPV3") - set(ENABLE_VFPV3 ON) - endif() endif() if(ANDROID OR WIN32) @@ -554,13 +551,13 @@ else() endif() if(ANDROID) - ocv_update(OPENCV_SAMPLES_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}samples/${ANDROID_NDK_ABI_NAME}") + ocv_update(OPENCV_SAMPLES_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}samples/${CMAKE_ANDROID_ARCH_ABI}") else() ocv_update(OPENCV_SAMPLES_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}samples") endif() if(ANDROID) - ocv_update(OPENCV_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}bin/${ANDROID_NDK_ABI_NAME}") + ocv_update(OPENCV_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}bin/${CMAKE_ANDROID_ARCH_ABI}") else() ocv_update(OPENCV_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}bin") endif() @@ -582,11 +579,11 @@ else() endif() if(ANDROID) - set(LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/lib/${ANDROID_NDK_ABI_NAME}") - ocv_update(3P_LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/3rdparty/lib/${ANDROID_NDK_ABI_NAME}") - ocv_update(OPENCV_LIB_INSTALL_PATH sdk/native/libs/${ANDROID_NDK_ABI_NAME}) - ocv_update(OPENCV_LIB_ARCHIVE_INSTALL_PATH sdk/native/staticlibs/${ANDROID_NDK_ABI_NAME}) - ocv_update(OPENCV_3P_LIB_INSTALL_PATH sdk/native/3rdparty/libs/${ANDROID_NDK_ABI_NAME}) + set(LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/lib/${CMAKE_ANDROID_ARCH_ABI}") + ocv_update(3P_LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/3rdparty/lib/${CMAKE_ANDROID_ARCH_ABI}") + ocv_update(OPENCV_LIB_INSTALL_PATH sdk/native/libs/${CMAKE_ANDROID_ARCH_ABI}) + ocv_update(OPENCV_LIB_ARCHIVE_INSTALL_PATH sdk/native/staticlibs/${CMAKE_ANDROID_ARCH_ABI}) + ocv_update(OPENCV_3P_LIB_INSTALL_PATH sdk/native/3rdparty/libs/${CMAKE_ANDROID_ARCH_ABI}) ocv_update(OPENCV_CONFIG_INSTALL_PATH sdk/native/jni) ocv_update(OPENCV_INCLUDE_INSTALL_PATH sdk/native/jni/include) ocv_update(OPENCV_SAMPLES_SRC_INSTALL_PATH samples/native) diff --git a/cmake/OpenCVGenAndroidMK.cmake b/cmake/OpenCVGenAndroidMK.cmake index 832ed6753393..9072ba0c8735 100644 --- a/cmake/OpenCVGenAndroidMK.cmake +++ b/cmake/OpenCVGenAndroidMK.cmake @@ -63,7 +63,7 @@ if(ANDROID) set(OPENCV_3RDPARTY_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/3rdparty/lib/\$(OPENCV_TARGET_ARCH_ABI)") configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCV.mk.in" "${CMAKE_BINARY_DIR}/OpenCV.mk" @ONLY) - configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCV-abi.mk.in" "${CMAKE_BINARY_DIR}/OpenCV-${ANDROID_NDK_ABI_NAME}.mk" @ONLY) + configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCV-abi.mk.in" "${CMAKE_BINARY_DIR}/OpenCV-${CMAKE_ANDROID_ARCH_ABI}.mk" @ONLY) # ------------------------------------------------------------------------------------------- # Part 2/2: ${BIN_DIR}/unix-install/OpenCV.mk -> For use with "make install" @@ -75,7 +75,7 @@ if(ANDROID) set(OPENCV_3RDPARTY_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/../3rdparty/libs/\$(OPENCV_TARGET_ARCH_ABI)") configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCV.mk.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCV.mk" @ONLY) - configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCV-abi.mk.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCV-${ANDROID_NDK_ABI_NAME}.mk" @ONLY) + configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCV-abi.mk.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCV-${CMAKE_ANDROID_ARCH_ABI}.mk" @ONLY) install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCV.mk DESTINATION ${OPENCV_CONFIG_INSTALL_PATH} COMPONENT dev) - install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCV-${ANDROID_NDK_ABI_NAME}.mk DESTINATION ${OPENCV_CONFIG_INSTALL_PATH} COMPONENT dev) + install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCV-${CMAKE_ANDROID_ARCH_ABI}.mk DESTINATION ${OPENCV_CONFIG_INSTALL_PATH} COMPONENT dev) endif(ANDROID) diff --git a/cmake/OpenCVGenConfig.cmake b/cmake/OpenCVGenConfig.cmake index b2ca82bad071..1223a40407b9 100644 --- a/cmake/OpenCVGenConfig.cmake +++ b/cmake/OpenCVGenConfig.cmake @@ -16,10 +16,10 @@ if(HAVE_CUDA) endif() if(ANDROID) - if(NOT ANDROID_NATIVE_API_LEVEL) + if(NOT CMAKE_SYSTEM_VERSION) set(OpenCV_ANDROID_NATIVE_API_LEVEL_CONFIGCMAKE 0) else() - set(OpenCV_ANDROID_NATIVE_API_LEVEL_CONFIGCMAKE "${ANDROID_NATIVE_API_LEVEL}") + set(OpenCV_ANDROID_NATIVE_API_LEVEL_CONFIGCMAKE "${CMAKE_SYSTEM_VERSION}") endif() ocv_cmake_configure("${CMAKE_CURRENT_LIST_DIR}/templates/OpenCVConfig-ANDROID.cmake.in" ANDROID_CONFIGCMAKE @ONLY) endif() @@ -110,7 +110,7 @@ if((CMAKE_HOST_SYSTEM_NAME MATCHES "Linux" OR UNIX) AND NOT ANDROID) endif() if(ANDROID) - ocv_gen_config("${CMAKE_BINARY_DIR}/unix-install" "abi-${ANDROID_NDK_ABI_NAME}" "OpenCVConfig.root-ANDROID.cmake.in") + ocv_gen_config("${CMAKE_BINARY_DIR}/unix-install" "abi-${CMAKE_ANDROID_ARCH_ABI}" "OpenCVConfig.root-ANDROID.cmake.in") install(FILES "${OpenCV_SOURCE_DIR}/platforms/android/android.toolchain.cmake" DESTINATION "${OPENCV_CONFIG_INSTALL_PATH}" COMPONENT dev) endif() diff --git a/cmake/android/android_ant_projects.cmake b/cmake/android/android_ant_projects.cmake index ed9ce43582e5..7b96c915dbce 100644 --- a/cmake/android/android_ant_projects.cmake +++ b/cmake/android/android_ant_projects.cmake @@ -110,10 +110,10 @@ macro(add_android_project target path) endforeach() # get compatible SDK target - android_get_compatible_target(android_proj_sdk_target ${ANDROID_NATIVE_API_LEVEL} ${android_proj_SDK_TARGET}) + android_get_compatible_target(android_proj_sdk_target ${CMAKE_SYSTEM_VERSION} ${android_proj_SDK_TARGET}) if(NOT android_proj_sdk_target) - message(WARNING "Can not find any SDK target compatible with: ${ANDROID_NATIVE_API_LEVEL} ${android_proj_SDK_TARGET} + message(WARNING "Can not find any SDK target compatible with: ${CMAKE_SYSTEM_VERSION} ${android_proj_SDK_TARGET} The project ${target} will not be build") endif() @@ -128,7 +128,7 @@ macro(add_android_project target path) # find if native_app_glue is used file(STRINGS "${path}/jni/Android.mk" NATIVE_APP_GLUE REGEX ".*(call import-module,android/native_app_glue)" ) if(NATIVE_APP_GLUE) - if(ANDROID_NATIVE_API_LEVEL LESS 9 OR NOT EXISTS "${ANDROID_NDK}/sources/android/native_app_glue") + if(CMAKE_SYSTEM_VERSION LESS 9 OR NOT EXISTS "${CMAKE_ANDROID_NDK}/sources/android/native_app_glue") set(OCV_DEPENDENCIES_FOUND FALSE) endif() endif() @@ -185,8 +185,8 @@ macro(add_android_project target path) if(JNI_LIB_NAME) if(NATIVE_APP_GLUE) - include_directories(${ANDROID_NDK}/sources/android/native_app_glue) - list(APPEND android_proj_jni_files ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + include_directories(${CMAKE_ANDROID_NDK}/sources/android/native_app_glue) + list(APPEND android_proj_jni_files ${CMAKE_ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) ocv_warnings_disable(CMAKE_C_FLAGS -Wstrict-prototypes -Wunused-parameter -Wmissing-prototypes) set(android_proj_NATIVE_DEPS ${android_proj_NATIVE_DEPS} android) endif() @@ -198,7 +198,7 @@ macro(add_android_project target path) set_target_properties(${JNI_LIB_NAME} PROPERTIES OUTPUT_NAME "${JNI_LIB_NAME}" - LIBRARY_OUTPUT_DIRECTORY "${android_proj_bin_dir}/libs/${ANDROID_NDK_ABI_NAME}" + LIBRARY_OUTPUT_DIRECTORY "${android_proj_bin_dir}/libs/${CMAKE_ANDROID_ARCH_ABI}" ) if (NOT (CMAKE_BUILD_TYPE MATCHES "debug")) diff --git a/cmake/templates/OpenCVConfig-ANDROID.cmake.in b/cmake/templates/OpenCVConfig-ANDROID.cmake.in index 1787acab3883..b2033da7951c 100644 --- a/cmake/templates/OpenCVConfig-ANDROID.cmake.in +++ b/cmake/templates/OpenCVConfig-ANDROID.cmake.in @@ -4,7 +4,7 @@ set(OpenCV_ANDROID_NATIVE_API_LEVEL "@OpenCV_ANDROID_NATIVE_API_LEVEL_CONFIGCMAK # ============================================================== # Check OpenCV availability # ============================================================== -if(OpenCV_ANDROID_NATIVE_API_LEVEL GREATER ANDROID_NATIVE_API_LEVEL) +if(OpenCV_ANDROID_NATIVE_API_LEVEL GREATER CMAKE_SYSTEM_VERSION) if(NOT OpenCV_FIND_QUIETLY) message(WARNING "Minimum required by OpenCV API level is android-${OpenCV_ANDROID_NATIVE_API_LEVEL}") endif() diff --git a/cmake/templates/OpenCVConfig.root-ANDROID.cmake.in b/cmake/templates/OpenCVConfig.root-ANDROID.cmake.in index 7ceeec4c7f93..23797b0e4a8e 100644 --- a/cmake/templates/OpenCVConfig.root-ANDROID.cmake.in +++ b/cmake/templates/OpenCVConfig.root-ANDROID.cmake.in @@ -36,7 +36,7 @@ if(CMAKE_VERSION VERSION_LESS "2.8.3") endif() if(NOT DEFINED OpenCV_CONFIG_SUBDIR) - set(OpenCV_CONFIG_SUBDIR "/abi-${ANDROID_NDK_ABI_NAME}") + set(OpenCV_CONFIG_SUBDIR "/abi-${CMAKE_ANDROID_ARCH_ABI}") endif() set(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_DIR}${OpenCV_CONFIG_SUBDIR}") diff --git a/modules/java/CMakeLists.txt b/modules/java/CMakeLists.txt index 8cc4bd07a652..a4e68e3bf94f 100644 --- a/modules/java/CMakeLists.txt +++ b/modules/java/CMakeLists.txt @@ -4,7 +4,7 @@ if(OPENCV_INITIAL_PASS) endif() if(APPLE_FRAMEWORK OR WINRT OR NOT PYTHON_DEFAULT_AVAILABLE OR NOT ANT_EXECUTABLE - OR NOT (JNI_FOUND OR (ANDROID AND ANDROID_NATIVE_API_LEVEL GREATER 7)) + OR NOT (JNI_FOUND OR (ANDROID AND CMAKE_SYSTEM_VERSION GREATER 7)) OR BUILD_opencv_world ) ocv_module_disable(java) @@ -54,7 +54,6 @@ macro(copy_common_tests _src_location _dst_location _deps) unset(_dst) endmacro() - add_subdirectory(jni) # generates ${the_module} target (${the_module}_jni doesn't work properly with Android samples) if(ANDROID) add_subdirectory(android_sdk) # generates ${the_module}_android target diff --git a/modules/ts/misc/run_utils.py b/modules/ts/misc/run_utils.py index 4fc84cc8efeb..5dfaa1fcc518 100644 --- a/modules/ts/misc/run_utils.py +++ b/modules/ts/misc/run_utils.py @@ -76,7 +76,7 @@ def getPlatformVersion(): {'name': "opencv_build", 'default': None, 'pattern': re.compile(r"^OpenCV_BINARY_DIR:\w+=(.+)$")}, {'name': "tests_dir", 'default': None, 'pattern': re.compile(r"^EXECUTABLE_OUTPUT_PATH:\w+=(.+)$")}, {'name': "build_type", 'default': "Release", 'pattern': re.compile(r"^CMAKE_BUILD_TYPE:\w+=(.*)$")}, - {'name': "android_abi", 'default': None, 'pattern': re.compile(r"^ANDROID_ABI:\w+=(.*)$")}, + {'name': "android_abi", 'default': None, 'pattern': re.compile(r"^CMAKE_ANDROID_ARCH_ABI:\w+=(.*)$")}, {'name': "android_executable", 'default': None, 'pattern': re.compile(r"^ANDROID_EXECUTABLE:\w+=(.*android.*)$")}, {'name': "ant_executable", 'default': None, 'pattern': re.compile(r"^ANT_EXECUTABLE:\w+=(.*ant.*)$")}, {'name': "java_test_dir", 'default': None, 'pattern': re.compile(r"^OPENCV_JAVA_TEST_DIR:\w+=(.*)$")}, From cb64714aadf81d4230ebb702c1b4e2e6cf96c5bf Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Mon, 14 Aug 2017 16:31:47 +0300 Subject: [PATCH 17/25] Update Hunter --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b1bc6b688652..26d4be19059f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -132,8 +132,8 @@ endif() include("cmake/HunterGate.cmake") HunterGate( - URL "https://github.com/ruslo/hunter/archive/v0.17.7.tar.gz" - SHA1 "78219f42c3737adcc161c52b9f71ce65a3d775c2" + URL "https://github.com/ruslo/hunter/archive/v0.19.68.tar.gz" + SHA1 "ad0d042d8ec56a3c6a4bda1e657f1f65b494ab12" ) project(OpenCV CXX C) From 34f85dba33bedd46775d466aa634932aede5931c Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Mon, 14 Aug 2017 16:32:05 +0300 Subject: [PATCH 18/25] Fix iOS build --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 26d4be19059f..694bf18a1d3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,7 +139,6 @@ HunterGate( project(OpenCV CXX C) if(IOS) - set(CMAKE_SYSTEM_PROCESSOR "") set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3 -fomit-frame-pointer -ffast-math") endif() From 015a2a3dc6376765baf80979b88f6e8256fe7427 Mon Sep 17 00:00:00 2001 From: Alexandre Pretyman Date: Fri, 17 Nov 2017 14:19:24 -0200 Subject: [PATCH 19/25] Added target Qt5::Widgets to opencv_highgui target --- cmake/templates/OpenCVConfig.cmake.in | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/templates/OpenCVConfig.cmake.in b/cmake/templates/OpenCVConfig.cmake.in index 5039cc3a4473..3120010ae5ac 100644 --- a/cmake/templates/OpenCVConfig.cmake.in +++ b/cmake/templates/OpenCVConfig.cmake.in @@ -343,6 +343,7 @@ endif() if("@Qt5Widgets_FOUND@") find_dependency(Qt5Widgets) + _qt_cmake_extra_helpers_add_interface(opencv_highgui Qt5::Widgets) if(NOT "@BUILD_SHARED_LIBS@") # function from Hunter's QtCMakeExtra project _qt_cmake_extra_helpers_add_source( From d4818aac6002618b591957f179b4fd71dc100dd1 Mon Sep 17 00:00:00 2001 From: Sacha Date: Wed, 7 Nov 2018 11:16:49 +1000 Subject: [PATCH 20/25] Fix CMake find_package(OpenCV) for Windows when BUILD_SHARED_LIBS is not defined. --- cmake/OpenCVDetectCXXCompiler.cmake | 6 +++--- cmake/templates/OpenCVConfig.root-WIN32.cmake.in | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmake/OpenCVDetectCXXCompiler.cmake b/cmake/OpenCVDetectCXXCompiler.cmake index d7fb4f9a8098..f4d270994448 100644 --- a/cmake/OpenCVDetectCXXCompiler.cmake +++ b/cmake/OpenCVDetectCXXCompiler.cmake @@ -111,10 +111,10 @@ endif() # Similar code exists in OpenCVConfig.cmake if(NOT DEFINED OpenCV_STATIC) # look for global setting - if(NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS) - set(OpenCV_STATIC OFF) - else() + if(NOT DEFINED BUILD_SHARED_LIBS OR NOT BUILD_SHARED_LIBS) set(OpenCV_STATIC ON) + else() + set(OpenCV_STATIC OFF) endif() endif() diff --git a/cmake/templates/OpenCVConfig.root-WIN32.cmake.in b/cmake/templates/OpenCVConfig.root-WIN32.cmake.in index 76027bf92ee1..c5b7ab234add 100644 --- a/cmake/templates/OpenCVConfig.root-WIN32.cmake.in +++ b/cmake/templates/OpenCVConfig.root-WIN32.cmake.in @@ -43,10 +43,10 @@ endif() if(NOT DEFINED OpenCV_STATIC) # look for global setting - if(NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS) - set(OpenCV_STATIC OFF) - else() + if(NOT DEFINED BUILD_SHARED_LIBS OR NOT BUILD_SHARED_LIBS) set(OpenCV_STATIC ON) + else() + set(OpenCV_STATIC OFF) endif() endif() From 639719f3f2fe822834f05cde58a620d12dcdbfbb Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Mon, 9 Apr 2018 20:12:28 +0300 Subject: [PATCH 21/25] Use Hunter to download Jpeg --- cmake/OpenCVFindLibsGrfmt.cmake | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmake/OpenCVFindLibsGrfmt.cmake b/cmake/OpenCVFindLibsGrfmt.cmake index 402a4ff2e40f..19a05bdcc235 100644 --- a/cmake/OpenCVFindLibsGrfmt.cmake +++ b/cmake/OpenCVFindLibsGrfmt.cmake @@ -32,7 +32,18 @@ if(WITH_JPEG) ocv_clear_vars(JPEG_FOUND) else() hunter_add_package(Jpeg) + if(HUNTER_ENABLED) + find_package(JPEG CONFIG REQUIRED) + set(JPEG_LIBRARY JPEG::jpeg) + set(JPEG_LIBRARIES ${JPEG_LIBRARY}) + get_target_property( + JPEG_INCLUDE_DIR + JPEG::jpeg + INTERFACE_INCLUDE_DIRECTORIES + ) + else() include(FindJPEG) + endif() endif() if(NOT JPEG_FOUND) From 7fdd6b8993d691246fc0039a08b35f23788b9995 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Mon, 9 Apr 2018 21:03:49 +0300 Subject: [PATCH 22/25] Use Hunter to download Jasper --- cmake/OpenCVFindLibsGrfmt.cmake | 16 ++++++++++++++++ cmake/templates/OpenCVConfig.cmake.in | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/cmake/OpenCVFindLibsGrfmt.cmake b/cmake/OpenCVFindLibsGrfmt.cmake index 19a05bdcc235..91084fa09392 100644 --- a/cmake/OpenCVFindLibsGrfmt.cmake +++ b/cmake/OpenCVFindLibsGrfmt.cmake @@ -172,7 +172,23 @@ if(WITH_JASPER) if(BUILD_JASPER) ocv_clear_vars(JASPER_FOUND) else() + if(HUNTER_ENABLED) + hunter_add_package(jasper) + find_package(jasper CONFIG REQUIRED) + + set(JASPER_FOUND TRUE) + set(JASPER_LIBRARY jasper::libjasper) + set(JASPER_LIBRARIES ${JASPER_LIBRARY}) + get_target_property( + JASPER_INCLUDE_DIR + jasper::libjasper + INTERFACE_INCLUDE_DIRECTORIES + ) + else() + include(FindJasper) + + endif() endif() if(NOT JASPER_FOUND) diff --git a/cmake/templates/OpenCVConfig.cmake.in b/cmake/templates/OpenCVConfig.cmake.in index 3120010ae5ac..706b07196f58 100644 --- a/cmake/templates/OpenCVConfig.cmake.in +++ b/cmake/templates/OpenCVConfig.cmake.in @@ -332,6 +332,10 @@ if("@JPEG_FOUND@") find_dependency(JPEG CONFIG) endif() +if("@JASPER_FOUND@") + find_dependency(jasper CONFIG) +endif() + # AWP: Qt5 dependencies -- start if("@Qt5Core_FOUND@") find_dependency(Qt5Core) From 6304317ed06959a5f9a4460ba87e4c120931de21 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Mon, 9 Apr 2018 21:36:47 +0300 Subject: [PATCH 23/25] Use Hunter to download WebP --- cmake/OpenCVFindLibsGrfmt.cmake | 17 +++++++++++++++++ cmake/templates/OpenCVConfig.cmake.in | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/cmake/OpenCVFindLibsGrfmt.cmake b/cmake/OpenCVFindLibsGrfmt.cmake index 91084fa09392..b9a613548191 100644 --- a/cmake/OpenCVFindLibsGrfmt.cmake +++ b/cmake/OpenCVFindLibsGrfmt.cmake @@ -131,10 +131,27 @@ if(WITH_WEBP) if(BUILD_WEBP) ocv_clear_vars(WEBP_FOUND WEBP_LIBRARY WEBP_LIBRARIES WEBP_INCLUDE_DIR) else() + if(HUNTER_ENABLED) + hunter_add_package(WebP) + find_package(WebP CONFIG REQUIRED) + set(WEBP_FOUND TRUE) + set(HAVE_WEBP 1) + set(WEBP_LIBRARY WebP::webp) + set(WEBP_LIBRARIES ${WEBP_LIBRARY}) + + get_target_property( + WEBP_INCLUDE_DIR + WebP::webp + INTERFACE_INCLUDE_DIRECTORIES + ) + else() + include(cmake/OpenCVFindWebP.cmake) if(WEBP_FOUND) set(HAVE_WEBP 1) endif() + + endif() endif() endif() diff --git a/cmake/templates/OpenCVConfig.cmake.in b/cmake/templates/OpenCVConfig.cmake.in index 706b07196f58..bdf0ec3beebb 100644 --- a/cmake/templates/OpenCVConfig.cmake.in +++ b/cmake/templates/OpenCVConfig.cmake.in @@ -336,6 +336,10 @@ if("@JASPER_FOUND@") find_dependency(jasper CONFIG) endif() +if("@WEBP_FOUND@") + find_dependency(WebP CONFIG) +endif() + # AWP: Qt5 dependencies -- start if("@Qt5Core_FOUND@") find_dependency(Qt5Core) From 21a773509210bd54528869284b912fd71772a817 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Wed, 3 Apr 2019 01:59:34 +0300 Subject: [PATCH 24/25] Update HunterGate --- cmake/HunterGate.cmake | 225 +++++++++++++++++++++++------------------ 1 file changed, 128 insertions(+), 97 deletions(-) diff --git a/cmake/HunterGate.cmake b/cmake/HunterGate.cmake index acb6aeccaa18..e78d3e8912a0 100644 --- a/cmake/HunterGate.cmake +++ b/cmake/HunterGate.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2013-2015, 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( @@ -42,35 +42,46 @@ # * https://github.com/hunter-packages/gate/ # * https://github.com/ruslo/hunter -cmake_minimum_required(VERSION 3.0) # Minimum for Hunter +option(HUNTER_ENABLED "Enable Hunter package manager support" ON) + +if(HUNTER_ENABLED) + 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() + include(CMakeParseArguments) # cmake_parse_arguments -option(HUNTER_ENABLED "Enable Hunter package manager support" ON) 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 "") @@ -83,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}) @@ -98,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) @@ -123,14 +133,10 @@ function(hunter_gate_self root version sha1 result) string(SUBSTRING "${sha1}" 0 7 archive_id) - if(EXISTS "${root}/cmake/Hunter") - set(hunter_self "${root}") - else() - set( - hunter_self - "${root}/_Base/Download/Hunter/${version}/${archive_id}/Unpacked" - ) - endif() + set( + hunter_self + "${root}/_Base/Download/Hunter/${version}/${archive_id}/Unpacked" + ) set("${result}" "${hunter_self}" PARENT_SCOPE) endfunction() @@ -184,24 +190,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 @@ -217,7 +209,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) @@ -241,7 +233,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") @@ -258,7 +253,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" @@ -269,6 +264,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" @@ -287,15 +284,45 @@ function(hunter_gate_download dir) endif() hunter_gate_status_debug("Run generate") + + # Need to add toolchain file too. + # Otherwise on Visual Studio + MDD this will fail with error: + # "Could not find an appropriate version of the Windows 10 SDK installed on this machine" + if(EXISTS "${CMAKE_TOOLCHAIN_FILE}") + get_filename_component(absolute_CMAKE_TOOLCHAIN_FILE "${CMAKE_TOOLCHAIN_FILE}" ABSOLUTE) + set(toolchain_arg "-DCMAKE_TOOLCHAIN_FILE=${absolute_CMAKE_TOOLCHAIN_FILE}") + else() + # 'toolchain_arg' can't be empty + set(toolchain_arg "-DCMAKE_TOOLCHAIN_FILE=") + endif() + + string(COMPARE EQUAL "${CMAKE_MAKE_PROGRAM}" "" no_make) + if(no_make) + set(make_arg "") + else() + # Test case: remove Ninja from PATH but set it via CMAKE_MAKE_PROGRAM + set(make_arg "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}") + endif() + execute_process( - COMMAND "${CMAKE_COMMAND}" "-H${dir}" "-B${build_dir}" + COMMAND + "${CMAKE_COMMAND}" + "-H${dir}" + "-B${build_dir}" + "-G${CMAKE_GENERATOR}" + "${toolchain_arg}" + ${make_arg} WORKING_DIRECTORY "${dir}" RESULT_VARIABLE download_result ${logging_params} ) 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( @@ -340,6 +367,17 @@ macro(HunterGate) # Empty function to avoid error "unknown function" function(hunter_add_package) endfunction() + + set( + _hunter_gate_disabled_mode_dir + "${CMAKE_CURRENT_LIST_DIR}/cmake/Hunter/disabled-mode" + ) + if(EXISTS "${_hunter_gate_disabled_mode_dir}") + hunter_gate_status_debug( + "Adding \"disabled-mode\" modules: ${_hunter_gate_disabled_mode_dir}" + ) + list(APPEND CMAKE_PREFIX_PATH "${_hunter_gate_disabled_mode_dir}") + endif() elseif(_hunter_gate_done) hunter_gate_status_debug("Secondary HunterGate (use old settings)") hunter_gate_self( @@ -350,14 +388,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() @@ -377,17 +415,17 @@ macro(HunterGate) string(COMPARE NOTEQUAL "${HUNTER_GATE_GLOBAL}" "" _have_global) string(COMPARE NOTEQUAL "${HUNTER_GATE_FILEPATH}" "" _have_filepath) + if(_have_unparsed) + hunter_gate_user_error( + "HunterGate unparsed arguments: ${HUNTER_GATE_UNPARSED_ARGUMENTS}" + ) + endif() if(_empty_sha1) hunter_gate_user_error("SHA1 suboption of HunterGate is mandatory") endif() if(_empty_url) hunter_gate_user_error("URL suboption of HunterGate is mandatory") endif() - if(_have_unparsed) - hunter_gate_user_error( - "HunterGate unparsed arguments: ${HUNTER_GATE_UNPARSED_ARGUMENTS}" - ) - endif() if(_have_global) if(HUNTER_GATE_LOCAL) hunter_gate_user_error("Unexpected LOCAL (already has GLOBAL)") @@ -427,7 +465,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() @@ -448,48 +486,41 @@ macro(HunterGate) "${HUNTER_GATE_ROOT}" "${HUNTER_GATE_VERSION}" "${HUNTER_GATE_SHA1}" - hunter_self_ + _hunter_self ) - set(_master_location "${hunter_self_}/cmake/Hunter") - if(EXISTS "${HUNTER_GATE_ROOT}/cmake/Hunter") - # Hunter downloaded manually (e.g. by 'git clone') - set(_unused "xxxxxxxxxx") - set(HUNTER_GATE_SHA1 "${_unused}") - set(HUNTER_GATE_VERSION "${_unused}") - else() - get_filename_component(_archive_id_location "${hunter_self_}/.." ABSOLUTE) - set(_done_location "${_archive_id_location}/DONE") - set(_sha1_location "${_archive_id_location}/SHA1") - - # Check Hunter already downloaded by HunterGate - if(NOT EXISTS "${_done_location}") - hunter_gate_download("${_archive_id_location}") - endif() + set(_master_location "${_hunter_self}/cmake/Hunter") + get_filename_component(_archive_id_location "${_hunter_self}/.." ABSOLUTE) + set(_done_location "${_archive_id_location}/DONE") + set(_sha1_location "${_archive_id_location}/SHA1") - if(NOT EXISTS "${_done_location}") - hunter_gate_internal_error("hunter_gate_download failed") - endif() + # Check Hunter already downloaded by HunterGate + if(NOT EXISTS "${_done_location}") + hunter_gate_download("${_archive_id_location}") + endif() - if(NOT EXISTS "${_sha1_location}") - 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) - if(NOT _is_equal) - hunter_gate_internal_error( - "Short SHA1 collision:" - " ${_sha1_value} (from ${_sha1_location})" - " ${HUNTER_GATE_SHA1} (HunterGate)" - ) - endif() - if(NOT EXISTS "${_master_location}") - hunter_gate_user_error( - "Master file not found:" - " ${_master_location}" - "try to update Hunter/HunterGate" - ) - endif() + if(NOT EXISTS "${_done_location}") + hunter_gate_internal_error("hunter_gate_download failed") + endif() + + if(NOT EXISTS "${_sha1_location}") + 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) + if(NOT _is_equal) + hunter_gate_internal_error( + "Short SHA1 collision:" + " ${_sha1_value} (from ${_sha1_location})" + " ${HUNTER_GATE_SHA1} (HunterGate)" + ) + endif() + if(NOT EXISTS "${_master_location}") + hunter_gate_user_error( + "Master file not found:" + " ${_master_location}" + "try to update Hunter/HunterGate" + ) endif() include("${_master_location}") set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES) From 79a341e0cfb8580e3fe471d231b15401d4a712c1 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Wed, 3 Apr 2019 10:27:31 +0300 Subject: [PATCH 25/25] Fix Accelerate.framework full path --- cmake/templates/OpenCVConfig.cmake.in | 5 ++++- modules/core/CMakeLists.txt | 9 ++++++++- modules/dnn/CMakeLists.txt | 10 +++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/cmake/templates/OpenCVConfig.cmake.in b/cmake/templates/OpenCVConfig.cmake.in index bdf0ec3beebb..e6acb2fb4017 100644 --- a/cmake/templates/OpenCVConfig.cmake.in +++ b/cmake/templates/OpenCVConfig.cmake.in @@ -108,6 +108,10 @@ set(OpenCV_USE_MANGLED_PATHS @OpenCV_USE_MANGLED_PATHS_CONFIGCMAKE@) set(OpenCV_LIB_COMPONENTS @OPENCV_MODULES_CONFIGCMAKE@) set(OpenCV_INCLUDE_DIRS @OpenCV_INCLUDE_DIRS_CONFIGCMAKE@) +if(APPLE) + find_package(accelerate REQUIRED) +endif() + if(NOT TARGET opencv_core) include(${CMAKE_CURRENT_LIST_DIR}/OpenCVModules${OpenCV_MODULES_SUFFIX}.cmake) endif() @@ -372,4 +376,3 @@ if("@Qt5OpenGL_FOUND@") find_dependency(Qt5OpenGL) endif() # AWP: Qt5 dependencies -- end - diff --git a/modules/core/CMakeLists.txt b/modules/core/CMakeLists.txt index 285326a963e8..57d506e13d81 100644 --- a/modules/core/CMakeLists.txt +++ b/modules/core/CMakeLists.txt @@ -79,9 +79,16 @@ endif() ocv_create_module(${extra_libs}) +if(HUNTER_ENABLED AND APPLE) + find_package(accelerate REQUIRED) + set(__lapack_libraries accelerate::accelerate) +else() + set(__lapack_libraries ${LAPACK_LIBRARIES}) +endif() + ocv_target_link_libraries(${the_module} LINK_PRIVATE "${ZLIB_LIBRARIES}" "${OPENCL_LIBRARIES}" "${VA_LIBRARIES}" - "${LAPACK_LIBRARIES}" "${CPUFEATURES_LIBRARIES}" "${HALIDE_LIBRARIES}" + "${__lapack_libraries}" "${CPUFEATURES_LIBRARIES}" "${HALIDE_LIBRARIES}" "${ITT_LIBRARIES}" "${OPENCV_HAL_LINKER_LIBS}" ) diff --git a/modules/dnn/CMakeLists.txt b/modules/dnn/CMakeLists.txt index 7682257729ef..09a94b82defe 100644 --- a/modules/dnn/CMakeLists.txt +++ b/modules/dnn/CMakeLists.txt @@ -72,7 +72,15 @@ endif() set(include_dirs ${fw_inc}) set(sources_options "") -set(libs libprotobuf ${LAPACK_LIBRARIES}) + +if(HUNTER_ENABLED AND APPLE) + find_package(accelerate REQUIRED) + set(__lapack_libraries accelerate::accelerate) +else() + set(__lapack_libraries ${LAPACK_LIBRARIES}) +endif() + +set(libs libprotobuf ${__lapack_libraries}) if(OPENCV_DNN_OPENCL AND HAVE_OPENCL) list(APPEND include_dirs ${OPENCL_INCLUDE_DIRS}) else()