Trouble with fpm and a simple project

Hi All,

I’m moving some of my code with a fpm installation. Most of them are fine. However, for one, I’ve encountered an unexpected problem. It is probably a stupid mistake from my side, but I cannot figure it out.

The project is really simple, an application (in the APP directory) and a single module (in the SRC directory) without no dependencies (see below, the three files).

When I run:

fpm build

I’ve got the following error:

 + mkdir -p build/dependencies
<ERROR> *cmd_run* Targets error: Unable to find source for module dependency: "tnumtana_m" used by "APP/Tnum90.f90"
STOP 1

However, the module « tnumtana_m » is present in the fortran file ( SRC/TnumTana_m.f90).

Furthermore, with a direct compilation:

gfortran SRC/TnumTana_m.f90 APP/Tnum90.f90

I’ve got the executable, which runs without problem.

Any clue about a mistake?

Thanks


I’m running on a Mac M3 (Sonoma) with fpm 0.9.0

fpm.toml
name = "TnumTana"

[[executable]]
name="Tnum90"
source-dir="APP"
main="Tnum90.f90"

[build]
auto-executables = false
auto-examples = false
auto-tests = false

[library]
source-dir=["SRC"]
Tnum90.f90
PROGRAM Tnum_f90
  USE TnumTana_m
  IMPLICIT NONE

  CALL TnumTana_version(.TRUE.)

END PROGRAM Tnum_f90
TnumTana_m.f90
ODULE TnumTana_m
  IMPLICIT NONE
 
CONTAINS

  SUBROUTINE TnumTana_version(write_version)
    IMPLICIT NONE
  
    logical, intent(in) :: write_version

    character (len=*), parameter :: Tnum_version = "unknown: -D__TNUM_VER=?"
    character (len=*), parameter :: Tana_version = "unknown: -D__TANA_VER=?"
  
    character (len=*), parameter :: Tnum_name='Tnum'
    character (len=*), parameter :: Tana_name='Tana'

    IF (write_version) THEN
      write(*,*) '==============================================='
      write(*,*) '==============================================='
      write(*,*) 'Working with ',                             &
                 Tnum_name,trim(adjustl(Tnum_version)),'-',           &
                 Tana_name,trim(adjustl(Tana_version))
      write(*,*) '==============================================='
      write(*,*) '==============================================='
    END IF
  END SUBROUTINE TnumTana_version

END MODULE TnumTana_m

fpm does not support a list of library folders, but just one name.

If you try again with:

[library]
source-dir="SRC"

it should work (it does on my M1, although I’m naming all folders lowercase):

> TnumTana % fpmx run
Project is up to date
 ===============================================
 ===============================================
 Working with Tnumunknown: -D__TNUM_VER=?-Tanaunknown: -D__TANA_VER=?
 ===============================================
 ===============================================
1 Like

Thanks a lot. Indeed, I’ve tried with a list of source directories (the source code are in several directories).

1 Like