From 97507e42a14df1249c1b9ace1deab1ae2b78f0d1 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 28 Nov 2017 17:03:40 +0300 Subject: [PATCH] build: eliminate Xcode 9.1 warnings - 3rdparty/libjasper/jas_getopt.c:129:25: warning: this function declaration is not a prototype [-Wstrict-prototypes] - clang: warning: optimization flag '-fomit-frame-pointer' is not supported for target 'armv7' [-Wignored-optimization-argument] - clang: warning: optimization flag '-fomit-frame-pointer' is not supported for target 'armv7s' [-Wignored-optimization-argument] - backport IOS_ARCH toolchain option and setup CMAKE_SYSTEM_PROCESSOR: - adds '-mfpu=neon' compiler flag for ARM, SSE flags for i386/x86_64 - fixed proper libpng compilation (no ARM asm) --- 3rdparty/libjasper/CMakeLists.txt | 2 +- 3rdparty/libpng/CMakeLists.txt | 4 ++-- cmake/OpenCVCompilerOptions.cmake | 2 +- platforms/ios/build_framework.py | 1 + platforms/ios/cmake/Modules/Platform/iOS.cmake | 5 ++++- .../ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake | 5 ++++- .../cmake/Toolchains/Toolchain-iPhoneSimulator_Xcode.cmake | 5 ++++- 7 files changed, 17 insertions(+), 7 deletions(-) diff --git a/3rdparty/libjasper/CMakeLists.txt b/3rdparty/libjasper/CMakeLists.txt index bd7d0abbf2..f4e577ee32 100644 --- a/3rdparty/libjasper/CMakeLists.txt +++ b/3rdparty/libjasper/CMakeLists.txt @@ -25,7 +25,7 @@ endif(WIN32 AND NOT MINGW) ocv_warnings_disable(CMAKE_C_FLAGS -Wno-implicit-function-declaration -Wno-uninitialized -Wmissing-prototypes -Wno-unused-but-set-parameter -Wmissing-declarations -Wunused -Wshadow -Wsign-compare) -ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-parameter) # clang +ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-parameter -Wstrict-prototypes) # clang ocv_warnings_disable(CMAKE_C_FLAGS /wd4013 /wd4018 /wd4101 /wd4244 /wd4267 /wd4715) # vs2005 if(UNIX) diff --git a/3rdparty/libpng/CMakeLists.txt b/3rdparty/libpng/CMakeLists.txt index 2d4430423f..ed22b2ce4d 100644 --- a/3rdparty/libpng/CMakeLists.txt +++ b/3rdparty/libpng/CMakeLists.txt @@ -3,7 +3,7 @@ # # ---------------------------------------------------------------------------- -if(ARM AND ENABLE_NEON AND NOT AARCH64) +if(ARM AND ENABLE_NEON AND NOT AARCH64 AND NOT IOS) project(${PNG_LIBRARY} ASM) else() project(${PNG_LIBRARY}) @@ -14,7 +14,7 @@ ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" ${ZLIB_INCLUDE_DIR}) file(GLOB lib_srcs *.c) file(GLOB lib_hdrs *.h) -if(ARM AND ENABLE_NEON AND NOT AARCH64) +if(ARM AND ENABLE_NEON AND NOT AARCH64 AND NOT IOS) list(APPEND lib_srcs arm/filter_neon.S arm/arm_init.c) add_definitions(-DPNG_ARM_NEON_OPT=2) else() diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake index 7b079c5f98..e61059a80a 100644 --- a/cmake/OpenCVCompilerOptions.cmake +++ b/cmake/OpenCVCompilerOptions.cmake @@ -164,7 +164,7 @@ if(CMAKE_COMPILER_IS_GNUCXX) # Other optimizations if(ENABLE_OMIT_FRAME_POINTER) add_extra_compiler_option(-fomit-frame-pointer) - else() + elseif(DEFINED ENABLE_OMIT_FRAME_POINTER) add_extra_compiler_option(-fno-omit-frame-pointer) endif() if(ENABLE_FAST_MATH) diff --git a/platforms/ios/build_framework.py b/platforms/ios/build_framework.py index 28ce885b20..6ed4e2c147 100755 --- a/platforms/ios/build_framework.py +++ b/platforms/ios/build_framework.py @@ -49,6 +49,7 @@ def build_opencv(srcroot, buildroot, target, arch): # for some reason, if you do not specify CMAKE_BUILD_TYPE, it puts libs to "RELEASE" rather than "Release" cmakeargs = ("-GXcode " + "-DCMAKE_BUILD_TYPE=Release " + + ("-DIOS_ARCH=%s " % arch) + "-DCMAKE_TOOLCHAIN_FILE=%s/platforms/ios/cmake/Toolchains/Toolchain-%s_Xcode.cmake " + "-DBUILD_opencv_world=ON " + "-DCMAKE_C_FLAGS=\"-Wno-implicit-function-declaration\" " + diff --git a/platforms/ios/cmake/Modules/Platform/iOS.cmake b/platforms/ios/cmake/Modules/Platform/iOS.cmake index 3a80e84ae1..82c00694e0 100644 --- a/platforms/ios/cmake/Modules/Platform/iOS.cmake +++ b/platforms/ios/cmake/Modules/Platform/iOS.cmake @@ -43,7 +43,10 @@ set (no_warn "-Wno-unused-function -Wno-overloaded-virtual") set (CMAKE_C_FLAGS "${no_warn}") set (CMAKE_CXX_FLAGS "-stdlib=libc++ -fvisibility=hidden -fvisibility-inlines-hidden ${no_warn}") -set (CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3 -fomit-frame-pointer -ffast-math") +set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3 -ffast-math") +if(NOT IOS_ARCH STREQUAL "armv7" AND NOT IOS_ARCH STREQUAL "armv7s") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer") +endif() if (HAVE_FLAG_SEARCH_PATHS_FIRST) set (CMAKE_C_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}") diff --git a/platforms/ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake b/platforms/ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake index 14555cd6a9..42c17c52c0 100644 --- a/platforms/ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake +++ b/platforms/ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake @@ -2,7 +2,10 @@ message (STATUS "Setting up iPhoneOS toolchain") set (IPHONEOS TRUE) # Standard settings -set (CMAKE_SYSTEM_NAME iOS) +set(CMAKE_SYSTEM_NAME iOS) +set(CMAKE_SYSTEM_VERSION 6.0) +set(CMAKE_SYSTEM_PROCESSOR "${IOS_ARCH}") + # Include extra modules for the iOS platform files set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/platforms/ios/cmake/Modules") diff --git a/platforms/ios/cmake/Toolchains/Toolchain-iPhoneSimulator_Xcode.cmake b/platforms/ios/cmake/Toolchains/Toolchain-iPhoneSimulator_Xcode.cmake index 937079d182..e3ce03b8c4 100644 --- a/platforms/ios/cmake/Toolchains/Toolchain-iPhoneSimulator_Xcode.cmake +++ b/platforms/ios/cmake/Toolchains/Toolchain-iPhoneSimulator_Xcode.cmake @@ -2,7 +2,10 @@ message (STATUS "Setting up iPhoneSimulator toolchain") set (IPHONESIMULATOR TRUE) # Standard settings -set (CMAKE_SYSTEM_NAME iOS) +set(CMAKE_SYSTEM_NAME iOS) +set(CMAKE_SYSTEM_VERSION 6.0) +set(CMAKE_SYSTEM_PROCESSOR "${IOS_ARCH}") + # Include extra modules for the iOS platform files set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/platforms/ios/cmake/Modules")