瀏覽代碼

Make glaze multiplatform (#4637)

* Make glaze multiplatform

* Update xmake.lua

* Update xmake.lua

---------

Co-authored-by: star9029 <[email protected]>
Zetelias 1 年之前
父節點
當前提交
b9256cbb46
共有 1 個文件被更改,包括 26 次插入2 次删除
  1. 26 2
      packages/g/glaze/xmake.lua

+ 26 - 2
packages/g/glaze/xmake.lua

@@ -2,6 +2,7 @@ package("glaze")
     set_kind("library", {headeronly = true})
     set_homepage("https://github.com/stephenberry/glaze")
     set_description("Extremely fast, in memory, JSON and interface library for modern C++")
+    set_license("MIT")
 
     add_urls("https://github.com/stephenberry/glaze/archive/refs/tags/$(version).tar.gz",
              "https://github.com/stephenberry/glaze.git")
@@ -16,8 +17,31 @@ package("glaze")
     add_versions("v2.2.0", "1d6e36029a58bf8c4bdd035819e1ab02b87d8454dd80fa2f5d46c96a1e6d600c")
     add_versions("v1.3.5", "de5d59cb7f31193d45f67f25d8ced1499df50c0d926a1461432b87f2b2368817")
 
-    on_install("linux", function (package)
-        os.cp("include", package:installdir())
+    add_deps("cmake")
+
+    if on_check then
+        on_check("windows", function (package)
+            if package:is_plat("windows") then
+                local vs = package:toolchain("msvc"):config("vs")
+                assert(vs and tonumber(vs) >= 2022, "package(glaze): need vs >= 2022")
+            end
+        end)
+    end
+
+    on_install("windows", "linux", "bsd", "mingw", "wasm", function (package)
+        local version = package:version()
+        if version and version:ge("2.9.5") then
+            if package:has_tool("cxx", "cl", "clang_cl") then
+                package:add("cxxflags", "/Zc:preprocessor", "/permissive-", "/Zc:lambda")
+            end
+
+            import("package.tools.cmake").install(package, {
+                "-Dglaze_DEVELOPER_MODE=OFF",
+                "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")
+            })
+        else
+            os.cp("include", package:installdir())
+        end
     end)
 
     on_test(function (package)