Turns out this was a bug in the library itself and not just a basic misunderstanding of cmake. The problem is addressed in https://github.com/Goddard-Fortran-Ecosystem/pFUnit/pull/485
As pointed out by @Tsyvarev, the scoping of PFUNIT_DRIVER
was the source of the problem. The sledgehammer solution was to cache this variablee (i.e., using the CACHE
) so that the variable is visible at all scopes.