Open brentleyjones opened 3 months ago
@brentleyjones Do you have an example where a Swift package combines c and c++ in the same target? If so, I will use it as a test case.
I don't know of one in the wild. I'm not even 100% sure SwiftPM allows it (though I expect it does). I know Bazel does, and it leads to issues with copts
, so you generally should split them.
Maybe they can't be both C++ and C at the same time? https://github.com/swiftlang/swift-package-manager/blob/ce099264a187759c2f587393bd209d317a0352b4/Sources/PackageModel/Target.swift#L487
I am going to write the support as if it can be one or the other. If we run into a real-world example that says otherwise, I will adjust the logic accordingly.
We shouldn't recommend that users set workspace-wide
--copt
/--cxxopt
flags. Instead we should set the required flags on the{cc,objc}_library
targets. If a target has both C and C++ files, we may need to split the target in two in order to apply the correct flag to each one.