Skip to content

Commit 71c7b94

Browse files
committed
Minor fix: for link flag concatenation
1 parent 0a5440e commit 71c7b94

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

fpm/src/fpm_backend.f90

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,20 +209,23 @@ subroutine build_target(model,target)
209209
// " -o " // target%output_file)
210210

211211
case (FPM_TARGET_EXECUTABLE)
212+
213+
link_flags = string_cat(target%link_objects," ")
214+
212215
if (allocated(model%library_file)) then
213-
link_flags = " "//model%library_file//" "//model%link_flags
216+
link_flags = link_flags//" "//model%library_file//" "//model%link_flags
214217
else
215-
link_flags = " "//model%link_flags
218+
link_flags = link_flags//" "//model%link_flags
216219
end if
217220

218221
if (allocated(target%link_libraries)) then
219222
if (size(target%link_libraries) > 0) then
220223
link_flags = link_flags // " -l" // string_cat(target%link_libraries," -l")
221224
end if
222225
end if
223-
224-
call run("gfortran " // string_cat(target%link_objects," ") // model%fortran_compile_flags &
225-
//link_flags// " -o " // target%output_file)
226+
227+
call run("gfortran " // model%fortran_compile_flags &
228+
//" "//link_flags// " -o " // target%output_file)
226229

227230
case (FPM_TARGET_ARCHIVE)
228231
call run("ar -rs " // target%output_file // " " // string_cat(target%link_objects," "))

fpm/src/fpm_strings.f90

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ function string_cat(strings,delim) result(cat)
150150
integer :: i,n
151151
character(:), allocatable :: delim_str
152152

153-
if (size(strings) < 1) return
153+
if (size(strings) < 1) then
154+
cat = ''
155+
return
156+
end if
154157

155158
if (present(delim)) then
156159
delim_str = delim

0 commit comments

Comments
 (0)