acroucher/zofu

Can't open module file ‘zofu.mod’

vincentmr opened this issue · 2 comments

I am trying to setup the "adder_tests" example. I created a module which defines the adder_type in ./src and the following meson.build file, which is a bit different than the one in the repo because of the zofu library location.

project('adder', ['fortran'])

# find zofu library: https://github.com/mesonbuild/meson/issues/3926
cmplr = meson.get_compiler('fortran')  
local_lib_dir = '/home/vince/.local/lib'
deps = []
foreach libname : ['zofu']
    deps += [cmplr.find_library(libname, dirs : local_lib_dir)]
endforeach

src_dir = join_paths(meson.current_source_dir(), 'src')
adder = shared_library('adder', join_paths(src_dir, 'adder_module.F90'))

test_dir = join_paths(meson.current_source_dir(), 'test')
test_name = 'adder_tests'
test = join_paths(meson.current_source_dir(),
                      'tests', test_name + '.F90')
driver_src_name = test_name + '_driver.F90'

test_driver_src = configure_file(
  output: driver_src_name,
  command: ['zofu-driver', test, driver_src_name])
test_exe = executable('adder_tests',
                      [test_driver_src, test],
                      link_with: adder,
                      dependencies: deps)
test('adder_tests', test_exe)

I then call

meson --wipe build && ninja -C build

The first command succeeds, but ninja fails as follows

Fatal Error: Can't open module file ‘zofu.mod’ for reading at (1): No such file or directory
compilation terminated.

I am wondering what is the correct way to solve this.

It looks like the main thing you are doing differently is locating the Zofu library, using cmplr.find_library() instead of declaring Zofu as a dependency using zofu = dependency('zofu'). And the fact that it is complaining about not finding the Zofu module suggests that the way you're trying to do it isn't working.

I don't quite understand what is preventing you from using dependency(). Can pkg-config not find Zofu if you do it that way? If so is that just a matter of setting $PKG_CONFIG_PATH so it can find the Zofu pkg-config file?

Setting PKG_CONFIG_PATH solved the problem indeed. I must have made a mistake in the path originally and then got carried away. Thanks.