2008-11-29 10:19:00 +00:00
|
|
|
SDL = {
|
|
|
|
OptFind = function (name, required)
|
2009-01-08 09:48:42 +00:00
|
|
|
local check = function(option, settings)
|
2010-05-29 07:25:38 +00:00
|
|
|
option.value = false
|
2015-09-03 04:28:11 +00:00
|
|
|
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.use_osxframework = false
|
2008-11-29 10:19:00 +00:00
|
|
|
option.lib_path = nil
|
|
|
|
|
2015-08-24 20:46:28 +00:00
|
|
|
if family ~= "windows" and ExecuteSilent("pkg-config sdl2") == 0 then
|
2010-05-29 07:25:38 +00:00
|
|
|
option.value = true
|
2015-09-03 04:28:11 +00:00
|
|
|
option.use_pkgconfig = true
|
2008-11-29 10:19:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if platform == "win32" then
|
2010-05-29 07:25:38 +00:00
|
|
|
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
|
2008-11-29 10:19:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if platform == "macosx" then
|
2010-05-29 07:25:38 +00:00
|
|
|
option.value = true
|
|
|
|
option.use_osxframework = true
|
2015-09-03 04:28:11 +00:00
|
|
|
option.use_pkgconfig = false
|
2008-11-29 10:19:00 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local apply = function(option, settings)
|
2015-09-03 04:28:11 +00:00
|
|
|
if option.use_pkgconfig == true then
|
2015-08-24 20:46:28 +00:00
|
|
|
settings.cc.flags:Add("`pkg-config sdl2 --cflags`")
|
|
|
|
settings.link.flags:Add("`pkg-config sdl2 --libs`")
|
2008-11-29 10:19:00 +00:00
|
|
|
end
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if option.use_osxframework == true then
|
2015-08-24 20:46:28 +00:00
|
|
|
client_settings.link.frameworks:Add("SDL2")
|
|
|
|
client_settings.cc.includes:Add("/Library/Frameworks/SDL2.framework/Headers")
|
2008-11-29 10:19:00 +00:00
|
|
|
end
|
|
|
|
|
2011-12-04 21:28:58 +00:00
|
|
|
if option.use_winlib > 0 then
|
2017-07-19 19:51:47 +00:00
|
|
|
settings.cc.includes:Add("ddnet-libs/sdl/include")
|
2011-12-04 21:28:58 +00:00
|
|
|
if option.use_winlib == 32 then
|
2017-07-21 21:43:01 +00:00
|
|
|
settings.link.libpath:Add("ddnet-libs/sdl/windows/lib32")
|
2011-12-04 21:28:58 +00:00
|
|
|
else
|
2017-07-21 21:43:01 +00:00
|
|
|
settings.link.libpath:Add("ddnet-libs/sdl/windows/lib64")
|
2011-12-04 21:28:58 +00:00
|
|
|
end
|
2015-08-24 20:46:28 +00:00
|
|
|
settings.link.libs:Add("SDL2")
|
2015-08-26 02:19:58 +00:00
|
|
|
settings.link.libs:Add("SDL2main")
|
2008-11-29 10:19:00 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local save = function(option, output)
|
|
|
|
output:option(option, "value")
|
2015-09-03 04:28:11 +00:00
|
|
|
output:option(option, "use_pkgconfig")
|
2011-12-04 21:28:58 +00:00
|
|
|
output:option(option, "use_winlib")
|
2008-11-29 10:19:00 +00:00
|
|
|
output:option(option, "use_osxframework")
|
|
|
|
end
|
|
|
|
|
|
|
|
local display = function(option)
|
2010-05-29 07:25:38 +00:00
|
|
|
if option.value == true then
|
2015-09-03 04:28:11 +00:00
|
|
|
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
|
|
|
if option.use_osxframework == true then return "using osx framework" end
|
2008-11-29 10:19:00 +00:00
|
|
|
return "using unknown method"
|
|
|
|
else
|
|
|
|
if option.required then
|
|
|
|
return "not found (required)"
|
|
|
|
else
|
|
|
|
return "not found (optional)"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local o = MakeOption(name, 0, check, save, display)
|
2009-01-08 09:48:42 +00:00
|
|
|
o.Apply = apply
|
2008-11-29 10:19:00 +00:00
|
|
|
o.include_path = nil
|
|
|
|
o.lib_path = nil
|
|
|
|
o.required = required
|
|
|
|
return o
|
|
|
|
end
|
|
|
|
}
|