From 82190afe732a142c0cbd5002bf656bb2e2d58157 Mon Sep 17 00:00:00 2001 From: Petr Kobalicek Date: Tue, 19 Mar 2024 17:28:56 +0100 Subject: [PATCH] Reworked CMakeLists.txt * Moved the logic into a single CMakeLists.txt file * Added miniocpp:: namespace and thus miniocpp::miniocpp target * Removed the generation of header files (config.h.in) * Consolidated tests and examples - use MINIO_CPP_TEST to build them all * Use miniocpp::miniocpp target in tests and exampels to simplify the use of dependencies * Setup the cmake project with DESCRIPTION and VERSION * Use GNUInstallDirs when installing targets * Export cmake files so another cmake can find minio-cpp by using find_package(miniocpp) and then use miniocpp::miniocpp * Building both documentation and tests/examples is OFF by default --- .github/workflows/ci.yml | 8 +- .gitignore | 28 ++-- .gitmodules | 0 CMakeLists.txt | 307 ++++++++++++++++++++++++++------------- README.md | 68 +++++++-- configure.sh | 16 ++ examples/CMakeLists.txt | 154 -------------------- include/CMakeLists.txt | 34 ----- include/config.h | 74 ++++++++++ include/config.h.in | 26 ---- src/CMakeLists.txt | 33 ----- tests/CMakeLists.txt | 2 - vcpkg.json | 26 +--- 13 files changed, 375 insertions(+), 401 deletions(-) delete mode 100644 .gitmodules create mode 100755 configure.sh delete mode 100644 examples/CMakeLists.txt delete mode 100644 include/CMakeLists.txt create mode 100644 include/config.h delete mode 100644 include/config.h.in delete mode 100644 src/CMakeLists.txt delete mode 100644 tests/CMakeLists.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1accba77..f654a5d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -103,7 +103,7 @@ jobs: - name: Configure and Build shell: bash run: | - cmake -B ./build -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -DCMAKE_TOOLCHAIN_FILE=./vcpkg-master/scripts/buildsystems/vcpkg.cmake + cmake -B ./build -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -DCMAKE_TOOLCHAIN_FILE=./vcpkg-master/scripts/buildsystems/vcpkg.cmake -DMINIO_CPP_TEST:BOOL=ON cmake --build ./build --config ${{ matrix.config.build_type }} -j 4 - name: Start MinIO server if Ubuntu @@ -135,18 +135,18 @@ jobs: - name: Run tests if Ubuntu if: startsWith(matrix.config.name, 'Ubuntu_Latest_GCC') run: | - SERVER_ENDPOINT=localhost:9000 ACCESS_KEY=minioadmin SECRET_KEY=minioadmin ENABLE_HTTPS=1 ./build/tests/tests + SERVER_ENDPOINT=localhost:9000 ACCESS_KEY=minioadmin SECRET_KEY=minioadmin ENABLE_HTTPS=1 ./build/tests - name: Run tests if macOS if: startsWith(matrix.config.name, 'macos') run: | - SERVER_ENDPOINT=localhost:9000 ACCESS_KEY=minioadmin SECRET_KEY=minioadmin ./build/tests/tests + SERVER_ENDPOINT=localhost:9000 ACCESS_KEY=minioadmin SECRET_KEY=minioadmin ./build/tests - name: Run tests if Windows shell: bash if: startsWith(matrix.config.os, 'windows') run: | - SERVER_ENDPOINT=localhost:9000 ACCESS_KEY=minioadmin SECRET_KEY=minioadmin ENABLE_HTTPS=1 ./build/tests/Release/tests.exe + SERVER_ENDPOINT=localhost:9000 ACCESS_KEY=minioadmin SECRET_KEY=minioadmin ENABLE_HTTPS=1 ./build/Release/tests.exe - name: Run CMake test working-directory: ${{github.workspace}}/build diff --git a/.gitignore b/.gitignore index a5559007..36392e03 100644 --- a/.gitignore +++ b/.gitignore @@ -1,26 +1,18 @@ +/build +/vcpkg_installed +/docs/search +/docs/*html +/docs/*png +/docs/*js +/docs/*css +/docs/*svg +/docs/*map +/docs/*md5 *.d -*.o s3tool *~ -libminiocpp.so -*.a -*.so -build/ -*.pc .vs CMakeSettings.json -vcpkg_installed/ -docs/search -docs/*html -docs/*png -docs/*js -docs/*css -docs/*svg -docs/*map -docs/*md5 -include/config.h .idea/ -cmake-build* vcpkg-master.zip vcpkg-master/ - diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e69de29b..00000000 diff --git a/CMakeLists.txt b/CMakeLists.txt index 4704139a..87a93044 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # MinIO C++ Library for Amazon S3 Compatible Cloud Storage -# Copyright 2021 MinIO, Inc. +# Copyright 2021-2024 MinIO, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,124 +15,227 @@ cmake_minimum_required(VERSION 3.10) cmake_policy(SET CMP0091 NEW) -project(miniocpp) +# Minio C++ Project +# ----------------- + +set(MINIO_CPP_MAJOR_VERSION "0") +set(MINIO_CPP_MINOR_VERSION "1") +set(MINIO_CPP_PATCH_VERSION "0") +set(MINIO_CPP_VERSION_STRING "${MINIO_CPP_MAJOR_VERSION}.${MINIO_CPP_MINOR_VERSION}.${MINIO_CPP_PATCH_VERSION}") + +project(miniocpp + DESCRIPTION "MinIO C++ Client SDK provides simple APIs to access S3 compatible object storage" + VERSION ${MINIO_CPP_VERSION_STRING} + LANGUAGES C CXX +) include(GNUInstallDirs) +include(CheckIncludeFiles) + +option(MINIO_CPP_TEST "Build tests" OFF) +option(MINIO_CPP_MAKE_DOC "Build documentation" OFF) + +# TODO: Leftovers from previous CMake build script: +#set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +set(MINIO_CPP_CFLAGS) +set(MINIO_CPP_LIBS) +set(MINIO_CPP_STD "17") + +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") + # MSVC +else() + # GCC/Clang/AppleClang/... + LIST(APPEND MINIO_CPP_CFLAGS -Wall -Wextra -Wconversion) + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0 AND NOT MINGW) + list(APPEND MINIO_CPP_LIBS stdc++fs) + endif() +endif() -macro(set_globals) - set(CMAKE_BUILD_TYPE_INIT Release) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) - set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_DEBUG} --coverage") - set(CMAKE_EXE_LINKER_FLAGS_COVERAGE "${CMAKE_EXE_LINKER_FLAGS_DEBUG} --coverage") - set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} --coverage") - set(CMAKE_MODULE_LINKER_FLAGS_COVERAGE "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} --coverage") -endmacro() - -# specify the C++ standard -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED True) -set(CMAKE_POSITION_INDEPENDENT_CODE ON) - -# prohibit in-source-builds -IF (${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) - MESSAGE(STATUS "In-source-builds are not allowed") - MESSAGE(STATUS "Clean your source directory (e.g. delete the CMakeCache.txt file)") - MESSAGE(FATAL_ERROR "Please create a separate build directory and call CMake again") -ENDIF (${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) - -# Look for required libraries -SET(requiredlibs) - -IF(CMAKE_COMPILER_IS_GNUCC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Wconversion") - IF(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0 AND NOT MINGW) - list(APPEND requiredlibs stdc++fs) - ENDIF() -ENDIF() +# Dependencies +# ------------ find_package(CURL REQUIRED) -IF(CURL_FOUND) - INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIRS}) - list(APPEND requiredlibs CURL::libcurl) -ELSE(CURL_FOUND) - MESSAGE(FATAL_ERROR "Could not find the CURL library and development files.") -ENDIF(CURL_FOUND) - +find_package(OpenSSL REQUIRED) find_package(unofficial-curlpp CONFIG REQUIRED) -list(APPEND requiredlibs unofficial::curlpp::curlpp) - find_package(unofficial-inih CONFIG REQUIRED) -list(APPEND requiredlibs unofficial::inih::inireader) - find_package(nlohmann_json CONFIG REQUIRED) -list(APPEND requiredlibs nlohmann_json::nlohmann_json) - find_package(pugixml CONFIG REQUIRED) -list(APPEND requiredlibs pugixml) -find_package(OpenSSL REQUIRED) -IF(OPENSSL_FOUND) - INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR}) - list(APPEND requiredlibs OpenSSL::SSL OpenSSL::Crypto) # bugfix, because libcrypto is not found automatically -ELSE(OPENSSL_FOUND) - MESSAGE(FATAL_ERROR "Could not find the OpenSSL library and development files.") -ENDIF(OPENSSL_FOUND) - -if(WIN32) - list(APPEND requiredlibs wsock32) - list(APPEND requiredlibs ws2_32) - list(APPEND requiredlibs ZLIB::ZLIB) +list(APPEND MINIO_CPP_LIBS + CURL::libcurl + unofficial::curlpp::curlpp + unofficial::inih::inireader + nlohmann_json::nlohmann_json + pugixml + OpenSSL::SSL OpenSSL::Crypto +) + +if (WIN32) + list(APPEND MINIO_CPP_LIBS wsock32) + list(APPEND MINIO_CPP_LIBS ws2_32) + list(APPEND MINIO_CPP_LIBS ZLIB::ZLIB) endif() -message(STATUS "Found required libs: ${requiredlibs}") - -INCLUDE (CheckIncludeFiles) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) - -SET(MINIOCPP_MAJOR_VERSION "0") -SET(MINIOCPP_MINOR_VERSION "1") -SET(MINIOCPP_PATCH_VERSION "0") - -add_subdirectory(include) -add_subdirectory(src) - -option(BUILD_EXAMPLES "Build examples" ON) -if (BUILD_EXAMPLES) - add_subdirectory(examples) -endif (BUILD_EXAMPLES) - -option(BUILD_TESTS "Build tests" ON) -if (BUILD_TESTS) - add_subdirectory(tests) -endif (BUILD_TESTS) +# Minio C++ Library +# ----------------- + +set(MINIO_CPP_SOURCES + src/args.cc + src/baseclient.cc + src/client.cc + src/credentials.cc + src/http.cc + src/providers.cc + src/request.cc + src/response.cc + src/select.cc + src/signer.cc + src/sse.cc + src/types.cc + src/utils.cc +) + +set(MINIO_CPP_HEADERS + include/args.h + include/baseclient.h + include/client.h + include/config.h + include/credentials.h + include/error.h + include/http.h + include/providers.h + include/request.h + include/response.h + include/select.h + include/signer.h + include/sse.h + include/types.h + include/utils.h +) + +add_library(miniocpp STATIC ${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 PRIVATE ${CMAKE_CURRENT_LIST_DIR}/include) +target_link_libraries(miniocpp PUBLIC ${MINIO_CPP_LIBS}) +set_target_properties(miniocpp PROPERTIES VERSION "${MINIO_CPP_VERSION_STRING}") + +# Add a cmake alias - this is how users should use minio-cpp in their cmake projects. +add_library(miniocpp::miniocpp ALIAS miniocpp) + +# Minio C++ Tests +# --------------- + +if (MINIO_CPP_TEST) + set(EXAMPLE_APPS + MakeBucket + RemoveBucket + BucketExists + ListBuckets + StatObject + RemoveObject + DownloadObject + UploadObject + GetObject + ListObjects + PutObject + CopyObject + ComposeObject + RemoveObjects + SelectObjectContent + ListenBucketNotification + DeleteBucketPolicy + GetBucketPolicy + SetBucketPolicy + DeleteBucketNotification + GetBucketNotification + SetBucketNotification + DeleteBucketEncryption + GetBucketEncryption + SetBucketEncryption + GetBucketVersioning + SetBucketVersioning + DeleteBucketReplication + GetBucketReplication + SetBucketReplication + DeleteBucketLifecycle + GetBucketLifecycle + SetBucketLifecycle + DeleteBucketTags + GetBucketTags + SetBucketTags + DeleteObjectLockConfig + GetObjectLockConfig + SetObjectLockConfig + DeleteObjectTags + GetObjectTags + SetObjectTags + DisableObjectLegalHold + EnableObjectLegalHold + IsObjectLegalHoldEnabled + GetObjectRetention + SetObjectRetention + GetPresignedObjectUrl + GetPresignedPostFormData + PutObjectProgress + GetObjectProgress + ) + + foreach(target ${EXAMPLE_APPS}) + add_executable(${target} examples/${target}.cc) + target_compile_features(${target} PUBLIC cxx_std_${MINIO_CPP_STD}) + target_include_directories(${target} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/include) + target_link_libraries(${target} PRIVATE miniocpp::miniocpp ${MINIO_CPP_LIBS}) + endforeach() + + add_executable(tests tests/tests.cc) + target_compile_features(tests PUBLIC cxx_std_${MINIO_CPP_STD}) + target_include_directories(tests PRIVATE ${CMAKE_CURRENT_LIST_DIR}/include) + target_link_libraries(tests miniocpp ${MINIO_CPP_LIBS}) +endif() -option(BUILD_DOC "Build documentation" ON) +# Minio C++ Documentation +# ----------------------- -if (BUILD_DOC) +if (MINIO_CPP_MAKE_DOC) # check if Doxygen is installed find_package(Doxygen) if (DOXYGEN_FOUND) - # set input and output files - set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in) - set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) - - # request to configure the file - configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) - message("Doxygen build started") - - # note the option ALL which allows to build the docs together with the application - add_custom_target(doc_doxygen ALL - COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Generating API documentation with Doxygen" - VERBATIM ) - else (DOXYGEN_FOUND) + # set input and output files + set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in) + set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) + + # request to configure the file + configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) + + # note the option ALL which allows to build the docs together with the application + add_custom_target(doc_doxygen ALL + COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Generating API documentation with Doxygen" + VERBATIM ) + else() message("Doxygen need to be installed to generate the doxygen documentation") - endif (DOXYGEN_FOUND) -endif(BUILD_DOC) + endif() +endif() + +# Installation Instructions +# ------------------------- + +install(TARGETS miniocpp + EXPORT miniocpp-config + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") + +install(EXPORT miniocpp-config + NAMESPACE miniocpp:: + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/miniocpp") -configure_file(miniocpp.pc.in miniocpp.pc @ONLY) -install(FILES ${CMAKE_BINARY_DIR}/miniocpp.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +install(FILES + ${MINIO_CPP_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/miniocpp") +configure_file(miniocpp.pc.in ${CMAKE_CURRENT_BINARY_DIR}/miniocpp.pc @ONLY) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/miniocpp.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) diff --git a/README.md b/README.md index f0ffc669..853f4927 100644 --- a/README.md +++ b/README.md @@ -4,17 +4,57 @@ MinIO C++ SDK is Simple Storage Service (aka S3) client to perform bucket and ob For a complete list of APIs and examples, please take a look at the [MinIO C++ Client API Reference](https://minio-cpp.min.io/) -## Build requirements -* A working C++ development environment supporting C++17 standards. -* CMake 3.10 or higher. -* [vcpkg](https://vcpkg.io/en/index.html). +## Build Requirements -## Install from `vcpkg` +* [cmake](https://cmake.org/) 3.10 or higher. +* [vcpkg](https://vcpkg.io/en/index.html) package manager. +* A working C++ compiler that supports at least C++17. + +## Installation via `vcpkg` + +MinIO C++ client SDK can be installed via `vcpkg` package manager: + +```bash +$ vcpkg install minio-cpp +``` + +Typically `minio-cpp` will be part of dependencies specified in `vcpkg.json` file: + +```json +{ + "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", + "name": "your-project", + "version": "0.0.1", + "dependencies": [ + { "name": "minio-cpp" } + ] +} ``` -vcpkg install minio-cpp + +## Hacking minio-cpp + +In order to run minio-cpp tests and examples, you can do the following assuming `VCPKG_ROOT` points to a `vcpkg` installation: + +```bash +$ git clone https://github.com/minio/minio-cpp +$ cd minio-cpp +$ ${VCPKG_ROOT}/vcpkg install +$ cmake . -B build/Debug -DCMAKE_BUILD_TYPE=Debug -DMINIO_CPP_TEST=ON -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake +$ cmake --build ./build/Debug ``` -## Building source +Note that cmake also supports multi-configuration generators. Multi-configuration generators don't use `CMAKE_BUILD_TYPE` during configure time. For example a Visual Studio project can be setup the following way: + +```bash +$ git clone https://github.com/minio/minio-cpp +$ cd minio-cpp +$ ${VCPKG_ROOT}/vcpkg install +$ cmake . -B build -DMINIO_CPP_TEST=ON -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake +$ cmake --build ./build --config Debug +``` + +The examples above assumed that you have `vcpkg` already installed and you have a `VCPKG_ROOT` environment variable set. This is common if you use `vcpkg` to handle dependencies of multiple projects as only a single installation of `vcpkg` is required in that case. If you don't have `vcpkg` installed and you only want to use it to test `minio-cpp`, it's possible to install it locally like this: + ```bash $ git clone https://github.com/minio/minio-cpp $ cd minio-cpp @@ -22,11 +62,20 @@ $ wget --quiet -O vcpkg-master.zip https://github.com/microsoft/vcpkg/archive/re $ unzip -qq vcpkg-master.zip $ ./vcpkg-master/bootstrap-vcpkg.sh $ ./vcpkg-master/vcpkg integrate install -$ cmake -B ./build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=./vcpkg-master/scripts/buildsystems/vcpkg.cmake -$ cmake --build ./build --config Debug +$ cmake . -B ./build/Debug -DCMAKE_BUILD_TYPE=Debug -DMINIO_CPP_TEST=ON -DCMAKE_TOOLCHAIN_FILE=./vcpkg-master/scripts/buildsystems/vcpkg.cmake +$ cmake --build ./build/Debug +``` + +We recommend the setup with `VCPKG_ROOT` for development. In that case there is a `configure.sh` script, that can be used to create both Debug and Release projects: + +```bash +$ git clone https://github.com/minio/minio-cpp +$ cd minio-cpp +$ ./configure.sh -DMINIO_CPP_TEST=ON ``` ## Example:: file-uploader.cc + ```c++ #include @@ -92,4 +141,5 @@ int main(int argc, char* argv[]) { ``` ## License + This SDK is distributed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0), see [LICENSE](https://github.com/minio/minio-cpp/blob/master/LICENSE) for more information. diff --git a/configure.sh b/configure.sh new file mode 100755 index 00000000..f28e3d91 --- /dev/null +++ b/configure.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +BUILD_OPTIONS="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" + +if [ -n "$VCPKG_ROOT" ]; then + $VCPKG_ROOT/vcpkg install + BUILD_OPTIONS="${BUILD_OPTIONS} -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" +fi + +echo "== [Configuring Build - Debug] ==" +eval cmake . -B build/Debug -DCMAKE_BUILD_TYPE=Debug ${BUILD_OPTIONS} "$@" +echo "" + +echo "== [Configuring Build - Release] ==" +eval cmake . -B build/Release -DCMAKE_BUILD_TYPE=Release ${BUILD_OPTIONS} "$@" +echo "" diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt deleted file mode 100644 index 3cbab052..00000000 --- a/examples/CMakeLists.txt +++ /dev/null @@ -1,154 +0,0 @@ -SET(S3_LIBS ${requiredlibs}) - -ADD_EXECUTABLE(MakeBucket MakeBucket.cc) -TARGET_LINK_LIBRARIES(MakeBucket miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(RemoveBucket RemoveBucket.cc) -TARGET_LINK_LIBRARIES(RemoveBucket miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(BucketExists BucketExists.cc) -TARGET_LINK_LIBRARIES(BucketExists miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(ListBuckets ListBuckets.cc) -TARGET_LINK_LIBRARIES(ListBuckets miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(StatObject StatObject.cc) -TARGET_LINK_LIBRARIES(StatObject miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(RemoveObject RemoveObject.cc) -TARGET_LINK_LIBRARIES(RemoveObject miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(DownloadObject DownloadObject.cc) -TARGET_LINK_LIBRARIES(DownloadObject miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(UploadObject UploadObject.cc) -TARGET_LINK_LIBRARIES(UploadObject miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(GetObject GetObject.cc) -TARGET_LINK_LIBRARIES(GetObject miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(ListObjects ListObjects.cc) -TARGET_LINK_LIBRARIES(ListObjects miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(PutObject PutObject.cc) -TARGET_LINK_LIBRARIES(PutObject miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(CopyObject CopyObject.cc) -TARGET_LINK_LIBRARIES(CopyObject miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(ComposeObject ComposeObject.cc) -TARGET_LINK_LIBRARIES(ComposeObject miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(RemoveObjects RemoveObjects.cc) -TARGET_LINK_LIBRARIES(RemoveObjects miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(SelectObjectContent SelectObjectContent.cc) -TARGET_LINK_LIBRARIES(SelectObjectContent miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(ListenBucketNotification ListenBucketNotification.cc) -TARGET_LINK_LIBRARIES(ListenBucketNotification miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(DeleteBucketPolicy DeleteBucketPolicy.cc) -TARGET_LINK_LIBRARIES(DeleteBucketPolicy miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(GetBucketPolicy GetBucketPolicy.cc) -TARGET_LINK_LIBRARIES(GetBucketPolicy miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(SetBucketPolicy SetBucketPolicy.cc) -TARGET_LINK_LIBRARIES(SetBucketPolicy miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(DeleteBucketNotification DeleteBucketNotification.cc) -TARGET_LINK_LIBRARIES(DeleteBucketNotification miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(GetBucketNotification GetBucketNotification.cc) -TARGET_LINK_LIBRARIES(GetBucketNotification miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(SetBucketNotification SetBucketNotification.cc) -TARGET_LINK_LIBRARIES(SetBucketNotification miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(DeleteBucketEncryption DeleteBucketEncryption.cc) -TARGET_LINK_LIBRARIES(DeleteBucketEncryption miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(GetBucketEncryption GetBucketEncryption.cc) -TARGET_LINK_LIBRARIES(GetBucketEncryption miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(SetBucketEncryption SetBucketEncryption.cc) -TARGET_LINK_LIBRARIES(SetBucketEncryption miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(GetBucketVersioning GetBucketVersioning.cc) -TARGET_LINK_LIBRARIES(GetBucketVersioning miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(SetBucketVersioning SetBucketVersioning.cc) -TARGET_LINK_LIBRARIES(SetBucketVersioning miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(DeleteBucketReplication DeleteBucketReplication.cc) -TARGET_LINK_LIBRARIES(DeleteBucketReplication miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(GetBucketReplication GetBucketReplication.cc) -TARGET_LINK_LIBRARIES(GetBucketReplication miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(SetBucketReplication SetBucketReplication.cc) -TARGET_LINK_LIBRARIES(SetBucketReplication miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(DeleteBucketLifecycle DeleteBucketLifecycle.cc) -TARGET_LINK_LIBRARIES(DeleteBucketLifecycle miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(GetBucketLifecycle GetBucketLifecycle.cc) -TARGET_LINK_LIBRARIES(GetBucketLifecycle miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(SetBucketLifecycle SetBucketLifecycle.cc) -TARGET_LINK_LIBRARIES(SetBucketLifecycle miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(DeleteBucketTags DeleteBucketTags.cc) -TARGET_LINK_LIBRARIES(DeleteBucketTags miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(GetBucketTags GetBucketTags.cc) -TARGET_LINK_LIBRARIES(GetBucketTags miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(SetBucketTags SetBucketTags.cc) -TARGET_LINK_LIBRARIES(SetBucketTags miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(DeleteObjectLockConfig DeleteObjectLockConfig.cc) -TARGET_LINK_LIBRARIES(DeleteObjectLockConfig miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(GetObjectLockConfig GetObjectLockConfig.cc) -TARGET_LINK_LIBRARIES(GetObjectLockConfig miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(SetObjectLockConfig SetObjectLockConfig.cc) -TARGET_LINK_LIBRARIES(SetObjectLockConfig miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(DeleteObjectTags DeleteObjectTags.cc) -TARGET_LINK_LIBRARIES(DeleteObjectTags miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(GetObjectTags GetObjectTags.cc) -TARGET_LINK_LIBRARIES(GetObjectTags miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(SetObjectTags SetObjectTags.cc) -TARGET_LINK_LIBRARIES(SetObjectTags miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(DisableObjectLegalHold DisableObjectLegalHold.cc) -TARGET_LINK_LIBRARIES(DisableObjectLegalHold miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(EnableObjectLegalHold EnableObjectLegalHold.cc) -TARGET_LINK_LIBRARIES(EnableObjectLegalHold miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(IsObjectLegalHoldEnabled IsObjectLegalHoldEnabled.cc) -TARGET_LINK_LIBRARIES(IsObjectLegalHoldEnabled miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(GetObjectRetention GetObjectRetention.cc) -TARGET_LINK_LIBRARIES(GetObjectRetention miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(SetObjectRetention SetObjectRetention.cc) -TARGET_LINK_LIBRARIES(SetObjectRetention miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(GetPresignedObjectUrl GetPresignedObjectUrl.cc) -TARGET_LINK_LIBRARIES(GetPresignedObjectUrl miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(GetPresignedPostFormData GetPresignedPostFormData.cc) -TARGET_LINK_LIBRARIES(GetPresignedPostFormData miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(PutObjectProgress PutObjectProgress.cc) -TARGET_LINK_LIBRARIES(PutObjectProgress miniocpp ${S3_LIBS}) - -ADD_EXECUTABLE(GetObjectProgress GetObjectProgress.cc) -TARGET_LINK_LIBRARIES(GetObjectProgress miniocpp ${S3_LIBS}) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt deleted file mode 100644 index 390950be..00000000 --- a/include/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -# MinIO C++ Library for Amazon S3 Compatible Cloud Storage -# Copyright 2021 MinIO, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -INCLUDE (CheckIncludeFiles) -INCLUDE (CheckFunctionExists) - -CHECK_INCLUDE_FILES(inttypes.h HAVE_INTTYPES_H) -CHECK_INCLUDE_FILES(stdint.h HAVE_STDINT_H) -CHECK_INCLUDE_FILES(stdlib.h HAVE_STDLIB_H) -CHECK_INCLUDE_FILES(limits.h HAVE_LIMITS_H) -CHECK_INCLUDE_FILES(sys/types.h HAVE_SYS_TYPES_H) - -CHECK_FUNCTION_EXISTS(strtoimax HAVE_STRTOIMAX_F) -CHECK_FUNCTION_EXISTS(strptime HAVE_STRPTIME_F) - -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config.h @ONLY) - -# install all the headers -FILE(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/*.h") -INSTALL(FILES ${files} DESTINATION include/miniocpp) - -INSTALL(FILES DESTINATION include) diff --git a/include/config.h b/include/config.h new file mode 100644 index 00000000..46665a66 --- /dev/null +++ b/include/config.h @@ -0,0 +1,74 @@ +// MinIO C++ Library for Amazon S3 Compatible Cloud Storage +// Copyright 2022 MinIO, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef MINIO_CPP_CONFIG_H_INCLUDED +#define MINIO_CPP_CONFIG_H_INCLUDED + +#define MINIO_CPP_STRINGIFY(x) #x + +#define MINIO_CPP_MAJOR_VERSION 0 +#define MINIO_CPP_MINOR_VERSION 1 +#define MINIO_CPP_PATCH_VERSION 1 + +#define MINIO_CPP_VERSION \ + "" MINIO_CPP_STRINGIFY(MINIO_CPP_MAJOR_VERSION) "." MINIO_CPP_STRINGIFY( \ + MINIO_CPP_MINOR_VERSION) "." MINIO_CPP_STRINGIFY(MINIO_CPP_PATCH_VERSION) + +#if defined(_M_X64) || defined(__x86_64__) +#define MINIO_CPP_ARCH_STRING "x86_64" +#elif defined(_M_IX86) || defined(__X86__) || defined(__i386__) +#define MINIO_CPP_ARCH_STRING "x86" +#elif defined(_M_ARM64) || defined(__arm64__) || defined(__aarch64__) +#define MINIO_CPP_ARCH_STRING "arm64" +#elif defined(_M_ARM) || defined(_M_ARMT) || defined(__arm__) || \ + defined(__thumb__) || defined(__thumb2__) +#define MINIO_CPP_ARCH_STRING "arm32" +#elif defined(_MIPS_ARCH_MIPS64) || defined(__mips64) +#define MINIO_CPP_ARCH_STRING "mips64" +#elif defined(_MIPS_ARCH_MIPS32) || defined(_M_MRX000) || defined(__mips__) +#define MINIO_CPP_ARCH_STRING "mips32" +#elif (defined(__riscv) || defined(__riscv__)) && defined(__riscv_xlen) +#define MINIO_CPP_ARCH_STRING "riscv" MINIO_CPP_STRINGIFY(__riscv_xlen) +#elif defined(__loongarch__) +#define MINIO_CPP_ARCH_STRING "loongarch" +#elif defined(__s390__) || defined(__s390x__) +#define MINIO_CPP_ARCH_STRING "s390" +#else +#define MINIO_CPP_ARCH_STRING "unknown-arch" +#endif + +#if defined(_WIN32) || defined(__CYGWIN__) +#define MINIO_CPP_PLATFORM_STRING "windows" +#elif defined(__ANDROID__) +#define MINIO_CPP_PLATFORM_STRING "android" +#elif defined(__linux__) || defined(__linux) +#define MINIO_CPP_PLATFORM_STRING "linux" +#elif defined(__APPLE__) || defined(__MACH__) +#define MINIO_CPP_PLATFORM_STRING "darwin" +#elif defined(__FreeBSD__) +#define MINIO_CPP_PLATFORM_STRING "freebsd" +#elif defined(__NetBSD__) +#define MINIO_CPP_PLATFORM_STRING "netbsd" +#elif defined(__OpenBSD__) +#define MINIO_CPP_PLATFORM_STRING "openbsd" +#else +#define MINIO_CPP_PLATFORM_STRING "unknown-os" +#endif + +#define DEFAULT_USER_AGENT \ + "MinIO (" MINIO_CPP_PLATFORM_STRING "; " MINIO_CPP_ARCH_STRING \ + ") minio-cpp/" MINIO_CPP_VERSION "" + +#endif // MINIO_CPP_CONFIG_H_INCLUDED diff --git a/include/config.h.in b/include/config.h.in deleted file mode 100644 index 657ebe26..00000000 --- a/include/config.h.in +++ /dev/null @@ -1,26 +0,0 @@ -// MinIO C++ Library for Amazon S3 Compatible Cloud Storage -// Copyright 2022 MinIO, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef _MINIO_CONFIG_H -#define _MINIO_CONFIG_H - -#define MINIO_CPP_MAJOR_VERSION @MINIOCPP_MAJOR_VERSION@ -#define MINIO_CPP_MINOR_VERSION @MINIOCPP_MINOR_VERSION@ -#define MINIO_CPP_PATCH_VERSION @MINIOCPP_PATCH_VERSION@ -#define MINIO_CPP_VERSION "@MINIOCPP_MAJOR_VERSION@.@MINIOCPP_MINOR_VERSION@.@MINIOCPP_PATCH_VERSION@" - -#define DEFAULT_USER_AGENT "MinIO (@CMAKE_SYSTEM_NAME@; @CMAKE_HOST_SYSTEM_PROCESSOR@) minio-cpp/" MINIO_CPP_VERSION - -#endif // #ifndef __MINIO_CONFIG_H diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index b7bcadbe..00000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -# MinIO C++ Library for Amazon S3 Compatible Cloud Storage -# Copyright 2021 MinIO, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -list(APPEND SRCS args.cc baseclient.cc client.cc credentials.cc http.cc providers.cc request.cc response.cc select.cc signer.cc sse.cc types.cc utils.cc) - -add_library(miniocpp STATIC ${SRCS}) -target_link_libraries(miniocpp ${requiredlibs}) - -list(APPEND S3CLIENT_INSTALL_LIST miniocpp) - -SET_TARGET_PROPERTIES(miniocpp PROPERTIES - VERSION ${MINIOCPP_MAJOR_VERSION}.${MINIOCPP_MINOR_VERSION}.${MINIOCPP_PATCH_VERSION} - CLEAN_DIRECT_OUTPUT 1 -) - -# install the library -INSTALL(TARGETS ${S3CLIENT_INSTALL_LIST} - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib -) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt deleted file mode 100644 index 44d14397..00000000 --- a/tests/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -ADD_EXECUTABLE(tests tests.cc) -TARGET_LINK_LIBRARIES(tests miniocpp ${requiredlibs}) diff --git a/vcpkg.json b/vcpkg.json index 9c8ebf9d..607cae41 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -4,25 +4,13 @@ "description": "The MinIO C++ Client SDK provides simple APIs to access any Amazon S3 compatible object storage", "homepage": "https://github.com/minio/minio-cpp", "license": "Apache-2.0", - "supports": "!windows & !osx & !uwp", "dependencies": [ - "curlpp", - { - "name": "inih", - "features": [ - "cpp" - ] - }, - "nlohmann-json", - "openssl", - "pugixml", - { - "name": "vcpkg-cmake", - "host": true - }, - { - "name": "vcpkg-cmake-config", - "host": true - } + { "name": "curlpp" }, + { "name": "inih", "features": ["cpp"] }, + { "name": "nlohmann-json" }, + { "name": "openssl" }, + { "name": "pugixml" }, + { "name": "vcpkg-cmake", "host": true }, + { "name": "vcpkg-cmake-config", "host": true } ] }