Skip to content

Commit d314aed

Browse files
author
Carlos Une
authored
Change link command on Windows with ifort or ifx (#590)
* Check whether compiler is `ifort` or `ifx` on Windows * Linker command with ifort/ifx on Windows * Enumerate libraries, based on compiler and platform
1 parent df9b01a commit d314aed

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/fpm_compiler.f90

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ module fpm_compiler
9494
procedure :: link
9595
!> Check whether compiler is recognized
9696
procedure :: is_unknown
97+
!> Enumerate libraries, based on compiler and platform
98+
procedure :: enumerate_libraries
9799
end type compiler_t
98100

99101

@@ -593,6 +595,23 @@ pure function is_unknown(self)
593595
is_unknown = self%id == id_unknown
594596
end function is_unknown
595597

598+
!>
599+
!> Enumerate libraries, based on compiler and platform
600+
!>
601+
function enumerate_libraries(self, prefix, libs) result(r)
602+
class(compiler_t), intent(in) :: self
603+
character(len=*), intent(in) :: prefix
604+
type(string_t), intent(in) :: libs(:)
605+
character(len=:), allocatable :: r
606+
607+
if (self%id == id_intel_classic_windows .or. &
608+
self%id == id_intel_llvm_windows) then
609+
r = prefix // " " // string_cat(libs,".lib ")//".lib"
610+
else
611+
r = prefix // " -l" // string_cat(libs," -l")
612+
end if
613+
end function enumerate_libraries
614+
596615

597616
!> Create new compiler instance
598617
subroutine new_compiler(self, fc, cc)

src/fpm_targets.f90

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ subroutine resolve_target_linking(targets, model)
466466
global_link_flags = ""
467467
if (allocated(model%link_libraries)) then
468468
if (size(model%link_libraries) > 0) then
469-
global_link_flags = global_link_flags // " -l" // string_cat(model%link_libraries," -l")
469+
global_link_flags = model%compiler%enumerate_libraries(global_link_flags, model%link_libraries)
470470
end if
471471
end if
472472

@@ -518,10 +518,8 @@ subroutine resolve_target_linking(targets, model)
518518

519519
if (allocated(target%link_libraries)) then
520520
if (size(target%link_libraries) > 0) then
521-
target%link_flags = target%link_flags &
522-
& // " -l" // string_cat(target%link_libraries," -l")
523-
local_link_flags = local_link_flags &
524-
& // " -l" // string_cat(target%link_libraries," -l")
521+
target%link_flags = model%compiler%enumerate_libraries(target%link_flags, target%link_libraries)
522+
local_link_flags = model%compiler%enumerate_libraries(local_link_flags, target%link_libraries)
525523
end if
526524
end if
527525

0 commit comments

Comments
 (0)