Browse Source

gflags: config mt=true as default. (#1021)

* gflags: config mt=true as default.

* gflags: add thread syslink only when mt=true.

* Update xmake.lua

Co-authored-by: ruki <[email protected]>
Chen Yufei 3 years ago
parent
commit
dfa161a276
1 changed files with 12 additions and 7 deletions
  1. 12 7
      packages/g/gflags/xmake.lua

+ 12 - 7
packages/g/gflags/xmake.lua

@@ -9,14 +9,19 @@ package("gflags")
     add_versions("v2.2.2", "34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf")
     add_versions("v2.2.2", "34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf")
     add_patches("v2.2.2", path.join(os.scriptdir(), "patches", "v2.2.2", "fix-cmake.patch"), "a2b9f99fe1421723aacd66e1a268efcb23c3dbf357776d4942c0bb25fc89d15c")
     add_patches("v2.2.2", path.join(os.scriptdir(), "patches", "v2.2.2", "fix-cmake.patch"), "a2b9f99fe1421723aacd66e1a268efcb23c3dbf357776d4942c0bb25fc89d15c")
 
 
-    add_configs("mt", {description = "Build the multi-threaded gflags library.", default = false, type = "boolean"})
-
+    add_configs("mt", {description = "Build the multi-threaded gflags library.", default = true, type = "boolean"})
     add_deps("cmake")
     add_deps("cmake")
-    if is_plat("windows", "mingw") then
-        add_syslinks("shlwapi")
-    elseif is_plat("linux") then
-        add_syslinks("pthread")
-    end
+
+    on_load(function (package)
+        if package:config("mt") then
+            if package:is_plat("windows", "mingw") then
+                package:add("syslinks", "shlwapi")
+            elseif package:is_plat("linux") then
+                package:add("syslinks", "pthread")
+            end
+        end
+    end)
+
     on_install(function (package)
     on_install(function (package)
         local configs = {
         local configs = {
             "-DBUILD_TESTING=OFF",
             "-DBUILD_TESTING=OFF",