package An official xmake package repository https://xrepo.xmake.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

110 lines
6.4 KiB

package("magnum")
set_homepage("https://magnum.graphics/")
set_description("Light­weight and mod­u­lar C++11/C++14 graph­ics mid­dle­ware for games and data visu­al­iz­a­tion.")
set_license("MIT")
add_urls("https://github.com/mosra/magnum/archive/refs/tags/$(version).tar.gz",
"https://github.com/mosra/magnum.git")
add_versions("v2020.06", "98dfe802e56614e4e6bf750d9b693de46a5ed0c6eb479b0268f1a20bf34268bf")
add_configs("audio", {description = "Build audio module.", default = false, type = "boolean"})
add_configs("vulkan", {description = "Build vulkan module.", default = false, type = "boolean"})
add_configs("deprecated", {description = "Include deprecated APIs in the build.", default = true, type = "boolean"})
add_configs("plugin_static", {description = "Build plugins as static libraries.", default = false, type = "boolean"})
local applicationlibs = {"android", "emscripten", "glfw", "glx", "sdl2", "xegl", "windowlesscgl", "windowlessegl", "windowlessglx", "windowlessios", "windowlesswgl", "windowlesswindowsegl"}
for _, applicationlib in ipairs(applicationlibs) do
add_configs(applicationlib, {description = "Build the " .. applicationlib .. " application library.", default = false, type = "boolean"})
end
local contexts = {"cgl", "egl", "glx", "wgl"}
for _, context in ipairs(contexts) do
add_configs(context .. "context", {description = "Build the " .. context .. " context handling library.", default = false, type = "boolean"})
end
local testers = {"opengltester", "vulkantester"}
for _, tester in ipairs(testers) do
add_configs(tester, {description = "Build the " .. tester .. " class.", default = false, type = "boolean"})
end
local plugins = {"anyaudioimporter", "anyimageconverter", "anyimageimporter", "anysceneconverter", "anysceneimporter", "anyshaderconverter", "magnumfont", "magnumfontconverter", "objimporter", "tgaimporter", "tgaimageconverter", "wavaudioimporter"}
for _, plugin in ipairs(plugins) do
add_configs(plugin, {description = "Build the " .. plugin .. " plugin.", default = false, type = "boolean"})
end
local utilities = {"gl_info", "vk_info", "al_info", "distancefieldconverter", "fontconverter", "imageconverter", "sceneconverter", "shaderconverter"}
for _, utility in ipairs(utilities) do
add_configs(utility, {description = "Build the " .. utility .. " executable.", default = false, type = "boolean"})
end
add_deps("cmake", "corrade", "opengl")
add_links("AnyAudioImporter", "AnyImageConverter", "AnyImageImporter", "AnySceneConverter", "AnySceneImporter", "MagnumFont", "MagnumFontConverter", "ObjImporter", "TgaImageConverter", "TgaImporter", "WavAudioImporter")
add_links("CglContext", "EglContext", "GlxContext", "WglContext", "OpenGLTester", "VulkanTester")
add_links("AndroidApplication", "EmscriptenApplication", "GlfwApplication", "GlxApplication", "Sdl2Application", "XEglApplication", "WindowlessCglApplication", "WindowlessEglApplication", "WindowlessGlxApplication", "WindowlessIosApplication", "WindowlessWglApplication", "WindowlessWindowsEglApplication")
add_links("MagnumAudio", "MagnumDebugTools", "MagnumGL", "MagnumMeshTools", "MagnumPrimitives", "MagnumSceneGraph", "MagnumShaders", "MagnumText", "MagnumTextureTools", "MagnumTrade", "MagnumVk", "Magnum")
on_load("windows", "linux", "macosx", function (package)
if package:config("audio") then
package:add("deps", "openal-soft", {configs = {shared = true}})
end
if package:config("vulkan") then
package:add("deps", "vulkansdk")
end
if package:config("glfw") then
package:add("deps", "glfw")
end
if package:config("sdl2") then
package:add("deps", "libsdl")
end
if package:config("glx") then
package:add("deps", "libx11")
end
end)
on_install("windows", "linux", "macosx", function (package)
local configs = {"-DBUILD_TESTS=OFF", "-DLIB_SUFFIX="}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
table.insert(configs, "-DBUILD_STATIC=" .. (package:config("shared") and "OFF" or "ON"))
table.insert(configs, "-DWITH_AUDIO=" .. (package:config("audio") and "ON" or "OFF"))
table.insert(configs, "-DWITH_VK=" .. (package:config("vulkan") and "ON" or "OFF"))
table.insert(configs, "-DBUILD_DEPRECATED=" .. (package:config("deprecated") and "ON" or "OFF"))
table.insert(configs, "-DBUILD_PLUGIN_STATIC=" .. (package:config("plugin_static") and "ON" or "OFF"))
for _, applicationlib in ipairs(applicationlibs) do
table.insert(configs, "-DWITH_" .. applicationlib:upper() .. "APPLICATION=" .. (package:config(applicationlib) and "ON" or "OFF"))
end
for _, context in ipairs(contexts) do
table.insert(configs, "-DWITH_" .. context:upper() .. "CONTEXT=" .. (package:config(context) and "ON" or "OFF"))
end
for _, tester in ipairs(testers) do
table.insert(configs, "-DWITH_" .. tester:upper() .. "=" .. (package:config(tester) and "ON" or "OFF"))
end
for _, plugin in ipairs(plugins) do
table.insert(configs, "-DWITH_" .. plugin:upper() .. "=" .. (package:config(plugin) and "ON" or "OFF"))
end
for _, utility in ipairs(utilities) do
table.insert(configs, "-DWITH_" .. utility:upper() .. "=" .. (package:config(utility) and "ON" or "OFF"))
end
import("package.tools.cmake").install(package, configs, {buildir = os.tmpdir()})
end)
on_test(function (package)
assert(package:check_cxxsnippets({test = [[
#include <Magnum/GL/Buffer.h>
#include <Magnum/Math/Color.h>
using namespace Magnum;
struct TriangleVertex {
Vector2 position;
Color3 color;
};
void test() {
using namespace Math::Literals;
const TriangleVertex data[]{
{{-0.5f, -0.5f}, 0xff0000_rgbf},
{{ 0.5f, -0.5f}, 0x00ff00_rgbf},
{{ 0.0f, 0.5f}, 0x0000ff_rgbf}
};
GL::Buffer buffer;
buffer.setData(data);
}
]]}, {configs = {languages = "c++14"}}))
end)