Cross-platform support for Swift and XCTest

I think I’ve solved the problem of how to build and run Swift-based XCTests, on all platforms where Swift is supported, using CMake. My code is here. It seems like some part of this work ought to be lifted into CMake, so I’m opening this issue to discuss if/how that should be done. Additionally I have some thoughts about how CMake’s existing FindXCTest is structured, which maybe warrant discussion here as well.

Do you think this is best done as a module like FindGTest and its CMake API or something built-in for CMake (i.e., C++ code)? We do now have an experimental feature gate mechanism to aid in deploying this without committing to a stable interface if that would help get more feedback.

I’m not all that well versed in these areas of CMake, but a separate topic might be best to avoid them cluttering each other’s discussions.

Definitely no need to write new C++ code in this case! As noted here I view this mostly as a modernization of the existing FindXCTest so I think FindXCTest (or FindSwiftXCTest if my code can’t be made to work with Objective-C on macOS—I haven’t tried that) would be appropriate.

The one complication I see is that support for non-macOS platforms involves building and running a code generator written in Swift. I don’t know if there’s any precedent for including something like that in CMake… but ideally the whole thing belongs there.

Can we find_program this and it be maintained separately from CMake?

We can do anything. I just don’t know CMake-isms, culture, etc., well enough to know what’s most appropriate, which is part of why I started this discussion rather than just, say, opening a PR.

Ok, that sounds good to me then. Yes, discussion for proposed features starts here; we can open issues as concrete tasks arise.

Since it sounds like maintaining the codegen separately from CMake is an option (it seems to be in Swift because the stdlib contains a Swift parser?), that sounds preferable to me to avoid:

  • new toolchain for CMake packages
  • more development environment needed for CMake developers
  • coupling to CMake’s release schedule

Since it sounds like maintaining the codegen separately from CMake is an option (it seems to be in Swift because the stdlib contains a Swift parser?), that sounds preferable to me

It’s not in the standard library, but it’s a kind of (mostly?) official auxilliary package.

What would you suggest my next steps are then?