Skip to content

Commit

Permalink
Integrate minio-cpp from main (#275)
Browse files Browse the repository at this point in the history
All the headers in src/3rdParty/minio-cpp/inc are taken without
modification from
[minio/minio-cpp](https://github.com/minio/minio-cpp/tree/cd4ef14955201d5ce81e54155ef0980f7c644864).

Additions to vcpkg.json are temporary until minio-cpp push a new release
to vcpkg.
  • Loading branch information
aliddell authored Jul 15, 2024
1 parent ee39999 commit 17e1591
Show file tree
Hide file tree
Showing 28 changed files with 3,564 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
test:
name: ${{ matrix.platform }}
runs-on: ${{ matrix.platform }}
timeout-minutes: 10
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
Expand Down
1 change: 1 addition & 0 deletions src/3rdParty/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(minio-cpp)
45 changes: 45 additions & 0 deletions src/3rdParty/minio-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
set(pwd ${CMAKE_CURRENT_LIST_DIR})

set(lib "unknown-minio-cpp-lib")

if(WIN32)
set(lib "${pwd}/lib/win64/miniocpp.lib")
set(libd "${pwd}/lib/win64/miniocpp-debug.lib")
elseif(APPLE)
set(lib "${pwd}/lib/osx/libminiocpp.a")
set(libd "${pwd}/lib/osx/libminiocpp-debug.a")
elseif(LINUX)
set(lib "${pwd}/lib/linux-amd64/libminiocpp.a")
set(libd "${pwd}/lib/linux-amd64/libminiocpp-debug.a")
endif()

find_package(OpenSSL REQUIRED)
find_package(unofficial-curlpp CONFIG REQUIRED)
find_package(unofficial-inih CONFIG REQUIRED)
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
nlohmann_json::nlohmann_json
pugixml
OpenSSL::SSL OpenSSL::Crypto
ZLIB::ZLIB
)

if (WIN32)
list(APPEND MINIO_CPP_LIBS wsock32)
list(APPEND MINIO_CPP_LIBS ws2_32)
endif()

message(STATUS "minio-cpp: ${pwd}")
set(tgt miniocpp::miniocpp)
add_library(${tgt} STATIC IMPORTED GLOBAL)
target_include_directories(${tgt} INTERFACE ${pwd}/inc)
target_link_libraries(${tgt} INTERFACE ${MINIO_CPP_LIBS})
set_target_properties(${tgt} PROPERTIES
IMPORTED_LOCATION ${lib}
IMPORTED_LOCATION_DEBUG ${libd}
)
50 changes: 50 additions & 0 deletions src/3rdParty/minio-cpp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# MinIO C++ client

This repository includes headers and pre-build binaries for the MinIO C++ client SDK.
It was built from
commit [cd4ef14955201d5ce81e54155ef0980f7c644864](https://github.com/minio/minio-cpp/tree/cd4ef14955201d5ce81e54155ef0980f7c644864).
In the base CMakeLists.txt, it was necessary to change `STATIC` to `MODULE` in the `add_library` command to build the
shared library.

## Building

### Windows

To generate the solution file, run the following command:

```shell
cmake . -B build -DMINIO_CPP_TEST=OFF -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" -DVCPKG_INSTALLED_DIR=vcpkg_installed -DVCPKG_TARGET_TRIPLET=x64-windows-static
```

Then, open the solution file in Visual Studio.
Open the Solution Explorer, select `miniocpp` and right-click on it.
Select `Configuration Properties > C/C++ > Code Generation`.
For Release type builds, include RelWithDebInfo, change the `Runtime Library` to `Multi-threaded (/MT)` in order to
statically link the MSVC runtime.
For Debug builds, change the `Runtime Library` to `Multi-threaded Debug (/MTd)`.
Finally, build the solution.

### macOS

To generate the universal binary, you will need to build the library for both x86_64 and arm64 architectures.
Run the following commands:

```shell
# Build for x86_64
cmake . -B build-x64 -DMINIO_CPP_TEST=OFF -DCMAKE_TOOLCHAIN_FILE="${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" -DVCPKG_INSTALLED_DIR=vcpkg-x64 -DVCPKG_TARGET_TRIPLET=x64-osx -DCMAKE_OSX_ARCHITECTURES="x86_64" -DCMAKE_BUILD_TYPE=Release # or Debug
cmake --build build-x64 --config Release # or Debug
# Repeat the process for arm64
cmake . -B build-arm64 -DMINIO_CPP_TEST=OFF -DCMAKE_TOOLCHAIN_FILE="${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" -DVCPKG_INSTALLED_DIR=vcpkg-arm64 -DVCPKG_TARGET_TRIPLET=arm64-osx -DCMAKE_OSX_ARCHITECTURES="arm64" -DCMAKE_BUILD_TYPE=Release # or Debug
cmake --build build-arm64 --config Release # or Debug
# Create the universal binary
lipo -create build-x64/libminiocpp.a build-arm64/libminiocpp.a -output libminiocpp.a
```

### Linux

To generate the shared library, run the following command:

```shell
cmake . -B build -DMINIO_CPP_TEST=OFF -DCMAKE_TOOLCHAIN_FILE="${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" -DCMAKE_BUILD_TYPE=Release # or Debug
cmake --build build --config Release # or Debug
```
Loading

0 comments on commit 17e1591

Please sign in to comment.