Re:My Favorite C++ Pattern: X Macros (2023)
by rcxdude on Tuesday March 25, 2025 @02:26PM
(#43474298)
CMake has a particularly irritating flaw here, though, in that it makes no distinction between host and target which cross-compiling, which makes it really difficult to do this kind of code generation when supporting this use-case (which is becoming more and more commoon).
[ Parent
| on HN ]
Re:My Favorite C++ Pattern: X Macros (2023)
by MITSardine on Tuesday March 25, 2025 @02:41PM
(#43474424)
Right, I hadn't thought of that, to be honest. If I understand correctly, you're saying the codegen targets will be compiled to the target arch, and then can't be run on the machine doing the compiling?
I think one solution might be to use target_compile_options() which lets you specify flags per target (instead of globally), assuming you're passing flags to specify the target architecture.
Re:My Favorite C++ Pattern: X Macros (2023)
by rcxdude on Tuesday March 25, 2025 @04:22PM
(#43475509)
That only works if it's mostly the same compiler, unfortunately. They could be completely different executables, calling conventions, etc. I don't know why CMake still has such a huge hole in its feature set, but it's quite unfortunate.