Skip to content

Commit 511d002

Browse files
committed
introspection: add optional build, link flags
1 parent 6827b8e commit 511d002

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/fpm_compiler.F90

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,14 +1440,16 @@ end function compiler_name
14401440

14411441
!> Run a single-source Fortran program using the current compiler
14421442
!> Compile a Fortran object
1443-
logical function check_fortran_source_runs(self, input) result(success)
1443+
logical function check_fortran_source_runs(self, input, compile_flags, link_flags) result(success)
14441444
!> Instance of the compiler object
14451445
class(compiler_t), intent(in) :: self
14461446
!> Program Source
14471447
character(len=*), intent(in) :: input
1448+
!> Optional build and link flags
1449+
character(len=*), optional, intent(in) :: compile_flags, link_flags
14481450

14491451
integer :: stat,unit
1450-
character(:), allocatable :: source,object,logf,exe
1452+
character(:), allocatable :: source,object,logf,exe,flags,ldflags
14511453

14521454
success = .false.
14531455

@@ -1463,10 +1465,17 @@ logical function check_fortran_source_runs(self, input) result(success)
14631465
write(unit,*) input
14641466
close(unit)
14651467

1468+
!> Get flags
1469+
flags = self%get_default_flags(release=.false.)
1470+
ldflags = self%get_default_flags(release=.false.)
1471+
1472+
if (present(compile_flags)) flags = flags//" "//compile_flags
1473+
if (present(link_flags)) ldflags = ldflags//" "//link_flags
1474+
14661475
!> Compile and link program
1467-
call self%compile_fortran(source, object, self%get_default_flags(release=.false.), logf, stat)
1476+
call self%compile_fortran(source, object, flags, logf, stat)
14681477
if (stat==0) &
1469-
call self%link(exe, self%get_default_flags(release=.false.)//" "//object, logf, stat)
1478+
call self%link(exe, ldflags//" "//object, logf, stat)
14701479

14711480
!> Run and retrieve exit code
14721481
if (stat==0) &

0 commit comments

Comments
 (0)