Goddard-Fortran-Ecosystem / pFUnit_demos

Pedagogical examples for using pFUnit
Apache License 2.0
17 stars 7 forks source link

Problems building with `add_subdirectory` #15

Open vegardjervell opened 1 month ago

vegardjervell commented 1 month ago

Hi,

We've been using pFUnit for some time for a library, and have been building the test suite with make. I'm working on a build system using cmake now, and I had some trouble getting the test suite to build when I include pFUnit using add_subdirectory, which I would like to do so that I could set up pFUnit as a git submodule in our project and more easily run fully automated building/testing. An example here of how you would set that up would be greatly appreciated!

I eventually got a working solution together, and put up a minimal example here. Feel free to use that however you wish :)

tclune commented 1 month ago

The approach that we have been using can be seen at https://github.com/Goddard-Fortran-Ecosystem/GFE

Unfortunately, I don't have time at the moment to drill down to see just what is different from your approach, if any. But I will add that supporting variant ways to include pFUnit has been rather expensive in terms of maintenance costs. Hopefully you've latched onto something that is already supported.

Cheers.

(notifying @mathomp4)

mathomp4 commented 1 month ago

As @tclune says, GFE essentially does use git submodules and add_subdirectory(). So we do a git clone and git submodule update --init say.

I will say I have thought at some point to look at CPM.cmake where with the right setup you could do:

CPMAddPackage("gh:Goddard-Fortran-Ecosystem/pFUnit@x.y.z")

It seemed clever, but I've never had time to try it out...

vegardjervell commented 1 month ago

Thanks! It looks like I've done pretty much the same as what you're doing. The trouble I was having was related to some compiler flags I was setting for my library that didn't play nicely with pFUnit, mostly as a result of my own inexperience with cmake. Regardless, it could be helpful to have an example here showing how it can be done properly for future reference.

I'll put up a PR with my working example in case it can be helpful for someone else, and you can do as you like with it, including postponing looking at it for however long you want ;)