George
1
I'm at the moment trying to package a C++ library in a way that it can be used with a SwiftPM project via C++ interop. I've got it working almost-perfectly, but the one remaining issue is that I have to specify the "-std=c++17" flag via the unsafeFlags CSetting in SwiftPM, which (as I understand it) prevents the package from being depended on. I tried adding this flag to the pkg-config file but I get warning: prohibited flag(s): -std=c++17.
On macOS, I can probably work around this by creating an xcframework that can be depended on, but on Linux IIRC the only way to depend on a precompiled binary at the moment is via systemLibrary.
Any advice on how to get this to work?
yaglo
(Stanislav Yaglo)
2
Does putting “requires cplusplus17” in the module.modulemap automatically update flags or will it just ignore the module if the flag wasn’t provided?
George
3
When I try that I just get an error:
error: module 'MyModule' requires feature 'cplusplus17'
Alex_L
(Alex Lorenz)
5
You need to use the cxxLanguageStandard: .cxx17 in your package manifest. Note that it applies to the entire package and not a target
1 Like
George
6
This worked, thanks for always having the answer to my questions so quickly, Alex!
Interestingly, this works with both requires cplusplus and requires cplusplus17 in the module map.
Alex_L
(Alex Lorenz)
7
The requires directives in the module map are only used to verify the language mode used by the Clang importer in Swift, it doesn't actually change the settings like whether C++ is enabled, or which standard is used.