@@ -204,15 +204,13 @@ function main(name, opt)
204
204
linkdirs = table .unique (linkdirs )
205
205
206
206
-- we iterate over each pkgconfig file to extract the required data
207
- local foundpc = false
208
- local result = {}
207
+ local result
209
208
for _ , pkgconfig_file in ipairs (pkgconfig_files ) do
210
209
local pkgconfig_dir = path .directory (pkgconfig_file )
211
210
local pkgconfig_name = path .basename (pkgconfig_file )
212
211
local pcresult = find_package_from_pkgconfig (pkgconfig_name , {configdirs = pkgconfig_dir , linkdirs = linkdirs })
213
-
214
- -- the pkgconfig file has been parse successfully
215
212
if pcresult then
213
+ result = result or {}
216
214
for _ , includedir in ipairs (pcresult .includedirs ) do
217
215
result .includedirs = result .includedirs or {}
218
216
table.insert (result .includedirs , includedir )
@@ -233,11 +231,10 @@ function main(name, opt)
233
231
result .version = pcresult .version
234
232
result .shared = pcresult .shared
235
233
result .static = pcresult .static
236
- foundpc = true
237
234
end
238
235
end
239
236
240
- if foundpc == true then
237
+ if result then
241
238
if result .includedirs then
242
239
result .includedirs = table .unique (result .includedirs )
243
240
end
@@ -255,9 +252,13 @@ function main(name, opt)
255
252
result = _find_package_from_list (list , name , pacman , opt )
256
253
end
257
254
if result then
258
- if not result .libfiles then
259
- result .libfiles = _find_libfiles_from_list (list , name , pacman , opt )
260
- for _ , libfile in ipairs (result .libfiles ) do
255
+ -- we give priority to libfiles in the list
256
+ local libfiles = _find_libfiles_from_list (list , name , pacman , opt )
257
+ if libfiles then
258
+ result .shared = nil
259
+ result .static = nil
260
+ result .libfiles = libfiles
261
+ for _ , libfile in ipairs (libfiles ) do
261
262
if libfile :endswith (" .so" ) then
262
263
result .shared = true
263
264
elseif libfile :endswith (" .a" ) then
0 commit comments