Automate macro expansion to inline code

Correct me if I'm wrong, but it seems to me that Swift Macros run hand in hand with SwiftPM. Now, I have a project whose cross-platform build process relies heavily on CMake, so I'm evaluating a different option than making macros work in CMake –if it's ever been a thing.

Xcode has a "Refactor > Inline Macro" menu that does what I need, which is running the macro on the target entity and producing the actual code. Well, I wonder if there's a way to do this from the command line, as in a codegen-like behavior. I don't need the generated code to be 100% in sync with the original source. I'm okay with doing it manually from time to time, but I need it to be easy to automate, as in "inline all the macros that you find in the codebase".

I haven't found a viable solution so far. Am I hopeless?

Thanks

SwiftPM builds macro implementations and passes them to the compiler so that they can be used in expansions, but this is possible from (and the responsibility of) any build system. Ultimately, you need to get the executable built and pass it to the compiler using the -load-plugin-executable <executable path>#<comma-delimited list of module names> flag.

For example, Bazel supports it by letting a swift_library target (which represent a module) depend on a swift_compiler_plugin target (which represents the macro).

I don't have much experience with CMake, so I'll defer to the owners of the Swift integration to speak on how macros are supported today. But you should never be required to manually expand the macros to get your code compiling.