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.
 
 
 

65 lines
3.0 KiB

package("glm")
set_homepage("https://glm.g-truc.net/")
set_description("OpenGL Mathematics (GLM)")
set_license("MIT")
add_urls("https://github.com/g-truc/glm/archive/refs/tags/$(version).tar.gz",
{version = function(version) return version:gsub("%+", ".") end})
add_urls("https://github.com/g-truc/glm.git")
add_versions("1.0.1", "55a195bacf76cc48226292ada71b26abc980cde53180120a7b2a4ea8718e1507")
add_versions("1.0.0", "e51f6c89ff33b7cfb19daafb215f293d106cd900f8d681b9b1295312ccadbd23")
add_versions("0.9.9+8", "7d508ab72cb5d43227a3711420f06ff99b0a0cb63ee2f93631b162bfe1fe9592")
add_configs("header_only", {description = "Use header only version.", default = true, type = "boolean"})
add_configs("cxx_standard", {description = "Select c++ standard to build.", default = "14", type = "string", values = {"98", "11", "14", "17", "20"}})
add_configs("modules", {description = "Build with C++20 modules support.", default = false, type = "boolean"})
on_load(function (package)
if package:config("modules") then
package:config_set("header_only", false)
package:config_set("cxx_standard", "20")
end
if not package:config("header_only") and not package:config("modules") then
package:add("deps", "cmake")
end
end)
on_install(function (package)
if not package:config("modules") then
if package:config("header_only") then
os.cp("glm", package:installdir("include"))
else
io.replace("CMakeLists.txt", "NOT GLM_DISABLE_AUTO_DETECTION", "FALSE")
local configs = {"-DGLM_BUILD_TESTS=OFF"}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
table.insert(configs, "-DCMAKE_CXX_STANDARD=" .. package:config("cxx_standard"))
import("package.tools.cmake").install(package, configs)
end
else
io.writefile("xmake.lua", [[
target("glm")
set_kind("$(kind)")
set_languages("c++20")
add_headerfiles("./(glm/**.hpp)")
add_headerfiles("./(glm/**.h)")
add_headerfiles("./(glm/**.inl)")
add_includedirs(".")
add_files("glm/**.cpp")
add_files("glm/**.cppm", {public = true})
]])
import("package.tools.xmake").install(package)
end
end)
on_test(function (package)
local cxx_standard = "c++" .. package:config("cxx_standard")
assert(package:check_cxxsnippets({test = [[
#include <glm/glm.hpp>
#include <glm/ext/matrix_clip_space.hpp>
void test() {
glm::mat4 proj = glm::perspective(glm::radians(45.f), 1.33f, 0.1f, 10.f);
}
]]}, {configs = {languages = cxx_standard}}))
end)