ddnet/other/freetype.lua

72 lines
1.9 KiB
Lua
Raw Normal View History

2010-05-29 07:25:38 +00:00
FreeType = {
2017-02-21 16:10:08 +00:00
OptFind = function (name, required)
2010-05-29 07:25:38 +00:00
local check = function(option, settings)
option.value = false
option.use_pkgconfig = false
2011-12-04 21:28:58 +00:00
option.use_winlib = 0
2010-05-29 07:25:38 +00:00
option.lib_path = nil
2017-02-21 16:10:08 +00:00
if family ~= "windows" and ExecuteSilent("pkg-config freetype2") == 0 then
2010-05-29 07:25:38 +00:00
option.value = true
option.use_pkgconfig = true
2010-05-29 07:25:38 +00:00
end
2017-02-21 16:10:08 +00:00
2010-05-29 07:25:38 +00:00
if platform == "win32" then
option.value = true
2011-12-04 21:28:58 +00:00
option.use_winlib = 32
elseif platform == "win64" then
option.value = true
option.use_winlib = 64
2010-05-29 07:25:38 +00:00
end
end
2017-02-21 16:10:08 +00:00
2010-05-29 07:25:38 +00:00
local apply = function(option, settings)
-- include path
settings.cc.includes:Add("ddnet-libs/freetype/include")
2017-02-21 16:10:08 +00:00
if option.use_pkgconfig == true then
settings.cc.flags:Add("`pkg-config freetype2 --cflags`")
settings.link.flags:Add("`pkg-config freetype2 --libs`")
2017-02-21 16:10:08 +00:00
2011-12-04 21:28:58 +00:00
elseif option.use_winlib > 0 then
if option.use_winlib == 32 then
settings.link.libpath:Add("ddnet-libs/freetype/windows/lib32")
2011-12-04 21:28:58 +00:00
else
settings.link.libpath:Add("ddnet-libs/freetype/windows/lib64")
2011-12-04 21:28:58 +00:00
end
settings.link.libs:Add("freetype")
2017-09-08 19:01:38 +00:00
else
settings.link.libs:Add("freetype")
2010-05-29 07:25:38 +00:00
end
end
2017-02-21 16:10:08 +00:00
2010-05-29 07:25:38 +00:00
local save = function(option, output)
output:option(option, "value")
output:option(option, "use_pkgconfig")
2011-12-04 21:28:58 +00:00
output:option(option, "use_winlib")
2010-05-29 07:25:38 +00:00
end
2017-02-21 16:10:08 +00:00
2010-05-29 07:25:38 +00:00
local display = function(option)
if option.value == true then
if option.use_pkgconfig == true then return "using pkg-config" end
2011-12-04 21:28:58 +00:00
if option.use_winlib == 32 then return "using supplied win32 libraries" end
if option.use_winlib == 64 then return "using supplied win64 libraries" end
2010-05-29 07:25:38 +00:00
return "using unknown method"
else
if option.required then
return "not found (required)"
else
return "not found (optional)"
end
end
end
2017-02-21 16:10:08 +00:00
2010-05-29 07:25:38 +00:00
local o = MakeOption(name, 0, check, save, display)
o.Apply = apply
o.include_path = nil
o.lib_path = nil
o.required = required
return o
end
}