@@ -40,7 +40,7 @@ module fpm_compiler
40
40
OS_UNKNOWN
41
41
use fpm_filesystem, only: join_path, basename, get_temp_filename, delete_file, unix_path, &
42
42
& getline
43
- use fpm_strings, only: string_cat, string_t
43
+ use fpm_strings, only: split, string_cat, string_t
44
44
implicit none
45
45
public :: compiler_t, new_compiler, archiver_t, new_archiver
46
46
public :: debug
@@ -467,22 +467,26 @@ function get_compiler_id(compiler) result(id)
467
467
character (len=* ), intent (in ) :: compiler
468
468
integer (kind= compiler_enum) :: id
469
469
470
- character (len= :), allocatable :: command, output
470
+ character (len= :), allocatable :: full_command, full_command_parts(:), command, output
471
471
integer :: stat, io
472
472
473
473
! Check whether we are dealing with an MPI compiler wrapper first
474
474
if (check_compiler(compiler, " mpifort" ) &
475
475
& .or. check_compiler(compiler, " mpif90" ) &
476
476
& .or. check_compiler(compiler, " mpif77" )) then
477
477
output = get_temp_filename()
478
- call run(compiler// " -showme:command > " // output// " 2>&1" , &
478
+ call run(compiler// " -show > " // output// " 2>&1" , &
479
479
& echo= .false. , exitstat= stat)
480
480
if (stat == 0 ) then
481
481
open (file= output, newunit= io, iostat= stat)
482
- if (stat == 0 ) call getline(io, command , stat)
482
+ if (stat == 0 ) call getline(io, full_command , stat)
483
483
close (io, iostat= stat)
484
484
485
485
! If we get a command from the wrapper, we will try to identify it
486
+ call split(full_command, full_command_parts, delimiters= ' ' )
487
+ if (size (full_command_parts) > 0 )then
488
+ command = trim (full_command_parts(1 ))
489
+ endif
486
490
if (allocated (command)) then
487
491
id = get_id(command)
488
492
if (id /= id_unknown) return
0 commit comments