I need to run a non-cmake sub-build (setuptools based in this case) in a cmake project and pass the linker and compiler command lines to that sub-build. My current implementation writes the command line arguments to a file using lots of generator expressions; the sub-build reads this file in. It is at katana/KatanaPythonSetupSubdirectory.cmake at 4f418f0aeab539c05fd296f3b28c5b7616dc747f · KatanaGraph/katana · GitHub. However, it fails when the new(-ish) cmake because the
HOST_LINK generator expression is used and my code doesn’t handle the
SHELL: magic supported by linker options. I encountered both because cmake 3.20 seems to use those features in FindMPI.cmake and generates them internally, so if the project imports MPI on a machine with CUDA my cmake generation failes with an error:
$<HOST_LINK:...> may only be used with binary targets to specify link options.
- How do I generate a file in a context that correctly handles
$<HOST_LINK:...>? I have tried using the
TARGEToption with a dummy executable target with
file(GENERATE...)but it doesn’t seem to make any difference. (probably because the generator expressions are not processed in the special “linker option” context.)
- Is there a generator expression or other technique that will decode the
SHELL:magic, so I don’t have to do it on the python side?