fortran_with_cache_dir Function

public function fortran_with_cache_dir(cache_dir) result(command_prefix)

Create a command that runs fortrun with specified cache directory

Arguments

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

Return Value character(len=:), allocatable


Source Code

    function fortran_with_cache_dir(cache_dir) result(command_prefix)
        character(len=*), intent(in) :: cache_dir
        character(len=:), allocatable :: command_prefix

        ! Build command with XDG_CACHE_HOME set
        if (get_os_type() == OS_WINDOWS) then
            ! Windows: use set command inline with proper escaping
            command_prefix = 'cmd /c "set XDG_CACHE_HOME='//trim(escape_quotes(cache_dir))//' && fpm run fortrun --"'
        else
            ! Unix: use environment variable prefix
            command_prefix = 'XDG_CACHE_HOME="'//trim(escape_quotes(cache_dir))//'" fpm run fortrun --'
        end if

    end function fortran_with_cache_dir