diff --git a/CMakeLists.txt b/CMakeLists.txt index 55d58fdab..5b53058e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -352,25 +352,17 @@ int main() { return 0; } " BUILTIN_ATOMIC) -if (NOT BUILTIN_ATOMIC) - #TODO: Check if -latomic exists - list(APPEND THIRDPARTY_LIBS atomic) -endif() + if (NOT BUILTIN_ATOMIC) + #TODO: Check if -latomic exists + list(APPEND THIRDPARTY_LIBS atomic) + endif() endif() if (WITH_LIBURING) - set(CMAKE_REQUIRED_FLAGS "-luring") - CHECK_CXX_SOURCE_COMPILES(" -#include -int main() { - struct io_uring ring; - io_uring_queue_init(1, &ring, 0); - return 0; -} -" HAS_LIBURING) - if (HAS_LIBURING) + find_package(uring) + if (uring_FOUND) add_definitions(-DROCKSDB_IOURING_PRESENT) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -luring") + list(APPEND THIRDPARTY_LIBS uring::uring) endif() endif() diff --git a/cmake/modules/Finduring.cmake b/cmake/modules/Finduring.cmake new file mode 100644 index 000000000..8cb14cb27 --- /dev/null +++ b/cmake/modules/Finduring.cmake @@ -0,0 +1,26 @@ +# - Find liburing +# +# uring_INCLUDE_DIR - Where to find liburing.h +# uring_LIBRARIES - List of libraries when using uring. +# uring_FOUND - True if uring found. + +find_path(uring_INCLUDE_DIR + NAMES liburing.h) +find_library(uring_LIBRARIES + NAMES liburing.a liburing) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(uring + DEFAULT_MSG uring_LIBRARIES uring_INCLUDE_DIR) + +mark_as_advanced( + uring_INCLUDE_DIR + uring_LIBRARIES) + +if(uring_FOUND AND NOT TARGET uring::uring) + add_library(uring::uring UNKNOWN IMPORTED) + set_target_properties(uring::uring PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${uring_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${uring_LIBRARIES}") +endif() diff --git a/util/bloom_test.cc b/util/bloom_test.cc index 8636315ee..4cb774fb0 100644 --- a/util/bloom_test.cc +++ b/util/bloom_test.cc @@ -1244,7 +1244,7 @@ INSTANTIATE_TEST_CASE_P(Full, FullBloomTest, static double GetEffectiveBitsPerKey(FilterBitsBuilder* builder) { union { - uint64_t key_value; + uint64_t key_value = 0; char key_bytes[8]; };