the-moisrex / liburing-hdr-only

The header only implementation of the liburing library
MIT License
18 stars 1 forks source link

Liburing header-only

This is an implementation of liburing that's header only and trying to be standard compliant (which liburing itself is not).

Goals of this fork

This library is a fork of liburing 2.4 (or 2.5, here's the exact commit); we've kept up with the changes so far (version 2.7).

C++ users

Usage in CMake

Using CPM.cmake (Use a release link instead of the master branch, and adjust the version):

CPMAddPackage(
        NAME liburing
        URL https://github.com/the-moisrex/liburing-hdr-only/archive/refs/heads/master.zip
        VERSION 2.7
        OPTIONS
            "LIBURING_CXX ON"
)

Using original liburing, and fallback on the header only version

#ifdef __linux__
#    if defined(USE_OS_LIBURING) && __has_include(<liburing.h>)
#        include <liburing.h>
#    else
#        include <liburing/liburing-hdr-only.h>
#    endif
#endif

Then define USE_OS_LIBURING in your build system (-DUSE_OS_LIBURING) to enable the use of original liburing if it exists, and fallback on the header-only version otherwise.

Using header-only version, and fallback on the original version if it doesn't exist

#ifdef __linux__
#    if __has_include(<liburing/liburing-hdr-only.h>)
#        include <liburing/liburing-hdr-only.h>
#    else
#        include <liburing.h>
#    endif
#endif