ksubox
(Ksubox)
1
Hello,
I want to build cross platform package which heavily use c++23 features, but can't build it with SPM.
With CMake it works fine for Linux/OSX/iOS/Win with
set(CMAKE_CXX_STANDARD 23)
But SPM supports CXXLanguageStandard only up to c++20.
I tried to remove CXXLanguageStandard and add flags
.unsafeFlags(["-std=c++23"])
But compiler complains and allow to specify up to
.unsafeFlags(["-std=c++2b"])
Which unfortunately can't help to compile.
I don't have intentions to expose C++23 features to Swift level, just to use internally in c++ target.
Do you have any suggestions to organize C++23 code in cross platform Swift package ?
C23 and C++23 are supported, via the C2x and C++2b aliases.
// swift-tools-version: 5.6
import PackageDescription
let package = Package(
name: "…",
products: […],
dependencies: […],
targets: […],
// Use the C23 and C++23 modes,
// for all targets in this package.
cLanguageStandard: .c2x, // or `.gnu2x`
cxxLanguageStandard: .cxx2b // or `.gnucxx2b`
)
SwiftPM doesn't support mixed-language targets yet. SE-0403 was "returned for revision" last year.