This module handles the construction of the build target list
 from the sources list ([[targets_from_sources]]), the
 resolution of module-dependencies between build targets
 ([[resolve_module_dependencies]]), and the enumeration of
 objects required for link targets ([[resolve_target_linking]]).
A build target ([[build_target_t]]) is a file to be generated
 by the backend (compilation and linking).
@note Note
      The current implementation is ignorant to the existence of
     module files (.mod,.smod). Dependencies arising from modules
     are based on the corresponding object files (.o) only.
For more information, please read the documentation for the procedures:
[[build_target_list]][[resolve_module_dependencies]]Target type: FPM_TARGET_*
 Describes the type of build target — determines backend build rules
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public, | parameter | :: | FPM_TARGET_ARCHIVE | = | 2 | Target type is library archive | 
| integer, | public, | parameter | :: | FPM_TARGET_CPP_OBJECT | = | 5 | Target type is cpp compiled object | 
| integer, | public, | parameter | :: | FPM_TARGET_C_OBJECT | = | 4 | Target type is c compiled object | 
| integer, | public, | parameter | :: | FPM_TARGET_EXECUTABLE | = | 1 | Target type is executable | 
| integer, | public, | parameter | :: | FPM_TARGET_OBJECT | = | 3 | Target type is compiled object | 
| integer, | public, | parameter | :: | FPM_TARGET_SHARED | = | 6 | Target type is a shared library | 
| integer, | public, | parameter | :: | FPM_TARGET_UNKNOWN | = | -1 | Target type is unknown (ignored) | 
Allocate a new target and append to target list
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(build_target_ptr), | intent(inout), | allocatable | :: | targets(:) | ||
| character(len=*), | intent(in) | :: | package | |||
| integer, | intent(in) | :: | type | |||
| character(len=*), | intent(in) | :: | output_name | |||
| type(srcfile_t), | intent(in), | optional | :: | source | ||
| type(string_t), | intent(in), | optional | :: | link_libraries(:) | ||
| type(fortran_config_t), | intent(in), | optional | :: | features | ||
| type(preprocess_config_t), | intent(in), | optional | :: | preprocess | ||
| type(version_t), | intent(in), | optional | :: | version | ||
| character(len=*), | intent(in), | optional | :: | output_dir | 
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(build_target_ptr), | intent(inout), | allocatable | :: | targets(:) | ||
| type(build_target_ptr), | intent(in) | :: | add_target | 
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(build_target_ptr), | intent(inout), | allocatable | :: | targets(:) | ||
| type(build_target_ptr), | intent(in) | :: | add_targets(:) | 
Add one or multiple build target pointers to array (gcc-15 bug workaround)
Add one build target pointer to array with a loop (gcc-15 bug on array initializer)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(build_target_ptr), | intent(inout), | allocatable | :: | list(:) | ||
| type(build_target_ptr), | intent(in) | :: | new | 
Add multiple build target pointers to array with a loop (gcc-15 bug on array initializer)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(build_target_ptr), | intent(inout), | allocatable | :: | list(:) | ||
| type(build_target_ptr), | intent(in) | :: | new(:) | 
Wrapper type for constructing arrays of [[build_target_t]] pointers
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| type(build_target_t), | public, | pointer | :: | ptr | => | null() | 
Type describing a generated build target
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| character(len=:), | public, | allocatable | :: | compile_flags | Compile flags for this build target | ||
| type(build_target_ptr), | public, | allocatable | :: | dependencies(:) | Resolved build dependencies | ||
| integer(kind=int64), | public, | allocatable | :: | digest_cached | Previous source file hash | ||
| type(fortran_config_t), | public | :: | features | Language features | |||
| character(len=:), | public, | allocatable | :: | link_flags | Link flags for this build target | ||
| type(string_t), | public, | allocatable | :: | link_libraries(:) | Native libraries to link against | ||
| type(string_t), | public, | allocatable | :: | link_objects(:) | Objects needed to link this target | ||
| type(string_t), | public, | allocatable | :: | macros(:) | List of macros | ||
| character(len=:), | public, | allocatable | :: | output_dir | File path of output directory | ||
| character(len=:), | public, | allocatable | :: | output_file | File path of build target object relative to cwd | ||
| character(len=:), | public, | allocatable | :: | output_log_file | File path of build log file relative to cwd | ||
| character(len=:), | public, | allocatable | :: | output_name | File path of build target object relative to output_dir | ||
| character(len=:), | public, | allocatable | :: | package_name | Name of parent package | ||
| integer, | public | :: | schedule | = | -1 | Targets in the same schedule group are guaranteed to be independent | |
| logical, | public | :: | skip | = | .false. | Flag set if build target will be skipped (not built) | |
| logical, | public | :: | sorted | = | .false. | Flag set if build target is sorted for building | |
| type(srcfile_t), | public, | allocatable | :: | source | Primary source for this build target | ||
| integer, | public | :: | target_type | = | FPM_TARGET_UNKNOWN | Target type | |
| logical, | public | :: | touched | = | .false. | Flag set when first visited to check for circular dependencies | |
| type(version_t), | public, | allocatable | :: | version | Version number | 
| procedure, public :: info | Print information on this instance | 
| procedure, public :: is_executable_target | |
| procedure, public :: set_output_dir | Set output directory | 
Target type name
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | type | 
Allocate a new target
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | package | |||
| integer, | intent(in) | :: | type | |||
| character(len=*), | intent(in) | :: | output_name | |||
| type(srcfile_t), | intent(in), | optional | :: | source | ||
| type(string_t), | intent(in), | optional | :: | link_libraries(:) | ||
| type(fortran_config_t), | intent(in), | optional | :: | features | ||
| type(preprocess_config_t), | intent(in), | optional | :: | preprocess | ||
| type(version_t), | intent(in), | optional | :: | version | ||
| character(len=*), | intent(in), | optional | :: | output_dir | 
Add pointer to dependeny in target%dependencies
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(build_target_t), | intent(inout) | :: | target | |||
| type(build_target_t), | intent(in), | target | :: | dependency | 
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(build_target_ptr), | intent(in) | :: | targets(:) | |||
| integer, | intent(in) | :: | scope | |||
| type(string_t), | intent(out), | allocatable | :: | list(:) | 
Returns pointers to all library targets
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(build_target_ptr), | intent(in) | :: | targets(:) | |||
| type(build_target_ptr), | intent(out), | allocatable | :: | list(:) | 
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(build_target_ptr), | intent(in) | :: | targets(:) | |||
| type(string_t), | intent(out), | allocatable | :: | list(:) | 
Add link directories for all shared libraries in the dependency graph
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(fpm_model_t), | intent(in) | :: | model | |||
| type(build_target_ptr), | intent(inout), | target | :: | targets(:) | ||
| type(string_t), | intent(out), | allocatable | :: | shared_lib_dirs(:) | 
Add dependencies to source-based targets (FPM_TARGET_OBJECT)
 based on any modules used by the corresponding source file.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(build_target_ptr), | intent(inout), | target | :: | targets(:) | ||
| type(string_t), | intent(in) | :: | external_modules(:) | |||
| type(error_t), | intent(out), | allocatable | :: | error | 
High-level wrapper to generate build target information
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(build_target_ptr), | intent(out), | allocatable | :: | targets(:) | The generated list of build targets | |
| type(fpm_model_t), | intent(inout), | target | :: | model | The package model from which to construct the target list | |
| logical, | intent(in) | :: | prune | Enable tree-shaking/pruning of module dependencies | ||
| type(library_config_t), | intent(in), | optional | :: | library | Library build configuration | |
| type(error_t), | intent(out), | allocatable | :: | error | Error structure |