[cmake] Build swift-testing with CMake.
Add files needed to build swift-testing with CMake.
Motivation:
Being able to build with CMake is useful in many scenarios. The immediate need is to bring swift-testing to Windows. To do so we need to support a non-SPM path to allow building targets that would otherwise hit the export symbol limit on Windows.
Modifications:
- Added CMake files to build
Testing,TestingInternal, andTestingMacros. - Build
TestingMacrosas anExternalProjecttargeting the build machine. - Add
SwiftTesting_GenerateDerivedSourceswhich generates arunner-swift-testing.swiftand returns a variable that allows consumers to compile it with their sources.
Result:
- Can build
swift-testingwith CMake. Example command lines:
cmake -S . -B b -G Ninja -D CMAKE_CXX_COMPILER=clang
cmake --build .\b
-
Example diff that converts
swift-webdriverto useswift-testingvia CMake.
Checklist:
- [X] Code and documentation should follow the style of the Style Guide.
- [X] If public symbols are renamed or modified, DocC references should be updated.
Thank you @jeffdav! Appreciate the helpful contribution. I have several comments so far and will take a second pass tomorrow
Open question: how do we test this change?
@jeffdav Could we ask you to just push additional commits so it's easier for us to see incremental changes? We'll squash the whole thing when we merge the PR. Thanks!
No problem. I wasn't sure what the right thing to do was. I'd honestly prefer incremental diffs. :)
Oh, but github does have a little "compare" link next to each force-push, which I hadn't realized.
Something else for you to consider: we should have instructions somewhere (perhaps in a dedicated .md file in Documentation/) showing how to build swift-testing from source using CMake.
Something else for you to consider: we should have instructions somewhere (perhaps in a dedicated .md file in Documentation/) showing how to build swift-testing from source using CMake.
Added. I'd love feedback on the documentation (consider this a 1st draft).
Holding off on approval because I am not in a position to audit the CMake bits, not myself understanding anything about CMake. @etcwilde would you please review?
@swift-ci please test
@grynspan any further concerns on your side?
Nope, I defer to @etcwilde here.
(FYI we don't use Swift's C++ interop feature, so its lack of support for exceptions doesn't make a difference to us. However, we also don't throw any exceptions or intend to catch any, so it's moot.)
Oh—please update the file lists before merging. There are a number of new files added since you opened this PR.
Oh—please update the file lists before merging. There are a number of new files added since you opened this PR.
Done!
@swift-ci please test
@jeffdav I know you folks obviously work with Windows. The Windows failure we're seeing is a compiler bug unrelated to your PR. If you're comfortable with merging the PR despite the failure, we can proceed. (I'm unsure if you can see a merge button—if not, ping me and I'll do it.)
@jeffdav I know you folks obviously work with Windows. The Windows failure we're seeing is a compiler bug unrelated to your PR. If you're comfortable with merging the PR despite the failure, we can proceed. (I'm unsure if you can see a merge button—if not, ping me and I'll do it.)
Yeah, I'm familiar with that compiler bug for other reasons. :)
@grynspan Thanks for your help! I don't have a merge button.
@swift-ci please test