1
1
module fpm_meta_blas
2
2
use fpm_compiler, only: compiler_t, get_include_flag
3
- use fpm_environment, only: get_os_type, OS_MACOS
3
+ use fpm_environment, only: get_os_type, OS_MACOS, OS_WINDOWS
4
4
use fpm_meta_base, only: metapackage_t, destroy
5
5
use fpm_meta_util, only: add_pkg_config_compile_options
6
6
use fpm_pkg_config, only: assert_pkg_config, pkgcfg_has_package
@@ -36,24 +36,22 @@ subroutine init_blas(this, compiler, error)
36
36
this% has_external_modules = .false.
37
37
38
38
if (get_os_type() == OS_MACOS) then
39
- this% flags = string_t(" -framework Accelerate" )
40
- this% has_build_flags = .true.
41
- this% link_flags = string_t(" -framework Accelerate" )
42
- this% has_link_flags = .true.
43
- return
39
+ if (compile_and_link_flags_supported(this, compiler, " -framework Accelerate" )) then
40
+ call set_compile_and_link_flags(this, compiler, " -framework Accelerate" )
41
+ return
42
+ end if
44
43
end if
45
44
46
45
if (compiler% is_intel()) then
47
- if (get_os_type() == OS_WINDOWS) then
48
- this% flags = string_t(" /Qmkl" )
49
- this% link_flags = string_t(" /Qmkl" )
50
- else
51
- this% flags = string_t(" -qmkl" )
52
- this% link_flags = string_t(" -qmkl" )
46
+ if (get_os_type() == OS_WINDOWS) then
47
+ if (compile_and_link_flags_supported(this, compiler, " /Qmkl" )) then
48
+ call set_compile_and_link_flags(this, compiler, " /Qmkl" )
49
+ return
50
+ end if
51
+ else if (compile_and_link_flags_supported(this, compiler, " -qmkl" )) then
52
+ call set_compile_and_link_flags(this, compiler, " -Qmkl" )
53
+ return
53
54
endif
54
- this% has_build_flags = .true.
55
- this% has_link_flags = .true.
56
- return
57
55
end if
58
56
59
57
! > Assert pkg-config is installed
@@ -73,4 +71,26 @@ subroutine init_blas(this, compiler, error)
73
71
74
72
call fatal_error(error, ' pkg-config could not find a suitable blas package.' )
75
73
end subroutine init_blas
74
+
75
+ function compile_and_link_flags_supported (this , compiler , flags ) result(is_supported)
76
+ class(metapackage_t), intent (in ) :: this
77
+ type (compiler_t), intent (in ) :: compiler
78
+ character (len=* ), intent (in ) :: flags
79
+ logical :: is_supported
80
+
81
+ is_supported = compiler% check_flags_supported( &
82
+ compile_flags= flags, &
83
+ link_flags= flags)
84
+ end function compile_and_link_flags_supported
85
+
86
+ subroutine set_compile_and_link_flags (this , compiler , flags )
87
+ class(metapackage_t), intent (inout ) :: this
88
+ type (compiler_t), intent (in ) :: compiler
89
+ character (len=* ), intent (in ) :: flags
90
+
91
+ this% flags = string_t(flags)
92
+ this% link_flags = string_t(flags)
93
+ this% has_build_flags = .true.
94
+ this% has_link_flags = .true.
95
+ end subroutine set_compile_and_link_flags
76
96
end module fpm_meta_blas
0 commit comments