fpm_version Function

public function fpm_version()

Return the current fpm version from fpm_version_ID as a version type

Arguments

None

Return Value type(version_t)


Source Code

    type(version_t) function fpm_version()

        type(error_t), allocatable :: error

! Accept solution from https://stackoverflow.com/questions/31649691/stringify-macro-with-gnu-gfortran
! which provides the "easiest" way to pass a macro to a string in Fortran complying with both
! gfortran's "traditional" cpp and the standard cpp syntaxes
#ifdef __GFORTRAN__ /* traditional-cpp stringification */
#  define STRINGIFY_START(X) "&
#  define STRINGIFY_END(X) &X"
#else               /* default stringification */
#  define STRINGIFY_(X) #X
#  define STRINGIFY_START(X) &
#  define STRINGIFY_END(X) STRINGIFY_(X)
#endif

        character (len=:), allocatable :: ver_string
#if defined(FPM_RELEASE_VERSION) && !defined(NAGFOR)
        ver_string = STRINGIFY_START(FPM_RELEASE_VERSION)
        STRINGIFY_END(FPM_RELEASE_VERSION)
#else
        ! Fallback to last known version when the macro is undefined, or when the
        ! preprocessor cannot turn it into a string (NAG fpp)
        ver_string = "0.14.1"
#endif

        call new_version(fpm_version,ver_string,error)

        if (allocated(error)) call fpm_stop(1,'*fpm*:internal error: cannot get version - '//error%message)

    end function fpm_version