Skip to content

Commit 7701274

Browse files
committed
Minor fix: no recursive source search for [[executable]] entries
Source directories specified in [[executable]] and [[test]] are not searched recursively. Fixes issue with having programs in the root directory.
1 parent 4d87edd commit 7701274

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

fpm/src/fpm_sources.f90

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ function parse_source(source_file_path,error) result(source)
5151
end function parse_source
5252

5353

54-
subroutine add_sources_from_dir(sources,directory,scope,with_executables,error)
54+
subroutine add_sources_from_dir(sources,directory,scope,with_executables,recurse,error)
5555
! Enumerate sources in a directory
5656
!
5757
type(srcfile_t), allocatable, intent(inout), target :: sources(:)
5858
character(*), intent(in) :: directory
5959
integer, intent(in) :: scope
6060
logical, intent(in), optional :: with_executables
61+
logical, intent(in), optional :: recurse
6162
type(error_t), allocatable, intent(out) :: error
6263

6364
integer :: i
@@ -68,7 +69,7 @@ subroutine add_sources_from_dir(sources,directory,scope,with_executables,error)
6869
type(srcfile_t), allocatable :: dir_sources(:)
6970

7071
! Scan directory for sources
71-
call list_files(directory, file_names,recurse=.true.)
72+
call list_files(directory, file_names,recurse=merge(recurse,.true.,present(recurse)))
7273

7374
if (allocated(sources)) then
7475
allocate(existing_src_files(size(sources)))
@@ -135,8 +136,8 @@ subroutine add_executable_sources(sources,executables,scope,auto_discover,error)
135136
call get_executable_source_dirs(exe_dirs,executables)
136137

137138
do i=1,size(exe_dirs)
138-
call add_sources_from_dir(sources,exe_dirs(i)%s, &
139-
scope, with_executables=auto_discover,error=error)
139+
call add_sources_from_dir(sources,exe_dirs(i)%s, scope, &
140+
with_executables=auto_discover, recurse=.false., error=error)
140141

141142
if (allocated(error)) then
142143
return

0 commit comments

Comments
 (0)