From 127059e7c600c3381fd53298cae764d55938e427 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Fri, 24 Nov 2023 12:41:44 -0500 Subject: [PATCH] cmake: rename qatzip->QATzip and support pkg-config Signed-off-by: Casey Bodley --- CMakeLists.txt | 6 +++--- cmake/modules/FindQATzip.cmake | 32 ++++++++++++++++++++++++++++++++ cmake/modules/Findqatzip.cmake | 24 ------------------------ src/CMakeLists.txt | 3 ++- src/compressor/CMakeLists.txt | 2 +- 5 files changed, 38 insertions(+), 29 deletions(-) create mode 100644 cmake/modules/FindQATzip.cmake delete mode 100644 cmake/modules/Findqatzip.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 213c6b69473..edb653a68fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -309,6 +309,7 @@ option(WITH_BLUEFS "libbluefs library" OFF) option(WITH_QATLIB "Enable QAT with qatlib" OFF) option(WITH_QATDRV "Enable QAT with out-of-tree driver" OFF) +option(WITH_QATZIP "Enable QATzip" OFF) if(WITH_QATDRV) find_package(QatDrv REQUIRED COMPONENTS qat_s usdm_drv_s) @@ -318,10 +319,9 @@ elseif(WITH_QATLIB) set(HAVE_QAT TRUE) endif() -option(WITH_QATZIP "Enable QATZIP" OFF) if(WITH_QATZIP) - find_package(qatzip REQUIRED) - set(HAVE_QATZIP ${qatzip_FOUND}) + find_package(QATzip REQUIRED) + set(HAVE_QATZIP TRUE) endif(WITH_QATZIP) # needs mds and? XXX diff --git a/cmake/modules/FindQATzip.cmake b/cmake/modules/FindQATzip.cmake new file mode 100644 index 00000000000..e61f5f7f4a1 --- /dev/null +++ b/cmake/modules/FindQATzip.cmake @@ -0,0 +1,32 @@ +# - Find QATzip +# Find the QATzip compression library and includes +# +# QATzip_INCLUDE_DIR - where to find QATzip.h, etc. +# QATzip_LIBRARIES - List of libraries when using QATzip. +# QATzip_FOUND - True if QATzip found. + +find_package(PkgConfig QUIET) +pkg_search_module(PC_QATzip qatzip QUIET) + +find_path(QATzip_INCLUDE_DIR + NAMES qatzip.h + HINTS ${PC_QATzip_INCLUDE_DIRS}) + +find_library(QATzip_LIBRARIES + NAMES qatzip + HINTS ${PC_QATzip_LIBRARY_DIRS}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(QATzip DEFAULT_MSG QATzip_LIBRARIES QATzip_INCLUDE_DIR) + +mark_as_advanced( + QATzip_LIBRARIES + QATzip_INCLUDE_DIR) + +if(QATzip_FOUND AND NOT TARGET QAT::zip) + add_library(QAT::zip SHARED IMPORTED) + set_target_properties(QAT::zip PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${QATzip_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${QATzip_LIBRARIES}") +endif() diff --git a/cmake/modules/Findqatzip.cmake b/cmake/modules/Findqatzip.cmake deleted file mode 100644 index 2d0f2ace388..00000000000 --- a/cmake/modules/Findqatzip.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# - Find qatzip -# Find the qatzip compression library and includes -# -# qatzip_INCLUDE_DIR - where to find qatzip.h, etc. -# qatzip_LIBRARIES - List of libraries when using qatzip. -# qatzip_FOUND - True if qatzip found. - -find_path(qatzip_INCLUDE_DIR NAMES qatzip.h) -find_library(qatzip_LIBRARIES NAMES qatzip HINTS /usr/local/lib64/) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(qatzip DEFAULT_MSG qatzip_LIBRARIES qatzip_INCLUDE_DIR) - -mark_as_advanced( - qatzip_LIBRARIES - qatzip_INCLUDE_DIR) - -if(qatzip_FOUND AND NOT TARGET qatzip::qatzip) - add_library(qatzip::qatzip SHARED IMPORTED) - set_target_properties(qatzip::qatzip PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${qatzip_INCLUDE_DIR}" - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${qatzip_LIBRARIES}") -endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d266eb72598..23196619eb8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -506,7 +506,8 @@ if(NOT WITH_SYSTEM_BOOST) endif() if(HAVE_QATZIP) - list(APPEND ceph_common_deps ${qatzip_LIBRARIES}) + # TODO: only the compression plugins should depend on QAT + list(APPEND ceph_common_deps QAT::zip) endif() if(WITH_DPDK) diff --git a/src/compressor/CMakeLists.txt b/src/compressor/CMakeLists.txt index 1f9cab5f3c7..d9512e87408 100644 --- a/src/compressor/CMakeLists.txt +++ b/src/compressor/CMakeLists.txt @@ -10,7 +10,7 @@ if(HAVE_QATZIP AND HAVE_QAT) target_link_libraries(compressor_objs PRIVATE QAT::qat QAT::usdm - qatzip::qatzip + QAT::zip ) endif() add_dependencies(compressor_objs legacy-option-headers) -- 2.39.5