aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLKedward <laurence.kedward@bristol.ac.uk>2020-11-08 13:02:23 +0000
committerLKedward <laurence.kedward@bristol.ac.uk>2020-11-08 13:02:23 +0000
commit4071e13104cc9b82ddd6969183a378b5a3f27b1c (patch)
treeb1109fe865fc3f11d3c9c06122d09a55b16778c3
parent00c75b4dbaa19a15d3f0e92ff9dbacf8b334a2bf (diff)
downloadfpm-4071e13104cc9b82ddd6969183a378b5a3f27b1c.tar.gz
fpm-4071e13104cc9b82ddd6969183a378b5a3f27b1c.zip
Add: check for duplicate output objects
-rw-r--r--fpm/src/fpm_targets.f9020
1 files changed, 18 insertions, 2 deletions
diff --git a/fpm/src/fpm_targets.f90 b/fpm/src/fpm_targets.f90
index 54f0764..2cd4418 100644
--- a/fpm/src/fpm_targets.f90
+++ b/fpm/src/fpm_targets.f90
@@ -114,16 +114,32 @@ subroutine add_target(targets,type,output_file,source)
character(*), intent(in) :: output_file
type(srcfile_t), intent(in), optional :: source
+ integer :: i
type(build_target_ptr), allocatable :: temp(:)
type(build_target_t), pointer :: new_target
+ if (.not.allocated(targets)) allocate(targets(0))
+
+ ! Check for duplicate outputs
+ do i=1,size(targets)
+
+ if (targets(i)%ptr%output_file == output_file) then
+
+ write(*,*) 'Error while building target list: duplicate output object "',&
+ output_file,'"'
+ if (present(source)) write(*,*) ' Source file: "',source%file_name,'"'
+ stop 1
+
+ end if
+
+ end do
+
allocate(new_target)
new_target%target_type = type
new_target%output_file = output_file
if (present(source)) new_target%source = source
allocate(new_target%dependencies(0))
-
- if (.not.allocated(targets)) allocate(targets(0))
+
targets = [targets, build_target_ptr(new_target)]
end subroutine add_target