opencv: CMake Error at cmake/OpenCVCompilerOptimizations.cmake:611 - Compiler doesn't support baseline optimization flags

System Information

Python version: 3.11.2 OpenCV version: 4.x Mac version: Monterey 12.6 XCode version: 14.2

Detailed description

Have a React Native project integrating with OpenCV where the simulator isn’t working due to architecture difference. https://github.com/opencv/opencv/issues/21926

Then tried to follow the steps in: https://github.com/opencv/opencv/tree/4.x/platforms/ios https://github.com/opencv/opencv/tree/4.x/platforms/apple

But when trying to run: python opencv/platforms/apple/build_xcframework.py --out ./build_xcframework

Keep getting an error:

CMake Error at cmake/OpenCVCompilerOptimizations.cmake:611 (message):
  Compiler doesn't support baseline optimization flags:
Call Stack (most recent call first):
  cmake/OpenCVCompilerOptions.cmake:327 (ocv_compiler_optimization_options)
  CMakeLists.txt:650 (include)

Steps to reproduce

git clone https://github.com/opencv/opencv.git 

Then try to follow the steps in:
https://github.com/opencv/opencv/tree/4.x/platforms/ios
https://github.com/opencv/opencv/tree/4.x/platforms/apple

Issue submission checklist

  • I report the issue, it’s not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 9
  • Comments: 17

Most upvoted comments

I am facing the same error while trying to build the xcframework to support multiple architecture with this command:

python3 opencv/platforms/apple/build_xcframework.py \
--out ./opencv-build \
--contrib opencv_contrib \
--iphoneos_archs armv7,armv7s,arm64 \
--iphonesimulator_archs arm64 \
--build_only_specified_archs

The error is:

=================================
CMake
=================================

Executing: ['cmake', '-GXcode', '-DAPPLE_FRAMEWORK=ON', '-DCMAKE_INSTALL_PREFIX=install', '-DCMAKE_BUILD_TYPE=Release', '-DOPENCV_INCLUDE_INSTALL_PATH=include', '-DOPENCV_3P_LIB_INSTALL_PATH=lib/3rdparty', '-DFRAMEWORK_NAME=opencv2', '-DIOS_ARCH=armv7', '-DCMAKE_TOOLCHAIN_FILE=/Users/michele/Development/software/opencv/opencv/platforms/ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake', '-DCPU_BASELINE=DETECT', '/Users/michele/Development/software/opencv/opencv', '-DOPENCV_EXTRA_MODULES_PATH=/Users/michele/Development/software/opencv/opencv_contrib/modules', '-DCMAKE_C_FLAGS=-fembed-bitcode', '-DCMAKE_CXX_FLAGS=-fembed-bitcode'] in /Users/michele/Development/software/opencv/opencv-build/iphoneos/build/build-armv7-iphoneos
Executing: cmake -GXcode -DAPPLE_FRAMEWORK=ON -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DOPENCV_INCLUDE_INSTALL_PATH=include -DOPENCV_3P_LIB_INSTALL_PATH=lib/3rdparty -DFRAMEWORK_NAME=opencv2 -DIOS_ARCH=armv7 -DCMAKE_TOOLCHAIN_FILE=/Users/michele/Development/software/opencv/opencv/platforms/ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake -DCPU_BASELINE=DETECT /Users/michele/Development/software/opencv/opencv -DOPENCV_EXTRA_MODULES_PATH=/Users/michele/Development/software/opencv/opencv_contrib/modules -DCMAKE_C_FLAGS=-fembed-bitcode -DCMAKE_CXX_FLAGS=-fembed-bitcode
-- Setting up iPhoneOS toolchain for IOS_ARCH='armv7'
-- iPhoneOS toolchain loaded
-- Detected processor: armv7
-- Looking for ccache - not found
-- VFPV3 is not supported by C++ compiler
-- NEON is not supported by C++ compiler
-- FP16 is not supported by C++ compiler
CMake Error at cmake/OpenCVCompilerOptimizations.cmake:611 (message):
  Compiler doesn't support baseline optimization flags:
Call Stack (most recent call first):
  cmake/OpenCVCompilerOptions.cmake:327 (ocv_compiler_optimization_options)
  CMakeLists.txt:650 (include)

@krjw-eyev did not change anything for me =(

Removing the armv7 and armv7s target architectures and keeping only arm64 worked for me.

My setup: Apple clang version 14.0.3 (clang-1403.0.22.14.1) Target: x86_64-apple-darwin22.4.0 Thread model: posix