summaryrefslogtreecommitdiff
path: root/xmake/modules/target/action/install/pkgconfig_importfiles.lua
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/modules/target/action/install/pkgconfig_importfiles.lua')
-rw-r--r--xmake/modules/target/action/install/pkgconfig_importfiles.lua15
1 files changed, 9 insertions, 6 deletions
diff --git a/xmake/modules/target/action/install/pkgconfig_importfiles.lua b/xmake/modules/target/action/install/pkgconfig_importfiles.lua
index 65da32085..67ab51b64 100644
--- a/xmake/modules/target/action/install/pkgconfig_importfiles.lua
+++ b/xmake/modules/target/action/install/pkgconfig_importfiles.lua
@@ -24,7 +24,7 @@ function main(target, opt)
-- check
opt = opt or {}
assert(target:is_library(), 'pkgconfig_importfiles: only support for library target(%s)!', target:name())
- local installdir = target:installdir()
+ local installdir = path.unix(path.normalize(target:installdir()))
if not installdir then
return
end
@@ -41,9 +41,10 @@ function main(target, opt)
-- get libs
local libs = ""
+ local base_libdir = path.join(installdir, "lib")
for _, linkdir in ipairs(linkdirs) do
- if linkdir ~= path.join(installdir, "lib") then
- libs = libs .. " -L" .. (linkdir:gsub("\\", "/"))
+ if linkdir ~= base_libdir then
+ libs = libs .. " -L" .. "${libdir}/" .. path.unix(path.relative(linkdir, base_libdir))
end
end
libs = libs .. " -L${libdir}"
@@ -56,9 +57,10 @@ function main(target, opt)
-- get cflags
local cflags = ""
+ local base_includedir = path.join(installdir, "include")
for _, includedir in ipairs(includedirs) do
- if includedir ~= path.join(installdir, "include") then
- cflags = cflags .. " -I" .. (includedir:gsub("\\", "/"))
+ if includedir ~= base_includedir then
+ cflags = cflags .. " -I" .. "${includedir}/" .. path.unix(path.relative(includedir, base_includedir))
end
end
cflags = cflags .. " -I${includedir}"
@@ -70,7 +72,8 @@ function main(target, opt)
-- generate a *.pc file
local file = io.open(pcfile, 'w')
if file then
- file:print("prefix=%s", installdir:gsub("\\", "/"))
+ file:print("# Generated by Xmake")
+ file:print("prefix=%s", "${pcfiledir}/" .. path.unix(path.relative(installdir, path.directory(pcfile))))
file:print("exec_prefix=${prefix}")
file:print("libdir=${exec_prefix}/lib")
file:print("includedir=${prefix}/include")