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

Using FiNeR as a library in a cmake project #17

Open
schwabfk opened this issue Jul 9, 2020 · 3 comments
Open

Using FiNeR as a library in a cmake project #17

schwabfk opened this issue Jul 9, 2020 · 3 comments
Assignees
Labels

Comments

@schwabfk
Copy link

schwabfk commented Jul 9, 2020

(Re-opened from wrongly posted for FLAP)

Dear @szaghi,

I recently started using Fortran for a project and stumbled across your libraries, especially FiNeR (and maybe in the future I'll use FLAP as well).

At the moment, the project is managed with cmake (v3.17) and I have trouble using FiNeR in my project. I tried it two ways:

a) via add_subdirectory (which is advised in your file headers):

  • The first problem I get here, is when i use git submodule add https://github.com/szaghi/FiNeR.git and then git submodule update --init --recursive it already fails when it wants to clone the fortran_tester third party programme. Here I think the problem is an old URL in the .gitmodule file (at the moment: git@github.com:pdebuyl/fortran_tester.git; but should be https://github.com/pdebuyl/fortran_tester perhaps).
  • The second problem is, that cmake (here I am not an expert) somehow does not like your namespaces. Either it has problem with the double colons or the names itself.
  • If I do manual changes to your code (manually copying the fortran_tester, changing all namespaces from :: to -), I get it working.
  • So here my question is, if I use your library wrongly in cmake, or if it is just not yet applicable to newer cmake versions?

b) via FetchContent:

  • This was also new for me, but I saw that cmake has this feature in newer versions to download/compile/include external programmes/libraries during the build process. Hence no third_party directory or similar is needed. Which I find very attractive.
  • Here there is the same problem with the fortran_tester package.
  • Later, unfortunately this fails either with No content details recorded for FiNeR or Failed to get the hash for HEAD.

Do you have an idea how to solve these problem? Perhaps also someone else with more cmake experience has an idea. As I said, I'm also no expert in this field.

Best regards!

EDIT:
For my way of doing it b)
I proceeded a little bit more, but latest now I am also stuck on the namespace problem.
The error message is (but not only for the fortran_tester):

The target name "fortran_tester::doc" is reserved or not valid for certain
CMake features, such as generator expressions, and may result in undefined
behavior.
@szaghi szaghi added the bug label Jul 10, 2020
@szaghi szaghi self-assigned this Jul 10, 2020
@szaghi
Copy link
Owner

szaghi commented Jul 10, 2020

@schwabfk

Thank you very much for reporting this, it is really appreciated. I am sorry for my delay.

Concerning the fortran_tester submodule I'll check soon what is the problem, probably it is my fail.

Concerning the cmake issues, I am very sorry, but I do not use it and I am not able to help you using it: the cmake building files of my libraries are maintained by very kind users, not directly by me. Anyhow, can you elaborate more on

The second problem is, that cmake (here I am not an expert) somehow does not like your namespaces. Either it has problem with the double colons or the names itself.

in particular which are the names raising cmake issues?

I'll try to fix fortran_tester bug soon.

Cheers

@schwabfk
Copy link
Author

@szaghi

Absolutely no problem, thanks for taking the time to look into this.

Regarding the git submodule command issue, I am now pretty sure it's about the URL. In the FLAP library there is a different one used for fortran_tester and there it works perfectly.

For the cmake issue, which arises later, I had basically issues with all the third party libraries used for FiNeR when the name was constructed using a namespace.
So the first one is about fortran_tester::docs (the full error message is the one at the end of my initial post). What I did is simply replace set(NAMESPACE "${PROJECT_NAME}::") with set(NAMESPACE "${PROJECT_NAME}-"). But then it got stuck with the next name containing a double colon. And that throughout all third party libraries.

Just to add one more detail: If I just build and compile the FiNeR library by itself using cmake, there is absolutely no problem regarding the names/namespaces (of course the initial problem with git submodule still persists). So I assume it might be related to the fact, that for me the third party libraries of FiNeR are in fact the third party libraries of a thrid party library I'm using? Perhaps that gets cmake confused (e.g. too many double colons in one name)?

@kostyfisik
Copy link
Contributor

@schwabfk I was able to use FiNeR as a lib in cmake project, see https://github.com/wave-scattering/amos-try (note it is a decoupled project, I haven tracked if my modification we accepted upstream, see https://github.com/wave-scattering/amos-try/blob/master/install-FiNeR.sh for details). I call FiNeR in my code from here https://github.com/wave-scattering/amos-try/blob/master/cylinder2mod/model_parameters.f90

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

No branches or pull requests

3 participants