add_target Subroutine

public subroutine add_target(targets, type, output_file, source, link_libraries)

Allocate a new target and append to target list

Arguments

Type IntentOptional AttributesName
type(build_target_ptr), intent(inout), allocatable:: targets(:)
integer, intent(in) :: type
character(len=*), intent(in) :: output_file
type(srcfile_t), intent(in), optional :: source
type(string_t), intent(in), optional :: link_libraries(:)

Contents

Source Code


Variables

TypeVisibility AttributesNameInitial
integer, public :: i
type(build_target_t), public, pointer:: new_target

Source Code

subroutine add_target(targets,type,output_file,source,link_libraries)
    type(build_target_ptr), allocatable, intent(inout) :: targets(:)
    integer, intent(in) :: type
    character(*), intent(in) :: output_file
    type(srcfile_t), intent(in), optional :: source
    type(string_t), intent(in), optional :: link_libraries(:)

    integer :: i
    type(build_target_t), pointer :: new_target

    if (.not.allocated(targets)) allocate(targets(0))

    ! Check for duplicate outputs
    do i=1,size(targets)

        if (targets(i)%ptr%output_file == output_file) then

            write(*,*) 'Error while building target list: duplicate output object "',&
                        output_file,'"'
            if (present(source)) write(*,*) ' Source file: "',source%file_name,'"'
            call fpm_stop(1,' ')

        end if

    end do

    allocate(new_target)
    new_target%target_type = type
    new_target%output_file = output_file
    if (present(source)) new_target%source = source
    if (present(link_libraries)) new_target%link_libraries = link_libraries
    allocate(new_target%dependencies(0))

    targets = [targets, build_target_ptr(new_target)]

end subroutine add_target