Skip to content

Commit 4071e13

Browse files
committed
Add: check for duplicate output objects
1 parent 00c75b4 commit 4071e13

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

fpm/src/fpm_targets.f90

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,32 @@ subroutine add_target(targets,type,output_file,source)
114114
character(*), intent(in) :: output_file
115115
type(srcfile_t), intent(in), optional :: source
116116

117+
integer :: i
117118
type(build_target_ptr), allocatable :: temp(:)
118119
type(build_target_t), pointer :: new_target
119120

121+
if (.not.allocated(targets)) allocate(targets(0))
122+
123+
! Check for duplicate outputs
124+
do i=1,size(targets)
125+
126+
if (targets(i)%ptr%output_file == output_file) then
127+
128+
write(*,*) 'Error while building target list: duplicate output object "',&
129+
output_file,'"'
130+
if (present(source)) write(*,*) ' Source file: "',source%file_name,'"'
131+
stop 1
132+
133+
end if
134+
135+
end do
136+
120137
allocate(new_target)
121138
new_target%target_type = type
122139
new_target%output_file = output_file
123140
if (present(source)) new_target%source = source
124141
allocate(new_target%dependencies(0))
125-
126-
if (.not.allocated(targets)) allocate(targets(0))
142+
127143
targets = [targets, build_target_ptr(new_target)]
128144

129145
end subroutine add_target

0 commit comments

Comments
 (0)