浏览代码

mimalloc: fix install cmake config files (#4036)

* mimalloc: fix install cmake config file

* add 2.1.4

* Revert "add 2.1.4"

This reverts commit 4ec764a0740ef9ae64459a112a84556d7842ee2b.
star9029 1 年之前
父节点
当前提交
f8b898dc4b
共有 1 个文件被更改,包括 27 次插入14 次删除
  1. 27 14
      packages/m/mimalloc/xmake.lua

+ 27 - 14
packages/m/mimalloc/xmake.lua

@@ -35,12 +35,16 @@ package("mimalloc")
     end
     end
 
 
     on_install("macosx", "windows", "linux", "android", "mingw", function (package)
     on_install("macosx", "windows", "linux", "android", "mingw", function (package)
-        local configs = {"-DMI_OVERRIDE=OFF"}
+        local configs = {
+            "-DMI_OVERRIDE=OFF",
+            "-DMI_BUILD_TESTS=OFF",
+            "-DMI_BUILD_OBJECT=OFF",
+        }
+
+        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
         table.insert(configs, "-DMI_BUILD_STATIC=" .. (package:config("shared") and "OFF" or "ON"))
         table.insert(configs, "-DMI_BUILD_STATIC=" .. (package:config("shared") and "OFF" or "ON"))
         table.insert(configs, "-DMI_BUILD_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
         table.insert(configs, "-DMI_BUILD_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
         table.insert(configs, "-DMI_SECURE=" .. (package:config("secure") and "ON" or "OFF"))
         table.insert(configs, "-DMI_SECURE=" .. (package:config("secure") and "ON" or "OFF"))
-        table.insert(configs, "-DMI_BUILD_TESTS=OFF")
-        table.insert(configs, "-DMI_BUILD_OBJECT=OFF")
         --x64:mimalloc-redirect.lib/dll x86:mimalloc-redirect32.lib/dll
         --x64:mimalloc-redirect.lib/dll x86:mimalloc-redirect32.lib/dll
         if package:version():le("2.0.1") and package:config("shared") and package:is_plat("windows") and package:is_arch("x86") then
         if package:version():le("2.0.1") and package:config("shared") and package:is_plat("windows") and package:is_arch("x86") then
             io.replace("CMakeLists.txt", "-redirect.", "-redirect32.", {plain = true})
             io.replace("CMakeLists.txt", "-redirect.", "-redirect32.", {plain = true})
@@ -54,20 +58,29 @@ package("mimalloc")
                 package:configs().cxflags = "-DMI_USE_RTLGENRANDOM"
                 package:configs().cxflags = "-DMI_USE_RTLGENRANDOM"
             end
             end
         end
         end
-        import("package.tools.cmake").build(package, configs, {buildir = "build", cxflags = cxflags})
 
 
-        if package:is_plat("windows") then
-            os.trycp("build/**.dll", package:installdir("bin"))
-            os.trycp("build/**.lib", package:installdir("lib"))
-        elseif package:is_plat("mingw") then
-            os.trycp("build/**.dll", package:installdir("bin"))
-            os.trycp("build/**.a", package:installdir("lib"))
+        if package:version():ge("2.1.2") then
+            table.insert(configs, "-DMI_INSTALL_TOPLEVEL=ON")
+            if package:is_plat("windows") then
+                table.insert(configs, "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=''")
+            end
+            import("package.tools.cmake").install(package, configs, {cxflags = cxflags})
         else
         else
-            os.trycp("build/*.so", package:installdir("bin"))
-            os.trycp("build/*.so", package:installdir("lib"))
-            os.trycp("build/*.a", package:installdir("lib"))
+            import("package.tools.cmake").build(package, configs, {buildir = "build", cxflags = cxflags})
+
+            if package:is_plat("windows") then
+                os.trycp("build/**.dll", package:installdir("bin"))
+                os.trycp("build/**.lib", package:installdir("lib"))
+            elseif package:is_plat("mingw") then
+                os.trycp("build/**.dll", package:installdir("bin"))
+                os.trycp("build/**.a", package:installdir("lib"))
+            else
+                os.trycp("build/*.so", package:installdir("bin"))
+                os.trycp("build/*.so", package:installdir("lib"))
+                os.trycp("build/*.a", package:installdir("lib"))
+            end
+            os.cp("include", package:installdir())
         end
         end
-        os.cp("include", package:installdir())
     end)
     end)
 
 
     on_test(function (package)
     on_test(function (package)