Browse Source

add not header only config (#1898)

* add not header only config

* improve kind
star9029 2 years ago
parent
commit
11076065a0
1 changed files with 20 additions and 3 deletions
  1. 20 3
      packages/t/toml++/xmake.lua

+ 20 - 3
packages/t/toml++/xmake.lua

@@ -1,5 +1,5 @@
 package("toml++")
 package("toml++")
-    set_kind("library", {headeronly = true})
+
     set_homepage("https://marzer.github.io/tomlplusplus/")
     set_homepage("https://marzer.github.io/tomlplusplus/")
     set_description("toml++ is a header-only TOML config file parser and serializer for C++17 (and later!).")
     set_description("toml++ is a header-only TOML config file parser and serializer for C++17 (and later!).")
 
 
@@ -11,10 +11,27 @@ package("toml++")
     add_versions("v3.2.0", "aeba776441df4ac32e4d4db9d835532db3f90fd530a28b74e4751a2915a55565")
     add_versions("v3.2.0", "aeba776441df4ac32e4d4db9d835532db3f90fd530a28b74e4751a2915a55565")
     add_versions("v3.3.0", "fc1a5eb410f3c67e90e5ad1264a1386d020067cfb01b633cc8c0441789aa6cf2")
     add_versions("v3.3.0", "fc1a5eb410f3c67e90e5ad1264a1386d020067cfb01b633cc8c0441789aa6cf2")
 
 
-    add_deps("cmake")
+    add_configs("header_only", {description = "Use header only version.", default = true, type = "boolean"})
+
+    on_load(function (package)
+        if package:config("header_only") then
+            package:set("kind", "library", {headeronly = true})
+            package:add("deps", "cmake")
+        else
+            package:add("deps", "meson", "ninja")
+        end
+    end)
 
 
     on_install(function (package)
     on_install(function (package)
-        import("package.tools.cmake").install(package)
+        if package:config("header_only") then
+            import("package.tools.cmake").install(package)
+        else
+            package:add("defines", "TOML_HEADER_ONLY=0")
+
+            local configs = {"-Dbuild_lib=true"}
+            table.insert(configs, "-Ddefault_library=" .. (package:config("shared") and "shared" or "static"))
+            import("package.tools.meson").install(package, configs)
+        end
     end)
     end)
 
 
     on_test(function (package)
     on_test(function (package)