Wrapping a fortran library from FetchContent #609
MuellerSeb
started this conversation in
Show and tell
Replies: 1 comment
-
@MuellerSeb thank you for sharing! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey there,
since I struggled a lot to get this working, I'd like to share a solution with you!
Aim
Compile a fortran shared library from FetchContent and provide a python wrapper with a set of interfaces that is linked against this shared library by using f2py.
Problem
I needed to set the rpath in the f2py generated SO
Solution
Magic happens in this line:
f2py has no option to pass linker flags other than setting the env-var
LDFLAGS
and to set these env-vars in a custom command, I had to wrap the f2py-call with Cmakes Command Line Tool Mode. Also theNPY_DISTUTILS_APPEND_FLAGS
env-var needs to be altered so numpy respects theLDFLAGS
.Maybe this is useful for someone. The solution does not target windows systems.
Cheers,
Sebastian
Beta Was this translation helpful? Give feedback.
All reactions