Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 44 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ list(APPEND MINIO_CPP_LIBS
if (WIN32)
list(APPEND MINIO_CPP_LIBS wsock32)
list(APPEND MINIO_CPP_LIBS ws2_32)
# miniocpp.pc.in has no visibility into target_link_libraries() - without this,
# pkg-config consumers (non-CMake) are missing wsock32/ws2_32 at link time
# (getaddrinfo, select, ...).
set(MINIO_CPP_PC_EXTRA_LIBS " -lwsock32 -lws2_32")
endif()

# Minio C++ Library
Expand Down Expand Up @@ -137,6 +141,7 @@ set(MINIO_CPP_HEADERS
include/miniocpp/providers.h
include/miniocpp/request.h
include/miniocpp/response.h
include/miniocpp/result.h
include/miniocpp/select.h
include/miniocpp/signer.h
include/miniocpp/sse.h
Expand Down Expand Up @@ -174,6 +179,25 @@ target_include_directories(miniocpp PUBLIC
$<BUILD_INTERFACE:${MINIO_CPP_INCLUDES}>
)
target_link_libraries(miniocpp PUBLIC ${MINIO_CPP_LIBS})

# Optional C++20 module interface for the public API (modules/miniocpp.cc).
# FILE_SET CXX_MODULES (CMake 3.28+) attaches it as a real part of the miniocpp
# target's build - the compiler gets whatever flags it needs for a module
# interface unit (e.g. /interface for MSVC) based on this declaration, not on
# the file's extension, so any CMake/MSBuild/Meson (via cmake.subproject())
# consumer of this target picks up `import miniocpp;` automatically. Requires
# C++20 (MINIO_CPP_STD=20); silently skipped otherwise for older setups.
set(MINIO_CPP_HAS_CXX_MODULE OFF)
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.28" AND MINIO_CPP_STD STREQUAL "20")
set(MINIO_CPP_HAS_CXX_MODULE ON)
target_sources(miniocpp
PUBLIC
FILE_SET CXX_MODULES
BASE_DIRS modules
FILES modules/miniocpp.cc
)
endif()

if (MINIO_CPP_ENABLE_RDMA)
target_compile_definitions(miniocpp PUBLIC MINIO_CPP_RDMA)
endif()
Expand Down Expand Up @@ -295,12 +319,22 @@ configure_package_config_file(
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)

install(TARGETS miniocpp
EXPORT miniocpp-targets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
if (MINIO_CPP_HAS_CXX_MODULE)
install(TARGETS miniocpp
EXPORT miniocpp-targets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
FILE_SET CXX_MODULES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/miniocpp/modules")
else()
install(TARGETS miniocpp
EXPORT miniocpp-targets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
endif()

install(EXPORT miniocpp-targets
NAMESPACE miniocpp::
Expand All @@ -313,5 +347,9 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/miniocpp-config.cmake"
install(FILES
${MINIO_CPP_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/miniocpp")

# error.h/credentials.h depend on the vendored tl::expected, which is otherwise
# never installed - without this, consumers (e.g. via vcpkg) fail to build.
install(DIRECTORY include/tl DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")

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)
57 changes: 57 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
project('miniocpp', 'cpp', version : '0.4.0')
Comment thread
coderabbitai[bot] marked this conversation as resolved.

cxx = meson.get_compiler('cpp')

openssl_dep = dependency('openssl')
curlpp_dep = dependency('curlpp')
inih_dep = dependency('INIReader')
nlohmann_json_dep = dependency('nlohmann_json')
pugixml_dep = dependency('pugixml')
zlib_dep = dependency('zlib')

extra_libs = []
if host_machine.system() == 'windows'
extra_libs = [cxx.find_library('ws2_32'), cxx.find_library('wsock32')]
endif

all_deps = [openssl_dep, curlpp_dep, inih_dep, nlohmann_json_dep, pugixml_dep, zlib_dep] + extra_libs
miniocpp_include = include_directories('include')

miniocpp_sources = files(
'src/args.cc',
'src/baseclient.cc',
'src/client.cc',
'src/credentials.cc',
'src/error.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',
)

# The real library - all .cc files from this repo, not the official minio-cpp
# vcpkg package.
miniocpp_lib = static_library('miniocpp', miniocpp_sources,
include_directories : miniocpp_include,
dependencies : all_deps,
)

# Module as its own target - /interface only applies to this one file, not to
# every .cc source.
miniocpp_module_lib = static_library('miniocpp_module', 'modules/miniocpp.cc',
include_directories : miniocpp_include,
dependencies : all_deps,
cpp_args : cxx.get_id() == 'msvc' ? ['/interface'] : [],
override_options : ['cpp_std=c++20'],
)

miniocpp_dep = declare_dependency(
link_with : [miniocpp_lib, miniocpp_module_lib],
include_directories : miniocpp_include,
dependencies : all_deps,
)
4 changes: 2 additions & 2 deletions miniocpp.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Name: @PROJECT_NAME@
Description: @PROJECT_DESCRIPTION@
Version: @PROJECT_VERSION@

Requires:
Libs: -L${libdir} -lminiocpp
Requires: curlpp libcrypto libssl pugixml zlib
Libs: -L${libdir} -lminiocpp@MINIO_CPP_PC_EXTRA_LIBS@
Cflags: -I${includedir}
26 changes: 26 additions & 0 deletions modules/miniocpp.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module;

#include <miniocpp/client.h>

export module miniocpp;

// Re-exporting the public API through the module requires an EXPLICIT using-
// declaration per symbol (using ns::Symbol;) - not a using-directive (using
// namespace ns;), because declarations from the global module fragment (the
// #include above) only become "reachable", not automatic members of an export
// namespace. The list below covers what a typical consumer needs today -
// extend it by adding more using-declarations as needed.
export namespace minio::s3 {
using s3::BaseUrl;
using s3::BucketExistsArgs;
using s3::BucketExistsResponse;
using s3::Client;
} // namespace minio::s3

export namespace minio::creds {
using minio::creds::StaticProvider;
}

export namespace minio {
using minio::Result;
}
Loading