Add modules support for glm (#3230)

* add modules support for glm

fix glm package

* Update xmake.lua

---------

Co-authored-by: ruki <waruqi@gmail.com>
pull/3236/head
Arthur Laurent 1 year ago committed by GitHub
parent 46919d4bef
commit b98f84e676
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 38
      packages/g/glm/xmake.lua

@ -12,23 +12,43 @@ package("glm")
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 not package:config("header_only") then
if not 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 package:config("header_only") then
os.cp("glm", package:installdir("include"))
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.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)
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)

Loading…
Cancel
Save