fpm_model Module

The fpm package model

Defines the fpm model data types which encapsulate all information required to correctly build a package and its dependencies.

The process (see build_model) for generating a valid fpm_model involves source files discovery (fpm_sources) and parsing (fpm_source_parsing).

Once a valid fpm_model has been constructed, it may be passed to targets_from_sources to generate a list of build targets for the backend.


Source type: FPM_UNIT_* Describes the type of source file — determines build target generation

Source scope: FPM_SCOPE_* Describes the scoping rules for using modules — controls module dependency resolution



TypeVisibility AttributesNameInitial
integer, public, parameter:: FPM_SCOPE_APP =3

Module-use scope is library/dependency and app modules

integer, public, parameter:: FPM_SCOPE_DEP =2

Module-use scope is library/dependency modules only

integer, public, parameter:: FPM_SCOPE_EXAMPLE =5
integer, public, parameter:: FPM_SCOPE_LIB =1

Module-use scope is library/dependency modules only

integer, public, parameter:: FPM_SCOPE_TEST =4

Module-use scope is library/dependency and test modules

integer, public, parameter:: FPM_SCOPE_UNKNOWN =-1

Source has no module-use scope

integer, public, parameter:: FPM_UNIT_CHEADER =6

Source type is c header file

integer, public, parameter:: FPM_UNIT_CSOURCE =5

Source type is c source file

integer, public, parameter:: FPM_UNIT_MODULE =2

Source type is fortran module

integer, public, parameter:: FPM_UNIT_PROGRAM =1

Source type is fortran program

integer, public, parameter:: FPM_UNIT_SUBMODULE =3

Source type is fortran submodule

integer, public, parameter:: FPM_UNIT_SUBPROGRAM =4

Source type is fortran subprogram

integer, public, parameter:: FPM_UNIT_UNKNOWN =-1

Source type unknown

Derived Types

type, public :: fpm_model_t

Type describing everything required to build the root package and its dependencies.


TypeVisibility AttributesNameInitial
character(len=:), public, allocatable:: archiver

Command line to invoke for creating static library

character(len=:), public, allocatable:: c_compiler

Command line name to invoke c compiler

type(dependency_tree_t), public :: deps

Project dependencies

type(string_t), public, allocatable:: external_modules(:)

External modules used

character(len=:), public, allocatable:: fortran_compile_flags

Command line flags passed to fortran for compilation

character(len=:), public, allocatable:: fortran_compiler

Command line name to invoke fortran compiler

type(string_t), public, allocatable:: include_dirs(:)

Include directories

type(string_t), public, allocatable:: link_libraries(:)

Native libraries to link against

character(len=:), public, allocatable:: output_directory

Base directory for build

character(len=:), public, allocatable:: package_name

Name of root package

type(package_t), public, allocatable:: packages(:)

Array of packages (including the root package)

type, public :: srcfile_t

Type for describing a source file


TypeVisibility AttributesNameInitial
integer(kind=int64), public :: digest

Current hash

character(len=:), public, allocatable:: exe_name

Name of executable for FPM_UNIT_PROGRAM

character(len=:), public, allocatable:: file_name

File path relative to cwd

type(string_t), public, allocatable:: include_dependencies(:)

Files INCLUDEd by this source file

type(string_t), public, allocatable:: link_libraries(:)

Native libraries to link against

type(string_t), public, allocatable:: modules_provided(:)

Modules provided by this source file (lowerstring)

type(string_t), public, allocatable:: modules_used(:)

Modules USEd by this source file (lowerstring)

integer, public :: unit_scope =FPM_SCOPE_UNKNOWN

Target module-use scope

integer, public :: unit_type =FPM_UNIT_UNKNOWN

Type of source unit


public subroutine show_model(model)


Type IntentOptional AttributesName
type(fpm_model_t), intent(in) :: model