Skip to content

Commit dfeb17a

Browse files
authored
Allow setting, archiver, C compiler flags and linker flags from commandline (#549)
- Read Fortran compiler from FPM_FC or --compiler (deprecate FPM_COMPILER) - Read Fortran compiler options from FPM_FFLAGS or --flag - Read C compiler from FPM_CC or --c-compiler (deprecate FPM_C_COMPILER) - Read C compiler options from FPM_CFLAGS or --c-flag - Read archiver from FPM_AR or --archiver - Read linker options from FPM_LDFLAGS or --link-flag
1 parent 6bb5f6c commit dfeb17a

File tree

5 files changed

+197
-93
lines changed

5 files changed

+197
-93
lines changed

src/fpm.f90

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ subroutine build_model(model, settings, package, error)
3939

4040
integer :: i, j
4141
type(package_config_t) :: dependency
42-
character(len=:), allocatable :: manifest, lib_dir, flags
42+
character(len=:), allocatable :: manifest, lib_dir, flags, cflags, ldflags
4343

4444
logical :: duplicates_found = .false.
4545
type(string_t) :: include_dir
@@ -60,8 +60,8 @@ subroutine build_model(model, settings, package, error)
6060
call filewrite(join_path("build", ".gitignore"),["*"])
6161
end if
6262

63-
call new_compiler(model%compiler, settings%compiler)
64-
call new_archiver(model%archiver)
63+
call new_compiler(model%compiler, settings%compiler, settings%c_compiler)
64+
call new_archiver(model%archiver, settings%archiver)
6565

6666
if (settings%flag == '') then
6767
flags = model%compiler%get_default_flags(settings%profile == "release")
@@ -73,7 +73,10 @@ subroutine build_model(model, settings, package, error)
7373
end select
7474
end if
7575

76-
write(build_name, '(z16.16)') fnv_1a(flags)
76+
cflags = trim(settings%cflag)
77+
ldflags = trim(settings%ldflag)
78+
79+
write(build_name, '(z16.16)') fnv_1a(flags//cflags//ldflags)
7780

7881
if (model%compiler%is_unknown()) then
7982
write(*, '(*(a:,1x))') &
@@ -197,6 +200,8 @@ subroutine build_model(model, settings, package, error)
197200
write(*,*)'<INFO> COMPILER: ',model%compiler%fc
198201
write(*,*)'<INFO> C COMPILER: ',model%compiler%cc
199202
write(*,*)'<INFO> COMPILER OPTIONS: ', model%fortran_compile_flags
203+
write(*,*)'<INFO> C COMPILER OPTIONS: ', model%c_compile_flags
204+
write(*,*)'<INFO> LINKER OPTIONS: ', model%link_flags
200205
write(*,*)'<INFO> INCLUDE DIRECTORIES: [', string_cat(model%include_dirs,','),']'
201206
end if
202207

0 commit comments

Comments
 (0)