This is an automated email from the ASF dual-hosted git repository.

dragon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 20e58ad3d6 Add logic to find nuraft (#10734)
20e58ad3d6 is described below

commit 20e58ad3d6b4075e0247c726dd5bb5f95e7882be
Author: dragon512 <[email protected]>
AuthorDate: Tue Nov 7 10:45:05 2023 -0600

    Add logic to find nuraft (#10734)
    
    Use standard pattern to find libraries and naming for constancy
---
 CMakeLists.txt                                     |  2 ++
 .../CMakeLists.txt => cmake/Findnuraft.cmake       | 32 ++++++++++++++++++----
 plugins/experimental/stek_share/CMakeLists.txt     |  9 +++---
 3 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e1f1541237..4cafeac123 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -329,8 +329,10 @@ if(ENABLE_QUICHE)
 endif()
 
 # for the plugin system
+find_package(nuraft)  # experimental stek_share
 find_package(maxminddb)  # Header_rewrite experimental/maxmind_acl
 
+
 if(ENABLE_ASAN)
   add_compile_options(-fsanitize=address)
   add_link_options(-fsanitize=address)
diff --git a/plugins/experimental/stek_share/CMakeLists.txt 
b/cmake/Findnuraft.cmake
similarity index 52%
copy from plugins/experimental/stek_share/CMakeLists.txt
copy to cmake/Findnuraft.cmake
index 196e435d03..25bb3a5d38 100644
--- a/plugins/experimental/stek_share/CMakeLists.txt
+++ b/cmake/Findnuraft.cmake
@@ -15,12 +15,32 @@
 #
 #######################
 
-find_package(NuRaft QUIET)
+# Findnuraft.cmake
+#
+# This will define the following variables
+#
+#     nuraft_FOUND
+#
+# and the following imported targets
+#
+#     nuraft::nuraft
+#
+
+find_library(nuraft_LIBRARY nuraft)
+find_path(
+  nuraft_INCLUDE_DIR
+  NAMES libnuraft/nuraft.hxx
+)
+
+mark_as_advanced(nuraft_FOUND nuraft_LIBRARY nuraft_INCLUDE_DIR)
 
-if(NuRaft_FOUND)
-  add_atsplugin(stek_share common.cc log_store.cc stek_share.cc stek_utils.cc)
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(nuraft REQUIRED_VARS nuraft_LIBRARY 
nuraft_INCLUDE_DIR)
 
-  target_link_libraries(stek_share PRIVATE NuRaft::static_lib OpenSSL::SSL 
yaml-cpp::yaml-cpp)
-else()
-  message(STATUS "skipping stek_share plugin (missing NuRaft)")
+# Add the library but only add libraries if nuraft is found
+add_library(nuraft::nuraft INTERFACE IMPORTED)
+if(nuraft_FOUND)
+  set(nuraft_INCLUDE_DIRS ${nuraft_INCLUDE_DIR})
+  target_include_directories(nuraft::nuraft INTERFACE ${nuraft_INCLUDE_DIRS})
+  target_link_libraries(nuraft::nuraft INTERFACE ${nuraft_LIBRARY})
 endif()
diff --git a/plugins/experimental/stek_share/CMakeLists.txt 
b/plugins/experimental/stek_share/CMakeLists.txt
index 196e435d03..9155c5a68e 100644
--- a/plugins/experimental/stek_share/CMakeLists.txt
+++ b/plugins/experimental/stek_share/CMakeLists.txt
@@ -15,12 +15,11 @@
 #
 #######################
 
-find_package(NuRaft QUIET)
-
-if(NuRaft_FOUND)
+if(nuraft_FOUND)
   add_atsplugin(stek_share common.cc log_store.cc stek_share.cc stek_utils.cc)
 
-  target_link_libraries(stek_share PRIVATE NuRaft::static_lib OpenSSL::SSL 
yaml-cpp::yaml-cpp)
+  target_include_directories(stek_share PRIVATE nuraft::nuraft OpenSSL::SSL 
yaml-cpp::yaml-cpp)
+  target_link_libraries(stek_share PRIVATE nuraft::nuraft OpenSSL::SSL 
yaml-cpp::yaml-cpp)
 else()
-  message(STATUS "skipping stek_share plugin (missing NuRaft)")
+  message(STATUS "skipping stek_share plugin (missing nuraft)")
 endif()

Reply via email to