From 553fba7e44f5d21552e7a97d41299403920872c0 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Sat, 16 May 2015 20:38:24 +0200 Subject: [PATCH 01/19] 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 2ccc50ba171ed8bdfc23e63f7d24211ba9c78b88 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Sat, 16 May 2015 20:41:20 +0200 Subject: [PATCH 02/19] Use HunterGate (without packages) --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4464441b760d..5cbc331fabff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,7 +112,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 75f8496b00fee4b4ae52df7b54da1ab3c7aaaa3b Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Sat, 16 May 2015 22:02:02 +0200 Subject: [PATCH 03/19] 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 751df33783a7..07969663143a 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_2017u3_mac_ia32_general_20170822.tgz") set(OPENCV_ICV_HASH "49b05a669042753ae75895a445ebd612") 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 0ae58c89f47b..62e32fb10465 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 STREQUAL "${ANDROID_SYSROOT}/usr/lib/libz.so" OR @@ -52,6 +53,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) @@ -160,6 +162,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 335019318270f816822638a244e07f519599503f Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Fri, 15 May 2015 17:54:57 +0200 Subject: [PATCH 04/19] 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 5cbc331fabff..a37006bc5994 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,6 +120,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 feb611bc79e89720f99dd018284a717cf7a75a57 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Fri, 15 May 2015 18:30:47 +0200 Subject: [PATCH 05/19] 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 a37006bc5994..bf045705a4ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -122,6 +122,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 7ab0a6b2279c0b6434d1027aea00d9685c128270 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Sat, 16 May 2015 22:20:20 +0200 Subject: [PATCH 06/19] 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 edc707549e8d..5b5ab8a883ee 100644 --- a/cmake/templates/OpenCVConfig.cmake.in +++ b/cmake/templates/OpenCVConfig.cmake.in @@ -311,3 +311,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 430d132d272d99777627f6e5916687f14117948d Mon Sep 17 00:00:00 2001 From: David Hirvonen Date: Fri, 26 Jun 2015 08:59:34 +0300 Subject: [PATCH 07/19] 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 943a27ea19b9..38dcdaf92148 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 cdcc94c2a75bc0e65bcd512293be1374a91dca1d Mon Sep 17 00:00:00 2001 From: David Hirvonen Date: Tue, 30 Jun 2015 19:55:58 -0400 Subject: [PATCH 08/19] 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 5b5ab8a883ee..421bf3b9f242 100644 --- a/cmake/templates/OpenCVConfig.cmake.in +++ b/cmake/templates/OpenCVConfig.cmake.in @@ -248,8 +248,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 c04376a7aa9d117bdadb199474e4e6da9f6f4af4 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Sat, 11 Jul 2015 22:52:07 +0300 Subject: [PATCH 09/19] 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 bf045705a4ec..6ee36f05528d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -496,6 +496,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") +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 500bae724d7af231e61c3669cdcb0a1a9a852584 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Sat, 11 Jul 2015 23:49:03 +0300 Subject: [PATCH 10/19] 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 76d1d83bb5fb..3aaab58217c5 100644 --- a/cmake/OpenCVFindLibsPerf.cmake +++ b/cmake/OpenCVFindLibsPerf.cmake @@ -39,11 +39,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 7ef299bbee299cabf29dfcd957d64acde09360b6 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Mon, 21 Mar 2016 18:23:03 +0700 Subject: [PATCH 11/19] 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 62e32fb10465..58925d3d452c 100644 --- a/cmake/OpenCVFindLibsGrfmt.cmake +++ b/cmake/OpenCVFindLibsGrfmt.cmake @@ -32,6 +32,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 421bf3b9f242..e44d0380542e 100644 --- a/cmake/templates/OpenCVConfig.cmake.in +++ b/cmake/templates/OpenCVConfig.cmake.in @@ -325,3 +325,7 @@ endif() if("@PNG_FOUND@") find_dependency(PNG CONFIG) endif() + +if("@JPEG_FOUND@") + find_dependency(JPEG CONFIG) +endif() From 63bbd2852ae77f1b6cc4de9eb0d50351b4ee7d5f Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Mon, 21 Mar 2016 18:26:34 +0700 Subject: [PATCH 12/19] Update Hunter --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ee36f05528d..af0687445e21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,8 +114,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 d7ce9b5bdbe9bdd1446de89ebc6f26b6d50b0df9 Mon Sep 17 00:00:00 2001 From: Alexandre Pretyman Date: Tue, 22 Mar 2016 23:38:54 -0400 Subject: [PATCH 13/19] 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 f58b3de62cc6..a3890332e879 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 e44d0380542e..1efec549fce1 100644 --- a/cmake/templates/OpenCVConfig.cmake.in +++ b/cmake/templates/OpenCVConfig.cmake.in @@ -329,3 +329,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 99d71886614b..a435bcfb7147 100644 --- a/modules/highgui/CMakeLists.txt +++ b/modules/highgui/CMakeLists.txt @@ -51,6 +51,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 6523267e29a8b45a980f9c6fcf1f6ecd112a7817 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Sat, 24 Dec 2016 01:06:29 +0800 Subject: [PATCH 14/19] 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 3aaab58217c5..8212a6f8f328 100644 --- a/cmake/OpenCVFindLibsPerf.cmake +++ b/cmake/OpenCVFindLibsPerf.cmake @@ -41,10 +41,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 ebbdf37f44efe492b917ba87ecef8dbe245a6fce Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Sat, 24 Dec 2016 01:07:28 +0800 Subject: [PATCH 15/19] Update Hunter --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index af0687445e21..284dda927235 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,8 +114,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 06cb3f79f11a7e46644cebfcf8160ac7bd30eff2 Mon Sep 17 00:00:00 2001 From: Sacha Date: Tue, 4 Apr 2017 11:48:32 +1000 Subject: [PATCH 16/19] Rename ANDROID_ vars to CMAKE_ vars. --- CMakeLists.txt | 29 +++++++------------ cmake/OpenCVDetectAndroidSDK.cmake | 12 ++++---- cmake/OpenCVGenAndroidMK.cmake | 6 ++-- cmake/OpenCVGenConfig.cmake | 6 ++-- cmake/templates/OpenCVConfig-ANDROID.cmake.in | 2 +- .../OpenCVConfig.root-ANDROID.cmake.in | 2 +- modules/java/CMakeLists.txt | 6 ++-- modules/java/android_test/CMakeLists.txt | 2 +- modules/ts/misc/run_utils.py | 4 +-- 9 files changed, 31 insertions(+), 38 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 284dda927235..413c4fadec14 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -349,12 +349,9 @@ include(cmake/OpenCVVersion.cmake) 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) @@ -377,13 +374,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() @@ -405,10 +402,10 @@ 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_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_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) @@ -1051,16 +1048,12 @@ status(" Non-free algorithms:" OPENCV_ENABLE_NONFREE THEN "YES" ELSE "NO") if(ANDROID) status("") status(" Android: ") - status(" Android ABI:" ${ANDROID_ABI}) + status(" Android ABI:" ${CMAKE_ANDROID_ARCH_ABI}) status(" STL type:" ${ANDROID_STL}) - status(" Native API level:" android-${ANDROID_NATIVE_API_LEVEL}) - android_get_compatible_target(android_sdk_target_status ${ANDROID_NATIVE_API_LEVEL} ${ANDROID_SDK_TARGET} 11) + status(" Native API level:" android-${CMAKE_SYSTEM_VERSION}) + android_get_compatible_target(android_sdk_target_status ${CMAKE_SYSTEM_VERSION} ${ANDROID_SDK_TARGET} 11) status(" SDK target:" "${android_sdk_target_status}") - if(BUILD_WITH_ANDROID_NDK) - status(" Android NDK:" "${ANDROID_NDK} (toolchain: ${ANDROID_TOOLCHAIN_NAME})") - elseif(BUILD_WITH_STANDALONE_TOOLCHAIN) - status(" Android toolchain:" "${ANDROID_STANDALONE_TOOLCHAIN}") - endif() + status(" Android NDK:" "${CMAKE_ANDROID_NDK} (toolchain: ${CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION})") status(" android tool:" ANDROID_EXECUTABLE THEN "${ANDROID_EXECUTABLE} (${ANDROID_TOOLS_Pkg_Desc})" ELSE NO) endif() diff --git a/cmake/OpenCVDetectAndroidSDK.cmake b/cmake/OpenCVDetectAndroidSDK.cmake index 85c103e002b7..93e5968bee29 100644 --- a/cmake/OpenCVDetectAndroidSDK.cmake +++ b/cmake/OpenCVDetectAndroidSDK.cmake @@ -199,10 +199,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() @@ -217,7 +217,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() @@ -281,8 +281,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() @@ -294,7 +294,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/OpenCVGenAndroidMK.cmake b/cmake/OpenCVGenAndroidMK.cmake index 69aa43bfd88a..a8aee56197c1 100644 --- a/cmake/OpenCVGenAndroidMK.cmake +++ b/cmake/OpenCVGenAndroidMK.cmake @@ -62,7 +62,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" @@ -73,7 +73,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 57c79f213afe..5e252b5c7cbc 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() @@ -108,7 +108,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/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 d44b19523830..b24b89518af0 100644 --- a/modules/java/CMakeLists.txt +++ b/modules/java/CMakeLists.txt @@ -2,7 +2,7 @@ # CMake file for java support # ---------------------------------------------------------------------------- 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) @@ -231,7 +231,7 @@ else() list(REMOVE_ITEM handwrittren_lib_project_files_rel "${ANDROID_MANIFEST_FILE}") # calc default SDK Target - android_get_compatible_target(android_sdk_target ${ANDROID_NATIVE_API_LEVEL} ${ANDROID_SDK_TARGET} 11) + android_get_compatible_target(android_sdk_target ${CMAKE_SYSTEM_VERSION} ${ANDROID_SDK_TARGET} 11) string(REGEX REPLACE "android-" "" android_sdk_target_num ${android_sdk_target}) # filter out if( (ANDROID_SDK_TARGET AND ANDROID_SDK_TARGET LESS 21) OR (android_sdk_target_num LESS 21) ) @@ -340,7 +340,7 @@ if(ANDROID AND ANDROID_EXECUTABLE) set(lib_target_files ${ANDROID_LIB_PROJECT_FILES}) ocv_list_add_prefix(lib_target_files "${OpenCV_BINARY_DIR}/") - android_get_compatible_target(lib_target_sdk_target ${ANDROID_NATIVE_API_LEVEL} ${ANDROID_SDK_TARGET} 14) + android_get_compatible_target(lib_target_sdk_target ${CMAKE_SYSTEM_VERSION} ${ANDROID_SDK_TARGET} 14) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/android_lib/${ANDROID_MANIFEST_FILE}" "${CMAKE_CURRENT_BINARY_DIR}/${ANDROID_MANIFEST_FILE}" @ONLY) add_custom_command(OUTPUT ${lib_target_files} "${OpenCV_BINARY_DIR}/${ANDROID_MANIFEST_FILE}" diff --git a/modules/java/android_test/CMakeLists.txt b/modules/java/android_test/CMakeLists.txt index 2925d65e37ca..843afd4a6692 100644 --- a/modules/java/android_test/CMakeLists.txt +++ b/modules/java/android_test/CMakeLists.txt @@ -46,7 +46,7 @@ list(APPEND opencv_test_java_file_deps ${android_proj_target_files}) # build java part add_custom_command( OUTPUT "${opencv_test_java_bin_dir}/bin/OpenCVTest-debug.apk" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${opencv_test_java_bin_dir}/libs/${ANDROID_NDK_ABI_NAME}/$" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${opencv_test_java_bin_dir}/libs/${CMAKE_ANDROID_ARCH_ABI}/$" COMMAND ${ANT_EXECUTABLE} -q -noinput -k debug -Djava.target=1.6 -Djava.source=1.6 COMMAND ${CMAKE_COMMAND} -E touch "${opencv_test_java_bin_dir}/bin/OpenCVTest-debug.apk" # needed because ant does not update the timestamp of updated apk WORKING_DIRECTORY "${opencv_test_java_bin_dir}" diff --git a/modules/ts/misc/run_utils.py b/modules/ts/misc/run_utils.py index 8c07763d030c..c0848d64ceb7 100644 --- a/modules/ts/misc/run_utils.py +++ b/modules/ts/misc/run_utils.py @@ -164,8 +164,8 @@ def testSIMD(compiler, cxx_flags, compiler_arg = None): {'name': "cxx_flags_debug", 'default': "", 'pattern': re.compile(r"^CMAKE_CXX_FLAGS_DEBUG:STRING=(.*)$")}, {'name': "cxx_flags_release", 'default': "", 'pattern': re.compile(r"^CMAKE_CXX_FLAGS_RELEASE:STRING=(.*)$")}, {'name': "opencv_cxx_flags", 'default': "", 'pattern': re.compile(r"^OPENCV_EXTRA_C_FLAGS:INTERNAL=(.*)$")}, - {'name': "cxx_flags_android", 'default': None, 'pattern': re.compile(r"^ANDROID_CXX_FLAGS:INTERNAL=(.*)$")}, - {'name': "android_abi", 'default': None, 'pattern': re.compile(r"^ANDROID_ABI:STRING=(.*)$")}, + {'name': "cxx_flags_android", 'default': None, 'pattern': re.compile(r"^CMAKE_CXX_FLAGS:INTERNAL=(.*)$")}, + {'name': "android_abi", 'default': None, 'pattern': re.compile(r"^CMAKE_ANDROID_ARCH_ABI:STRING=(.*)$")}, {'name': "android_executable", 'default': None, 'pattern': re.compile(r"^ANDROID_EXECUTABLE:FILEPATH=(.*android.*)$")}, {'name': "ant_executable", 'default': None, 'pattern': re.compile(r"^ANT_EXECUTABLE:FILEPATH=(.*ant.*)$")}, {'name': "java_test_binary_dir", 'default': None, 'pattern': re.compile(r"^opencv_test_java_BINARY_DIR:STATIC=(.*)$")}, From 171ebb25b8edbabd56f5aaa900afae66c09d6652 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Mon, 14 Aug 2017 16:31:47 +0300 Subject: [PATCH 17/19] Update Hunter --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 413c4fadec14..81a43f29036a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,8 +114,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 5e4df5d135fcdb3a3d9a36033b186c088e5e59a9 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Mon, 14 Aug 2017 16:32:05 +0300 Subject: [PATCH 18/19] Fix iOS build --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 81a43f29036a..cc1bb6c50663 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,7 +121,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 159118f2093a1184cbd52968339ce765092444d0 Mon Sep 17 00:00:00 2001 From: Alexandre Pretyman Date: Fri, 17 Nov 2017 14:19:24 -0200 Subject: [PATCH 19/19] 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 1efec549fce1..640031afe0ba 100644 --- a/cmake/templates/OpenCVConfig.cmake.in +++ b/cmake/templates/OpenCVConfig.cmake.in @@ -341,6 +341,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(