csdms / bmi-fortran

Basic Model Interface for Fortran
https://bmi.readthedocs.io
MIT License
6 stars 10 forks source link

CMake: refactor a few items #47

Closed mwtoews closed 9 months ago

mwtoews commented 1 year ago
mdpiper commented 1 year ago

@mwtoews This is really helpful, thank you!

mwtoews commented 1 year ago

Note that in a related repo, I see https://github.com/csdms/bmi-c/commit/a61e7f9f794d382f2147e10a04d806957d07ea6a Shouldn't system-specific dirs like lib64 be ok?

mdpiper commented 1 year ago

Note that in a related repo, I see csdms/bmi-c@a61e7f9 Shouldn't system-specific dirs like lib64 be ok?

I agree. I'm not sure why this caused a problem. Perhaps on Windows? I'll have to look at my notes. Definitely an argument for a better commit message.

mwtoews commented 1 year ago

On a related note, I've also been thinking about bunding cmake-packages, for example here. This effort would enable other BMI applications to use:

find_package(bmif CONFIG REQUIRED)
add_executable(my_bmi_app my_bmi_app.f90)
target_link_libraries(my_bmi_app bmif::bmif_static)

which is more standard in CMake projects (it's also way more logic to add compared to pkg-config, as is done with bmi-c). There is a bit of careful handing around the *.mod files, which are slightly outside CMake norms. What do you think?

mdpiper commented 9 months ago

@mwtoews I apologize for disappearing for awhile. I finally have some time to work on BMI stuff again.

I'll merge this PR because what's you've proposed here is the right thing to do. I'll also apply your changes to the other BMI specs (C, C++) built with CMake.

I'd genuinely appreciate your help with cmake-packages. Recently, I've run into a few places where this would've been handy. If you send a PR to this repo, I can learn from what you've done & apply it to the other BMI specs.