I was able to resolve this. The trouble seems to be that the original scikit-build
with distutils
did a lot on its own to include necessary f2py libraries, and I wasn't including the right.
The call to f2py, and subsequent code adding the library and linking it, should be this:
add_custom_command(
OUTPUT calc11module.c calc11-f2pywrappers.f calc11-f2pywrappers2.f90
DEPENDS ${includes}
VERBATIM
COMMAND "${Python_EXECUTABLE}" -m numpy.f2py
"${fortran_src_file}" -m ${f2py_module_name} --lower
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
python_add_library(
${f2py_module_name}
MODULE
"${CMAKE_CURRENT_BINARY_DIR}/calc11-f2pywrappers2.f90"
"${CMAKE_CURRENT_BINARY_DIR}/calc11-f2pywrappers.f"
"${CMAKE_CURRENT_BINARY_DIR}/calc11module.c"
"${fortran_src_file}"
WITH_SOABI)
target_link_libraries(${f2py_module_name} PRIVATE fortranobject)
The "f2pywrapper" files provide the necessary API for Python functions. This links correctly, and now it runs.