Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with multiple includes of UseF2Py #21

Closed
mathomp4 opened this issue Dec 3, 2024 · 0 comments · Fixed by #25
Closed

Issues with multiple includes of UseF2Py #21

mathomp4 opened this issue Dec 3, 2024 · 0 comments · Fixed by #25

Comments

@mathomp4
Copy link

mathomp4 commented Dec 3, 2024

Another issue from me, though this one is a bit more basic/CMake-y than #20.

As said in #20, we are looking at maybe moving to use f2py-cmake in our code. In doing so, I encountered an issue. The circumstances are that we have two repos that would like to use it, say A and B. Repo B is standalone, but repo A includes repo B (as a submodule or whatever). Since we want both A and B to be able to build, both A and B have include(UseF2Py) calls in them. However, it seems like UseF2Py.cmake is not set up to handle that. My investigations seem to show it is due to (at least):

  1. The _Python and _Python3 variables not being CACHE
  2. The F2Py::Headers not being GLOBAL

I created a demonstration of this at https://github.com/mathomp4/f2py-cmake-bug which has a case of multiple calls to include(UseF2Py.cmake)

In this repo, I used the:

pipx run f2py-cmake vendor cmake

command to add UseF2Py.cmake in both "repos" and then added "fixed" versions.

So, if you build with -DFIXED_FILE:BOOL=OFF you'll see the original error:

CMake Error at cmake/UseF2Py.cmake:43 (target_link_libraries):
  Target "test_object" links to:

    ::NumPy

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  src/CMakeLists.txt:18 (f2py_object_library)


-- Generating done (0.0s)

But if you run with -DFIXED_FILE:BOOL=ON then it all succeeds.

Note: At this point, all I've shown is this seems to let things build. In the real case where I'm trying to use this, I have no idea how to run any of the code, so perhaps there are more issues, but this at least is something.

I'm hestitant to make a PR with my fix only because, well, I need to do more testing on our end. But this seems to be usable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant