From 410b6fdd97e59abb8ccf8c8aa7460d43ba007e1c Mon Sep 17 00:00:00 2001 From: Yang Chao Date: Sun, 7 Jun 2026 15:19:10 +0800 Subject: [PATCH] ios: set Xcode C++ language standard for Apple framework build OpenCV requires C++17, and bundled 3rdparty libraries such as KleidiCV explicitly request CXX_STANDARD 17. With the CMake Xcode generator, however, neither the global CMAKE_CXX_STANDARD nor per-target CXX_STANDARD is emitted as CLANG_CXX_LANGUAGE_STANDARD in the generated project, so those sources are compiled at the toolchain default (pre-C++17) and fail, e.g.: kleidicv/include/kleidicv/traits.h: error: no template named 'is_base_of_v' in namespace 'std'; did you mean 'is_base_of'? Set CLANG_CXX_LANGUAGE_STANDARD=gnu++17 at the project level via CMAKE_XCODE_ATTRIBUTE_* in the shared getCMakeArgs(), so every target in the generated Xcode project (including 3rdparty subprojects) builds with C++17. --- platforms/ios/build_framework.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/platforms/ios/build_framework.py b/platforms/ios/build_framework.py index e1345aa608..2937267419 100755 --- a/platforms/ios/build_framework.py +++ b/platforms/ios/build_framework.py @@ -218,6 +218,12 @@ class Builder: "-DOPENCV_INCLUDE_INSTALL_PATH=include", "-DOPENCV_3P_LIB_INSTALL_PATH=lib/3rdparty", "-DFRAMEWORK_NAME=%s" % self.framework_name, + # With the Xcode generator CMAKE_CXX_STANDARD / per-target + # CXX_STANDARD is not translated into CLANG_CXX_LANGUAGE_STANDARD, + # so bundled 3rdparty libraries that require C++17 (e.g. KleidiCV) + # are compiled at the toolchain default and fail to build. Set the + # standard explicitly at the project level. + "-DCMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD=gnu++17", ] if self.dynamic: args += [