diff options
author | LKedward <laurence.kedward@bristol.ac.uk> | 2020-11-01 14:14:47 +0000 |
---|---|---|
committer | LKedward <laurence.kedward@bristol.ac.uk> | 2020-11-01 14:14:47 +0000 |
commit | 6a2d6e798703bb88dd4ab3b7a8bf643e55724a88 (patch) | |
tree | de5a667caed1c9db5b94dfd7ef766003b76ff4ab | |
parent | 309ddf645e62a57fc65ddbaf8a08127cbe1678ca (diff) | |
download | fpm-6a2d6e798703bb88dd4ab3b7a8bf643e55724a88.tar.gz fpm-6a2d6e798703bb88dd4ab3b7a8bf643e55724a88.zip |
Fix: new backend to link non-library dependencies with executables
-rw-r--r-- | fpm/src/fpm_backend.f90 | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/fpm/src/fpm_backend.f90 b/fpm/src/fpm_backend.f90 index d3fa785..e8f51cc 100644 --- a/fpm/src/fpm_backend.f90 +++ b/fpm/src/fpm_backend.f90 @@ -56,7 +56,8 @@ recursive subroutine build_target(model,target,linking) type(build_target_t), intent(inout) :: target character(:), allocatable, intent(in) :: linking - integer :: i + integer :: i, j + type(build_target_t), pointer :: exe_obj character(:), allocatable :: objs if (target%built) then @@ -80,12 +81,27 @@ recursive subroutine build_target(model,target,linking) if (target%target_type == FPM_TARGET_ARCHIVE ) then + ! Construct object list for archive objs = objs//" "//target%dependencies(i)%ptr%output_file else if (target%target_type == FPM_TARGET_EXECUTABLE .and. & target%dependencies(i)%ptr%target_type == FPM_TARGET_OBJECT) then - objs = " "//target%dependencies(i)%ptr%output_file + exe_obj => target%dependencies(i)%ptr + + ! Construct object list for executable + objs = " "//exe_obj%output_file + + ! Include non-library object dependencies + do j=1,size(exe_obj%dependencies) + + if (allocated(exe_obj%dependencies(j)%ptr%source)) then + if (exe_obj%dependencies(j)%ptr%source%unit_scope == exe_obj%source%unit_scope) then + objs = objs//" "//exe_obj%dependencies(j)%ptr%output_file + end if + end if + + end do end if |