[Linux] Helper methods for pkg-config
- Fixes linking on GCC by putting libs in link group
This commit is contained in:
parent
fa7f292432
commit
8f44a14131
|
@ -99,8 +99,8 @@ filter("platforms:Linux")
|
|||
toolset("clang")
|
||||
buildoptions({
|
||||
-- "-mlzcnt", -- (don't) Assume lzcnt is supported.
|
||||
({os.outputof("pkg-config --cflags gtk+-x11-3.0")})[1],
|
||||
})
|
||||
pkg_config.all("gtk+-x11-3.0")
|
||||
links({
|
||||
"stdc++fs",
|
||||
"dl",
|
||||
|
@ -108,9 +108,6 @@ filter("platforms:Linux")
|
|||
"pthread",
|
||||
"rt",
|
||||
})
|
||||
linkoptions({
|
||||
({os.outputof("pkg-config --libs gtk+-3.0")})[1],
|
||||
})
|
||||
|
||||
filter({"platforms:Linux", "kind:*App"})
|
||||
linkgroups("On")
|
||||
|
|
|
@ -3,5 +3,6 @@ require("vstudio")
|
|||
include("scripts/build_paths.lua")
|
||||
include("scripts/force_compile_as_c.lua")
|
||||
include("scripts/force_compile_as_cc.lua")
|
||||
include("scripts/pkg_config.lua")
|
||||
include("scripts/platform_files.lua")
|
||||
include("scripts/test_suite.lua")
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
-- Helper methods to use the system pkg-config utility
|
||||
|
||||
pkg_config = {}
|
||||
|
||||
function pkg_config.cflags(lib)
|
||||
if os.istarget("windows") then
|
||||
return
|
||||
end
|
||||
buildoptions({
|
||||
({os.outputof("pkg-config --cflags "..lib)})[1],
|
||||
})
|
||||
end
|
||||
|
||||
function pkg_config.lflags(lib)
|
||||
if os.istarget("windows") then
|
||||
return
|
||||
end
|
||||
linkoptions({
|
||||
({os.outputof("pkg-config --libs-only-L " ..lib)})[1],
|
||||
({os.outputof("pkg-config --libs-only-other "..lib)})[1],
|
||||
})
|
||||
-- We can't just drop the stdout of the `--libs` command in
|
||||
-- linkoptions because library order matters
|
||||
local output = ({os.outputof("pkg-config --libs-only-l "..lib)})[1]
|
||||
for k, flag in next, string.explode(output, " ") do
|
||||
-- remove "-l"
|
||||
links(string.sub(flag, 3))
|
||||
end
|
||||
end
|
||||
|
||||
function pkg_config.all(lib)
|
||||
pkg_config.cflags(lib)
|
||||
pkg_config.lflags(lib)
|
||||
end
|
Loading…
Reference in New Issue