aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fpm.f905
-rw-r--r--src/fpm_compiler.f9027
-rw-r--r--src/fpm_model.f903
3 files changed, 34 insertions, 1 deletions
diff --git a/src/fpm.f90 b/src/fpm.f90
index 31b68ff..653f8be 100644
--- a/src/fpm.f90
+++ b/src/fpm.f90
@@ -9,7 +9,7 @@ use fpm_filesystem, only: is_dir, join_path, number_of_rows, list_files, exists,
use fpm_model, only: fpm_model_t, srcfile_t, show_model, &
FPM_SCOPE_UNKNOWN, FPM_SCOPE_LIB, FPM_SCOPE_DEP, &
FPM_SCOPE_APP, FPM_SCOPE_EXAMPLE, FPM_SCOPE_TEST
-use fpm_compiler, only: get_module_flags, is_unknown_compiler
+use fpm_compiler, only: get_module_flags, is_unknown_compiler, get_default_c_compiler
use fpm_sources, only: add_executable_sources, add_sources_from_dir
@@ -62,6 +62,8 @@ subroutine build_model(model, settings, package, error)
model%fortran_compiler = settings%compiler
endif
+ call get_default_c_compiler(model%fortran_compiler, model%c_compiler)
+
if (is_unknown_compiler(model%fortran_compiler)) then
write(*, '(*(a:,1x))') &
"<WARN>", "Unknown compiler", model%fortran_compiler, "requested!", &
@@ -178,6 +180,7 @@ subroutine build_model(model, settings, package, error)
if (settings%verbose) then
write(*,*)'<INFO> BUILD_NAME: ',settings%build_name
write(*,*)'<INFO> COMPILER: ',settings%compiler
+ write(*,*)'<INFO> C COMPILER: ',model%c_compiler
write(*,*)'<INFO> COMPILER OPTIONS: ', model%fortran_compile_flags
write(*,*)'<INFO> INCLUDE DIRECTORIES: [', string_cat(model%include_dirs,','),']'
end if
diff --git a/src/fpm_compiler.f90 b/src/fpm_compiler.f90
index 36041bf..76aedcc 100644
--- a/src/fpm_compiler.f90
+++ b/src/fpm_compiler.f90
@@ -336,6 +336,33 @@ subroutine get_module_flags(compiler, modpath, flags)
end subroutine get_module_flags
+subroutine get_default_c_compiler(f_compiler, c_compiler)
+ character(len=*), intent(in) :: f_compiler
+ character(len=:), allocatable, intent(out) :: c_compiler
+ integer(compiler_enum) :: id
+
+ id = get_compiler_id(f_compiler)
+
+ select case(id)
+ case default
+ c_compiler = 'gcc'
+
+ case(id_intel_classic)
+ c_compiler = 'icc'
+
+ case(id_intel_llvm)
+ c_compiler = 'icx'
+
+ case(id_flang)
+ c_compiler='clang'
+
+ case(id_ibmxl)
+ c_compiler='xlc'
+
+ end select
+
+end subroutine get_default_c_compiler
+
function get_compiler_id(compiler) result(id)
character(len=*), intent(in) :: compiler
integer(kind=compiler_enum) :: id
diff --git a/src/fpm_model.f90 b/src/fpm_model.f90
index bfb0115..5c575fc 100644
--- a/src/fpm_model.f90
+++ b/src/fpm_model.f90
@@ -117,6 +117,9 @@ type :: fpm_model_t
!> Command line name to invoke fortran compiler
character(:), allocatable :: fortran_compiler
+ !> Command line name to invoke c compiler
+ character(:), allocatable :: c_compiler
+
!> Command line flags passed to fortran for compilation
character(:), allocatable :: fortran_compile_flags