pkgcfg_get_version Function

public function pkgcfg_get_version(package, error) result(screen)

Get package version from pkg-config

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: package

Package name

type(error_t), intent(out), allocatable :: error

Error handler

Return Value type(string_t)


Source Code

type(string_t) function pkgcfg_get_version(package,error) result(screen)

    !> Package name
    character(*), intent(in) :: package
    
    !> Error handler
    type(error_t), allocatable, intent(out) :: error

    integer :: exitcode
    logical :: success
    type(string_t) :: log    
        
    call run_wrapper(wrapper=string_t('pkg-config'), &
                     args=[string_t(package),string_t('--modversion')], &
                     exitcode=exitcode,cmd_success=success,screen_output=log)    
    
    if (success .and. exitcode==0) then 
        call remove_newline_characters(log)
        screen = log
    else
        screen = string_t("")
    end if      

end function pkgcfg_get_version