From 387a76ba598fa1e177f8d79a2760ec75a4e9b0e1 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Wed, 25 Nov 2020 12:56:12 +0000 Subject: [PATCH] build: xcode 12 support, cmake fixes --- CMakeLists.txt | 5 +++++ cmake/OpenCVCompilerOptions.cmake | 2 +- cmake/OpenCVFindLibsGrfmt.cmake | 36 +++++++++++++++++++----------------- platforms/ios/build_framework.py | 2 +- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d143a7a..f1b5423 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,11 @@ endif() # # Configure CMake policies # + +if(POLICY CMP0025) + cmake_policy(SET CMP0025 NEW) # CMAKE_CXX_COMPILER_ID=AppleClang +endif() + if(POLICY CMP0026) cmake_policy(SET CMP0026 NEW) endif() diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake index 9ac671d..21201c1 100644 --- a/cmake/OpenCVCompilerOptions.cmake +++ b/cmake/OpenCVCompilerOptions.cmake @@ -151,7 +151,7 @@ if(CV_GCC OR CV_CLANG) if(CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) add_extra_compiler_option(-Wno-missing-field-initializers) # GCC 4.x emits warnings about {}, fixed in GCC 5+ endif() - if(CV_CLANG AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0) + if(CV_CLANG AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0) add_extra_compiler_option(-Wno-deprecated-enum-enum-conversion) add_extra_compiler_option(-Wno-deprecated-anon-enum-enum-conversion) endif() diff --git a/cmake/OpenCVFindLibsGrfmt.cmake b/cmake/OpenCVFindLibsGrfmt.cmake index fcf716b..4ad44fe 100644 --- a/cmake/OpenCVFindLibsGrfmt.cmake +++ b/cmake/OpenCVFindLibsGrfmt.cmake @@ -15,11 +15,12 @@ else() endif() if(NOT ZLIB_FOUND) - ocv_clear_vars(ZLIB_LIBRARY ZLIB_LIBRARIES ZLIB_INCLUDE_DIRS) + ocv_clear_vars(ZLIB_LIBRARY ZLIB_LIBRARIES ZLIB_INCLUDE_DIR) - set(ZLIB_LIBRARY zlib) + set(ZLIB_LIBRARY zlib CACHE INTERNAL "") add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/zlib") - set(ZLIB_INCLUDE_DIRS "${${ZLIB_LIBRARY}_SOURCE_DIR}" "${${ZLIB_LIBRARY}_BINARY_DIR}") + set(ZLIB_INCLUDE_DIR "${${ZLIB_LIBRARY}_SOURCE_DIR}" "${${ZLIB_LIBRARY}_BINARY_DIR}" CACHE INTERNAL "") + set(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR}) set(ZLIB_LIBRARIES ${ZLIB_LIBRARY}) ocv_parse_header2(ZLIB "${${ZLIB_LIBRARY}_SOURCE_DIR}/zlib.h" ZLIB_VERSION) @@ -37,16 +38,17 @@ if(WITH_JPEG) ocv_clear_vars(JPEG_LIBRARY JPEG_LIBRARIES JPEG_INCLUDE_DIR) if(NOT BUILD_JPEG_TURBO_DISABLE) - set(JPEG_LIBRARY libjpeg-turbo) + set(JPEG_LIBRARY libjpeg-turbo CACHE INTERNAL "") set(JPEG_LIBRARIES ${JPEG_LIBRARY}) add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libjpeg-turbo") - set(JPEG_INCLUDE_DIR "${${JPEG_LIBRARY}_SOURCE_DIR}/src") + set(JPEG_INCLUDE_DIR "${${JPEG_LIBRARY}_SOURCE_DIR}/src" CACHE INTERNAL "") else() - set(JPEG_LIBRARY libjpeg) + set(JPEG_LIBRARY libjpeg CACHE INTERNAL "") set(JPEG_LIBRARIES ${JPEG_LIBRARY}) add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libjpeg") - set(JPEG_INCLUDE_DIR "${${JPEG_LIBRARY}_SOURCE_DIR}") + set(JPEG_INCLUDE_DIR "${${JPEG_LIBRARY}_SOURCE_DIR}" CACHE INTERNAL "") endif() + set(JPEG_INCLUDE_DIRS "${JPEG_INCLUDE_DIR}") endif() macro(ocv_detect_jpeg_version header_file) @@ -83,10 +85,10 @@ if(WITH_TIFF) if(NOT TIFF_FOUND) ocv_clear_vars(TIFF_LIBRARY TIFF_LIBRARIES TIFF_INCLUDE_DIR) - set(TIFF_LIBRARY libtiff) + set(TIFF_LIBRARY libtiff CACHE INTERNAL "") set(TIFF_LIBRARIES ${TIFF_LIBRARY}) add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libtiff") - set(TIFF_INCLUDE_DIR "${${TIFF_LIBRARY}_SOURCE_DIR}" "${${TIFF_LIBRARY}_BINARY_DIR}") + set(TIFF_INCLUDE_DIR "${${TIFF_LIBRARY}_SOURCE_DIR}" "${${TIFF_LIBRARY}_BINARY_DIR}" CACHE INTERNAL "") ocv_parse_header("${${TIFF_LIBRARY}_SOURCE_DIR}/tiff.h" TIFF_VERSION_LINES TIFF_VERSION_CLASSIC TIFF_VERSION_BIG TIFF_VERSION TIFF_BIGTIFF_VERSION) endif() @@ -128,12 +130,12 @@ endif() if(WITH_WEBP AND NOT WEBP_FOUND AND (NOT ANDROID OR HAVE_CPUFEATURES) ) - - set(WEBP_LIBRARY libwebp) + ocv_clear_vars(WEBP_LIBRARY WEBP_INCLUDE_DIR) + set(WEBP_LIBRARY libwebp CACHE INTERNAL "") set(WEBP_LIBRARIES ${WEBP_LIBRARY}) add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libwebp") - set(WEBP_INCLUDE_DIR "${${WEBP_LIBRARY}_SOURCE_DIR}/src") + set(WEBP_INCLUDE_DIR "${${WEBP_LIBRARY}_SOURCE_DIR}/src" CACHE INTERNAL "") set(HAVE_WEBP 1) endif() @@ -164,10 +166,10 @@ if(WITH_JASPER) if(NOT JASPER_FOUND) ocv_clear_vars(JASPER_LIBRARY JASPER_LIBRARIES JASPER_INCLUDE_DIR) - set(JASPER_LIBRARY libjasper) + set(JASPER_LIBRARY libjasper CACHE INTERNAL "") set(JASPER_LIBRARIES ${JASPER_LIBRARY}) add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libjasper") - set(JASPER_INCLUDE_DIR "${${JASPER_LIBRARY}_SOURCE_DIR}") + set(JASPER_INCLUDE_DIR "${${JASPER_LIBRARY}_SOURCE_DIR}" CACHE INTERNAL "") endif() set(HAVE_JASPER YES) @@ -197,10 +199,10 @@ if(WITH_PNG) if(NOT PNG_FOUND) ocv_clear_vars(PNG_LIBRARY PNG_LIBRARIES PNG_INCLUDE_DIR PNG_PNG_INCLUDE_DIR HAVE_LIBPNG_PNG_H PNG_DEFINITIONS) - set(PNG_LIBRARY libpng) + set(PNG_LIBRARY libpng CACHE INTERNAL "") set(PNG_LIBRARIES ${PNG_LIBRARY}) add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libpng") - set(PNG_INCLUDE_DIR "${${PNG_LIBRARY}_SOURCE_DIR}") + set(PNG_INCLUDE_DIR "${${PNG_LIBRARY}_SOURCE_DIR}" CACHE INTERNAL "") set(PNG_DEFINITIONS "") ocv_parse_header("${PNG_INCLUDE_DIR}/png.h" PNG_VERSION_LINES PNG_LIBPNG_VER_MAJOR PNG_LIBPNG_VER_MINOR PNG_LIBPNG_VER_RELEASE) endif() @@ -242,7 +244,7 @@ if(WITH_GDAL) endif() endif() -if (WITH_GDCM) +if(WITH_GDCM) find_package(GDCM QUIET) if(NOT GDCM_FOUND) set(HAVE_GDCM NO) diff --git a/platforms/ios/build_framework.py b/platforms/ios/build_framework.py index 223542d..bc76587 100755 --- a/platforms/ios/build_framework.py +++ b/platforms/ios/build_framework.py @@ -31,7 +31,7 @@ from __future__ import print_function import glob, re, os, os.path, shutil, string, sys, argparse, traceback, multiprocessing from subprocess import check_call, check_output, CalledProcessError -IPHONEOS_DEPLOYMENT_TARGET='8.0' # default, can be changed via command line options or environment variable +IPHONEOS_DEPLOYMENT_TARGET='9.0' # default, can be changed via command line options or environment variable def execute(cmd, cwd = None): print("Executing: %s in %s" % (cmd, cwd), file=sys.stderr) -- 2.7.4