@@ -27,11 +27,12 @@ module fpm
27
27
contains
28
28
29
29
30
- recursive subroutine add_libsources_from_package (sources ,package_list ,package , &
30
+ recursive subroutine add_libsources_from_package (sources ,link_libraries , package_list ,package , &
31
31
package_root ,dev_depends ,error )
32
32
! Discover library sources in a package, recursively including dependencies
33
33
!
34
34
type (srcfile_t), allocatable , intent (inout ), target :: sources(:)
35
+ type (string_t), allocatable , intent (inout ) :: link_libraries(:)
35
36
type (string_t), allocatable , intent (inout ) :: package_list(:)
36
37
type (package_t), intent (in ) :: package
37
38
character (* ), intent (in ) :: package_root
@@ -121,7 +122,7 @@ subroutine add_dependencies(dependency_list)
121
122
end if
122
123
123
124
124
- call add_libsources_from_package(sources,package_list,dependency, &
125
+ call add_libsources_from_package(sources,link_libraries, package_list,dependency, &
125
126
package_root= dependency_path, &
126
127
dev_depends= .false. , error= error)
127
128
@@ -134,6 +135,9 @@ subroutine add_dependencies(dependency_list)
134
135
135
136
dep_name% s = dependency_list(i)% name
136
137
package_list = [package_list, dep_name]
138
+ if (allocated (dependency% build_config% link)) then
139
+ link_libraries = [link_libraries, dependency% build_config% link]
140
+ end if
137
141
138
142
end do
139
143
@@ -150,11 +154,14 @@ subroutine build_model(model, settings, package, error)
150
154
type (package_t), intent (in ) :: package
151
155
type (error_t), allocatable , intent (out ) :: error
152
156
157
+ integer :: i
153
158
type (string_t), allocatable :: package_list(:)
154
159
155
160
model% package_name = package% name
156
161
if (allocated (package% build_config% link)) then
157
162
model% link_libraries = package% build_config% link
163
+ else
164
+ allocate (model% link_libraries(0 ))
158
165
end if
159
166
160
167
allocate (package_list(1 ))
@@ -222,14 +229,18 @@ subroutine build_model(model, settings, package, error)
222
229
endif
223
230
224
231
! Add library sources, including local dependencies
225
- call add_libsources_from_package(model% sources,package_list,package, &
232
+ call add_libsources_from_package(model% sources,model % link_libraries, package_list,package, &
226
233
package_root= ' .' ,dev_depends= .true. ,error= error)
227
234
if (allocated (error)) then
228
235
return
229
236
end if
230
237
231
238
call targets_from_sources(model,model% sources)
232
239
240
+ do i = 1 , size (model% link_libraries)
241
+ model% link_flags = model% link_flags // " -l" // model% link_libraries(i)% s
242
+ end do
243
+
233
244
call resolve_module_dependencies(model% targets,error)
234
245
235
246
end subroutine build_model
0 commit comments