-
Notifications
You must be signed in to change notification settings - Fork 108
Support for C and C++ source files and linking everything together #353
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
Comments
I will have a mixed Fortran/C++ package available soon (it's an interface to the nanoflann k-d tree library in C++). My current plan was to put
inside One issue I'm afraid of is that in C++ different conventions exist in practice ( For more complex C/C++ dependencies it might be a better idea to delegate them to a conan or CMake adaptor. In Rust they have a cmake crate which uses the two-way build script interface. Vice-versa, C++ projects which would depend on |
It is tempting to also make Given that we will have CMake (#69) backends, I would love to make In fact, I am looking forward to start new C++ projects by simply creating an fpm package (by adding some option to I think we can support all the cc @milancurcic |
In CMake, you need to manually specify the linker language is Fortran when adding executable targets in Fortran that depend on C++ libraries:
Alternatively, you need to play with the CMAKE_<LANG>_LINKER_PREFERENCE setting. Apparently the default preference rules give C++ higher priority. With the Intel Fortran compiler, when the executable is in C and depends on a Fortran subprogram, and linking is performed with
Ditto. I just spent the last 2 hours creating CMake files for my mixed Fortran/C++ project of five files... |
Well, there is dds as C++ counterpart to |
@awvwgk finally somebody is doing it! Thanks for the link. |
@wclodius2 @jvdp1 This might be needed to allow using C++ in the fpm version of stdlib (wclodius2/stdlib#6) |
Fpm already has a preliminary support for C and C++ source files. But there are still some issues to iron out. Here are a few that I am aware of, we should create individual issues out of these and link them here.
One issue is that you currently have to manually specify
stdc++
infpm.toml
. It should work automatically.I think we need to add tests for this and test it at our CI.
Document this feature in our documentation
Ensure this works with MPI. Fpm does not support MPI yet, so we should add support first (Support MPI natively #354). I remember there being issues regarding whether the main program has to be linked as a C++ or Fortran project.
The text was updated successfully, but these errors were encountered: