Browse Source

pahomqttcpp: improve configs (#4455)

* pahomqttcpp: improve configs

* fix dep config

* fix pahomqttc lib with shared
star9029 1 year ago
parent
commit
48e1d08b8e
2 changed files with 30 additions and 24 deletions
  1. 5 4
      packages/p/pahomqttc/xmake.lua
  2. 25 20
      packages/p/pahomqttcpp/xmake.lua

+ 5 - 4
packages/p/pahomqttc/xmake.lua

@@ -29,15 +29,16 @@ package("pahomqttc")
         if package:config("uuid") then
         if package:config("uuid") then
             package:add("deps", "uuid")
             package:add("deps", "uuid")
         end
         end
-        if package:config("openssl") then
-            package:add("deps", "openssl")
-        end
 
 
         if package:config("shared") and package:is_plat("windows") then
         if package:config("shared") and package:is_plat("windows") then
             package:add("defines", "PAHO_MQTT_IMPORTS")
             package:add("defines", "PAHO_MQTT_IMPORTS")
         end
         end
-        -- paho-mqtt3[a|c][-static]
+        -- paho-mqtt3[a|c][s][-static]
         local links = "paho-mqtt3" .. (package:config("asynchronous") and "a" or "c")
         local links = "paho-mqtt3" .. (package:config("asynchronous") and "a" or "c")
+        if package:config("openssl") then
+            links = links .. "s"
+            package:add("deps", "openssl")
+        end
         if package:is_plat("windows", "mingw") and (not package:config("shared")) then
         if package:is_plat("windows", "mingw") and (not package:config("shared")) then
             links = links .. "-static"
             links = links .. "-static"
         end
         end

+ 25 - 20
packages/p/pahomqttcpp/xmake.lua

@@ -1,7 +1,7 @@
 package("pahomqttcpp")
 package("pahomqttcpp")
     set_homepage("https://github.com/eclipse/paho.mqtt.cpp")
     set_homepage("https://github.com/eclipse/paho.mqtt.cpp")
     set_description("Eclipse Paho MQTT C++ Client Library")
     set_description("Eclipse Paho MQTT C++ Client Library")
-    set_license("EPL v1.0")
+    set_license("EPL-2.0")
 
 
     add_urls("https://github.com/eclipse/paho.mqtt.cpp/archive/refs/tags/$(version).zip",
     add_urls("https://github.com/eclipse/paho.mqtt.cpp/archive/refs/tags/$(version).zip",
              "https://github.com/eclipse/paho.mqtt.cpp.git")
              "https://github.com/eclipse/paho.mqtt.cpp.git")
@@ -9,29 +9,34 @@ package("pahomqttcpp")
     add_versions("v1.3.2", "e01f43cf0ba35efa666503c7adb2786d4a6f7fe6eb44ce5311ac4785a0ce8a98")
     add_versions("v1.3.2", "e01f43cf0ba35efa666503c7adb2786d4a6f7fe6eb44ce5311ac4785a0ce8a98")
     add_versions("v1.2.0", "90c4d8ae4f56bb706120fddcc5937cd0a0360b6f39d5cd5574a5846c0f923473")
     add_versions("v1.2.0", "90c4d8ae4f56bb706120fddcc5937cd0a0360b6f39d5cd5574a5846c0f923473")
     
     
-    add_deps("cmake")
-    add_deps("pahomqttc")
-
-    on_install("windows", "linux", "macosx", function (package)
-        
-        local configs = {"-DPAHO_WITH_SSL=FALSE"}
-        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"))
+    add_configs("openssl", {description = "Flag that defines whether to build ssl-enabled binaries too.", default = false, type = "boolean"})
 
 
-        if package:is_plat("windows") then
-            local pahomqttc = package:dep("pahomqttc"):fetch()
+    add_deps("cmake")
 
 
-            local includedirs = pahomqttc.includedirs or pahomqttc.sysincludedirs
-            if includedirs and #includedirs > 0 then
-                table.insert(configs, "-DPAHO_MQTT_C_INCLUDE_DIRS=" .. table.concat(includedirs, " "))
-            end
+    on_load(function (package)
+        if package:config("openssl") then
+            package:add("deps", "openssl")
+        end
 
 
-            local libfiles = pahomqttc.libfiles
-            if libfiles then
-                table.insert(configs, "-DPAHO_MQTT_C_LIBRARIES=" .. table.concat(libfiles, " "))
+        local opt = {configs = {asynchronous = true}}
+        if package:config("shared") and package:is_plat("windows", "mingw") then
+            opt.configs.shared = true
+            if package:is_plat("windows") then
+                package:add("defines", "PAHO_MQTTPP_IMPORTS")
             end
             end
         end
         end
-        
+
+        package:add("deps", "pahomqttc", opt)
+    end)
+
+    on_install("!wasm", function (package)
+        local configs = {}
+        local shared = package:config("shared")
+        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
+        table.insert(configs, "-DPAHO_BUILD_SHARED=" .. (shared and "TRUE" or "FALSE"))
+        table.insert(configs, "-DPAHO_BUILD_STATIC=" .. (shared and "FALSE" or "TRUE"))
+
+        table.insert(configs, "-DPAHO_WITH_SSL=" .. (package:config("openssl") and "TRUE" or "FALSE"))
         import("package.tools.cmake").install(package, configs)
         import("package.tools.cmake").install(package, configs)
     end)
     end)
 
 
@@ -43,4 +48,4 @@ package("pahomqttcpp")
                 cli.connect();
                 cli.connect();
             }
             }
         ]]}, {configs = {languages = "c++11"}}))
         ]]}, {configs = {languages = "c++11"}}))
-    end)    
+    end)