Skip to content

Commit 447b4b2

Browse files
authored
Merge pull request #255 from urbanjost/compiler
Add --compiler switch
2 parents e9a012a + 125e2e1 commit 447b4b2

File tree

9 files changed

+827
-113
lines changed

9 files changed

+827
-113
lines changed

fpm/fpm.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,7 @@ name = "fpm-test"
2929
source-dir = "test/fpm_test"
3030
main = "main.f90"
3131

32-
32+
[[test]]
33+
name = "help-test"
34+
source-dir = "test/help_test"
35+
main = "help_test.f90"

fpm/src/fpm.f90

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ module fpm
99
FPM_SCOPE_UNKNOWN, FPM_SCOPE_LIB, &
1010
FPM_SCOPE_DEP, FPM_SCOPE_APP, FPM_SCOPE_TEST, &
1111
FPM_TARGET_EXECUTABLE, FPM_TARGET_ARCHIVE
12+
use fpm_compiler, only: add_compile_flag_defaults
13+
1214

1315
use fpm_sources, only: add_executable_sources, add_sources_from_dir
1416
use fpm_targets, only: targets_from_sources, resolve_module_dependencies, &
@@ -153,11 +155,17 @@ subroutine build_model(model, settings, package, error)
153155
type(fpm_build_settings), intent(in) :: settings
154156
type(package_config_t), intent(in) :: package
155157
type(error_t), allocatable, intent(out) :: error
158+
type(string_t), allocatable :: package_list(:)
156159

157160
integer :: i
158-
type(string_t), allocatable :: package_list(:)
161+
162+
if(settings%verbose)then
163+
write(*,*)'<INFO>BUILD_NAME:',settings%build_name
164+
write(*,*)'<INFO>COMPILER: ',settings%compiler
165+
endif
159166

160167
model%package_name = package%name
168+
161169
if (allocated(package%build%link)) then
162170
model%link_libraries = package%build%link
163171
else
@@ -167,25 +175,16 @@ subroutine build_model(model, settings, package, error)
167175
allocate(package_list(1))
168176
package_list(1)%s = package%name
169177

170-
! #TODO: Choose flags and output directory based on cli settings & manifest inputs
171-
model%fortran_compiler = 'gfortran'
172-
173-
if(settings%release)then
174-
model%output_directory = 'build/gfortran_release'
175-
model%fortran_compile_flags=' &
176-
& -O3 &
177-
& -Wimplicit-interface &
178-
& -fPIC &
179-
& -fmax-errors=1 &
180-
& -ffast-math &
181-
& -funroll-loops ' // &
182-
& '-J'//join_path(model%output_directory,model%package_name)
178+
if(settings%compiler.eq.'')then
179+
model%fortran_compiler = 'gfortran'
183180
else
184-
model%output_directory = 'build/gfortran_debug'
185-
model%fortran_compile_flags = ' -Wall -Wextra -Wimplicit-interface -fPIC -fmax-errors=1 -g '// &
186-
'-fbounds-check -fcheck-array-temporaries -fbacktrace '// &
187-
'-J'//join_path(model%output_directory,model%package_name)
181+
model%fortran_compiler = settings%compiler
188182
endif
183+
184+
model%output_directory = join_path('build',basename(model%fortran_compiler)//'_'//settings%build_name)
185+
186+
call add_compile_flag_defaults(settings%build_name, basename(model%fortran_compiler), model)
187+
189188
model%link_flags = ''
190189

191190
! Add sources from executable directories

fpm/src/fpm_backend.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ subroutine build_target(model,target)
204204
select case(target%target_type)
205205

206206
case (FPM_TARGET_OBJECT)
207-
call run("gfortran -c " // target%source%file_name // model%fortran_compile_flags &
207+
call run(model%fortran_compiler//" -c " // target%source%file_name // model%fortran_compile_flags &
208208
// " -o " // target%output_file)
209209

210210
case (FPM_TARGET_EXECUTABLE)
@@ -223,7 +223,7 @@ subroutine build_target(model,target)
223223
end if
224224
end if
225225

226-
call run("gfortran " // model%fortran_compile_flags &
226+
call run(model%fortran_compiler// " " // model%fortran_compile_flags &
227227
//" "//link_flags// " -o " // target%output_file)
228228

229229
case (FPM_TARGET_ARCHIVE)

0 commit comments

Comments
 (0)