1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-21 19:33:03 +04:00

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.
This commit is contained in:
Yang Chao
2026-06-07 15:19:10 +08:00
parent 43dd75bf43
commit 410b6fdd97
+6
View File
@@ -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 += [