Skip to content

Commit

Permalink
Allow setting, archiver, C compiler flags and linker flags from comma…
Browse files Browse the repository at this point in the history
…ndline (#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
  • Loading branch information
awvwgk authored Sep 23, 2021
1 parent 6bb5f6c commit dfeb17a
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 93 deletions.
13 changes: 9 additions & 4 deletions src/fpm.f90
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ subroutine build_model(model, settings, package, error)

integer :: i, j
type(package_config_t) :: dependency
character(len=:), allocatable :: manifest, lib_dir, flags
character(len=:), allocatable :: manifest, lib_dir, flags, cflags, ldflags

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

call new_compiler(model%compiler, settings%compiler)
call new_archiver(model%archiver)
call new_compiler(model%compiler, settings%compiler, settings%c_compiler)
call new_archiver(model%archiver, settings%archiver)

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

write(build_name, '(z16.16)') fnv_1a(flags)
cflags = trim(settings%cflag)
ldflags = trim(settings%ldflag)

write(build_name, '(z16.16)') fnv_1a(flags//cflags//ldflags)

if (model%compiler%is_unknown()) then
write(*, '(*(a:,1x))') &
Expand Down Expand Up @@ -197,6 +200,8 @@ subroutine build_model(model, settings, package, error)
write(*,*)'<INFO> COMPILER: ',model%compiler%fc
write(*,*)'<INFO> C COMPILER: ',model%compiler%cc
write(*,*)'<INFO> COMPILER OPTIONS: ', model%fortran_compile_flags
write(*,*)'<INFO> C COMPILER OPTIONS: ', model%c_compile_flags
write(*,*)'<INFO> LINKER OPTIONS: ', model%link_flags
write(*,*)'<INFO> INCLUDE DIRECTORIES: [', string_cat(model%include_dirs,','),']'
end if

Expand Down
Loading

0 comments on commit dfeb17a

Please sign in to comment.