Skip to content

Commit 6a2d6e7

Browse files
committed
Fix: new backend to link non-library dependencies with executables
1 parent 309ddf6 commit 6a2d6e7

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

fpm/src/fpm_backend.f90

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ recursive subroutine build_target(model,target,linking)
5656
type(build_target_t), intent(inout) :: target
5757
character(:), allocatable, intent(in) :: linking
5858

59-
integer :: i
59+
integer :: i, j
60+
type(build_target_t), pointer :: exe_obj
6061
character(:), allocatable :: objs
6162

6263
if (target%built) then
@@ -80,12 +81,27 @@ recursive subroutine build_target(model,target,linking)
8081

8182
if (target%target_type == FPM_TARGET_ARCHIVE ) then
8283

84+
! Construct object list for archive
8385
objs = objs//" "//target%dependencies(i)%ptr%output_file
8486

8587
else if (target%target_type == FPM_TARGET_EXECUTABLE .and. &
8688
target%dependencies(i)%ptr%target_type == FPM_TARGET_OBJECT) then
8789

88-
objs = " "//target%dependencies(i)%ptr%output_file
90+
exe_obj => target%dependencies(i)%ptr
91+
92+
! Construct object list for executable
93+
objs = " "//exe_obj%output_file
94+
95+
! Include non-library object dependencies
96+
do j=1,size(exe_obj%dependencies)
97+
98+
if (allocated(exe_obj%dependencies(j)%ptr%source)) then
99+
if (exe_obj%dependencies(j)%ptr%source%unit_scope == exe_obj%source%unit_scope) then
100+
objs = objs//" "//exe_obj%dependencies(j)%ptr%output_file
101+
end if
102+
end if
103+
104+
end do
89105

90106
end if
91107

0 commit comments

Comments
 (0)