-
-
Notifications
You must be signed in to change notification settings - Fork 398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
minio-cpp: add package #5019
minio-cpp: add package #5019
Changes from all commits
e4e8f8c
47fb584
a5dfe3c
44f3500
6d489ce
68eace2
1eeb84e
4eb7ae9
3ef315d
42daf8e
5256d17
4258dc3
385d15b
b6f2ed8
5077378
1f1910f
3c7415e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index c2610db..abee1c8 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -57,15 +57,16 @@ endif() | ||
# ------------ | ||
|
||
find_package(OpenSSL REQUIRED) | ||
-find_package(unofficial-curlpp CONFIG REQUIRED) | ||
-find_package(unofficial-inih CONFIG REQUIRED) | ||
+find_package(CURL REQUIRED) | ||
+include(FindPkgConfig) | ||
+pkg_search_module(curlpp REQUIRED IMPORTED_TARGET curlpp) | ||
+pkg_search_module(inih REQUIRED IMPORTED_TARGET inih) | ||
find_package(nlohmann_json CONFIG REQUIRED) | ||
find_package(pugixml CONFIG REQUIRED) | ||
find_package(ZLIB REQUIRED) | ||
|
||
list(APPEND MINIO_CPP_LIBS | ||
- unofficial::curlpp::curlpp | ||
- unofficial::inih::inireader | ||
+ PkgConfig::curlpp CURL::libcurl PkgConfig::inih | ||
nlohmann_json::nlohmann_json | ||
pugixml | ||
OpenSSL::SSL OpenSSL::Crypto | ||
@@ -115,7 +116,7 @@ set(MINIO_CPP_HEADERS | ||
include/miniocpp/utils.h | ||
) | ||
|
||
-add_library(miniocpp STATIC ${MINIO_CPP_SOURCES} ${MINIO_CPP_HEADERS}) | ||
+add_library(miniocpp ${MINIO_CPP_SOURCES} ${MINIO_CPP_HEADERS}) | ||
target_compile_options(miniocpp PRIVATE ${MINIO_CPP_CFLAGS}) | ||
target_compile_features(miniocpp PUBLIC cxx_std_${MINIO_CPP_STD}) | ||
target_include_directories(miniocpp PUBLIC | ||
@@ -124,7 +125,6 @@ target_include_directories(miniocpp PUBLIC | ||
) | ||
target_link_libraries(miniocpp PUBLIC ${MINIO_CPP_LIBS}) | ||
set_target_properties(miniocpp PROPERTIES VERSION "${MINIO_CPP_VERSION_STRING}") | ||
-set_target_properties(miniocpp PROPERTIES POSITION_INDEPENDENT_CODE ON) | ||
|
||
# Add a cmake alias - this is how users should use minio-cpp in their cmake projects. | ||
add_library(miniocpp::miniocpp ALIAS miniocpp) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
diff --git a/src/utils.cc b/src/utils.cc | ||
index 05cb8e2..6f16a66 100644 | ||
--- a/src/utils.cc | ||
+++ b/src/utils.cc | ||
@@ -24,6 +24,10 @@ | ||
#include <corecrt.h> | ||
#endif | ||
|
||
+#ifndef _MSC_VER | ||
+#include <unistd.h> | ||
+#endif | ||
+ | ||
#include <openssl/bio.h> | ||
#include <openssl/buffer.h> | ||
#include <openssl/crypto.h> |
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,56 @@ | ||||||||||||
package("minio-cpp") | ||||||||||||
set_homepage("https://minio-cpp.min.io/") | ||||||||||||
set_description("MinIO C++ Client SDK for Amazon S3 Compatible Cloud Storage") | ||||||||||||
set_license("Apache-2.0") | ||||||||||||
|
||||||||||||
add_urls("https://github.com/minio/minio-cpp/archive/refs/tags/$(version).tar.gz", | ||||||||||||
"https://github.com/minio/minio-cpp.git") | ||||||||||||
|
||||||||||||
add_versions("v0.3.0", "da0f2f54bf169ad9e5e9368cc9143df4db056fc5c05bb55d8c1d9065e7211f7c") | ||||||||||||
|
||||||||||||
add_patches("0.3.0", "patches/0.3.0/cmake-pkgconfig-find-deps.patch", "53a0a5a300c896ad92dbaf3b96fa25556a2f555e84ce07deb7b7b1562ddac9e5") | ||||||||||||
add_patches("0.3.0", "patches/0.3.0/macos-unistd.patch", "cd50e5d3cb5ceda7d606dc15f90ab4764b34a61a96a3be83f02688329843ef1f") | ||||||||||||
|
||||||||||||
add_deps("cmake") | ||||||||||||
if is_host("windows") then | ||||||||||||
add_deps("pkgconf") | ||||||||||||
else | ||||||||||||
add_deps("pkg-config") | ||||||||||||
end | ||||||||||||
|
||||||||||||
add_deps("nlohmann_json", {configs = {cmake = true}}) | ||||||||||||
add_deps("inih", {configs = {ini_parser = true}}) | ||||||||||||
add_deps("curlpp", "pugixml", "zlib") | ||||||||||||
|
||||||||||||
on_load(function (package) | ||||||||||||
-- xrepo package: curlpp -> libcurl -> openssl | ||||||||||||
if package:is_plat("linux") then | ||||||||||||
package:add("deps", "openssl") | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 为啥其他平台用 openssl3 就不会冲突? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. libcurl 在 linux 默认启用 openssl xmake-repo/packages/l/libcurl/xmake.lua Lines 33 to 37 in 02309f9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 那可以用 另外,既然这个包 openssl 也可以,直接全用 openssl dep 呢 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
哦哦,这个可以。
一个大问题是不稳定。 |
||||||||||||
else | ||||||||||||
package:add("deps", "openssl3") | ||||||||||||
end | ||||||||||||
end) | ||||||||||||
|
||||||||||||
on_install("windows", "linux", "macosx", "mingw", function (package) | ||||||||||||
if package:is_plat("linux") then | ||||||||||||
io.replace("src/utils.cc", "#include <openssl/types.h>", "", {plain = true}) | ||||||||||||
end | ||||||||||||
|
||||||||||||
local configs = {} | ||||||||||||
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) | ||||||||||||
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) | ||||||||||||
if package:is_plat("windows") and package:config("shared") then | ||||||||||||
table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON") | ||||||||||||
end | ||||||||||||
import("package.tools.cmake").install(package, configs) | ||||||||||||
end) | ||||||||||||
|
||||||||||||
on_test(function (package) | ||||||||||||
assert(package:check_cxxsnippets({test = [[ | ||||||||||||
void test() { | ||||||||||||
minio::s3::BaseUrl base_url("play.min.io"); | ||||||||||||
minio::creds::StaticProvider provider("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); | ||||||||||||
minio::s3::Client client(base_url, &provider); | ||||||||||||
} | ||||||||||||
]]}, {configs = {languages = "c++17"}, includes = "miniocpp/client.h"})) | ||||||||||||
end) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这块感觉可以塞进 cmake 里面去。。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
目前是因为 patch 了 cmake,走 pkgconfig 找 xrepo 包才加,不知道有没有必要也加在 cmake。
另外我发现 cmake + pkgconfig + import target 这套好像挺稳定,或许可以用来改进 xrepo_cmake 和生成 cmakelists。