I’m trying to modify a test declared with ADD_TEST_MACRO to check that multiple configurations can be built with the same build directory and a single cmake configure invocation. Is there a non-hacky technique for that? It’s not obvious from the code.
Edit: Actually, let me add a second question here. I found a hacky way to do it, revealing a bug in the Ninja Multi-Config generator. The nature of the bug is that files that should have been separated per-configuration are not. That seems like an easy mistake to make in all kinds of areas of CMake, not just in Swift-specific code like the test I added. Shouldn’t all the tests be run that way when the generator is multi-config?
When configured with a multi-config generator, running tests with ctest requires specifying what configuration to test. For example, ctest -C Debug runs tests using the bin/Debug/{cmake,ctest,...} binaries from the current build tree. If one has built multiple configurations of CMake itself, the test suite can be run separately in each configuration. The tests themselves sometimes have config-specific behavior, but we have no model for testing multiple configurations simultaneously.
We do have tests for per-config artifact locations, but none for Swift.
In general when you want more control over the testing sequence, such as configuring once and building with multiple configurations, the “RunCMake” infrastructure is best. See Tests/RunCMake/README.rst. Grep through Tests/RunCMake/*/RunCMakeTest.cmake for use of --build to see cases where we run the build after running cmake in the test.