scikit-build / cython-cmake

CMake helpers for building Cython modules
Apache License 2.0
8 stars 1 forks source link

cython as a CMake Language #46

Open LecrisUT opened 2 months ago

LecrisUT commented 2 months ago

Quite some time ago I was researching adding a CMake language using CMake<Lang>Information.cmake with a prototype using Fypp. I don't remember where I've left off in that process, but iirc the issue was on the Fortran side. Probably for C/C++ adding a language as a preprocessor would still work.

Alternatively, for fypp I ended up writing it as Fypp_target_sources instead. That could also be a more CMakey way of implementing this support.

Has anyone else looked into the adding custom language approach?

henryiii commented 1 month ago

I don't think this is the correct approach. Cython is a transpiler. You still need a language compiler (C or CXX) to compile the file that Cython transpiles. You'd still need C or CXX settings, etc, on the targets.

LecrisUT commented 1 month ago

You can combine compiled objects from different languages. The issue that I've encountered is that even aa I generate the C/CXX file, I cannot trick CMake to add it as a source when inside the CMake<Lang>Information.cmake. This would need some patches upstream to allow chaining of target_spurces based on input and output extensions.

Any specific concerns about an Cython_target_sources which simply chains the transpile and target_sources command?