kubernetes-client / c

Official C client library for Kubernetes
Apache License 2.0
141 stars 45 forks source link

Using the operating system provided websockets library #232

Closed rishithaminol closed 2 months ago

rishithaminol commented 2 months ago

I was able to compile with using OS provided websockets library.

OS: Fedora 39

What we have to do is install websockets (dnf install libwebsockets-devel) and do few modification to the Cmake build mechanism. Then it will pick up the OS provided libwebsockets library.

Patch

diff --git a/kubernetes/PostTarget.cmake b/kubernetes/PostTarget.cmake
index 73df36a..91419d1 100644
--- a/kubernetes/PostTarget.cmake
+++ b/kubernetes/PostTarget.cmake
@@ -5,5 +5,6 @@ else()
 endif()

 target_include_directories(${pkgName} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
-target_link_libraries(${pkgName} PRIVATE yaml ${WEBSOCKETS})
-set_target_properties(${pkgName} PROPERTIES LINKER_LANGUAGE C)
\ No newline at end of file
+include_directories(${LIBWEBSOCKETS_INCLUDE_DIR})
+target_link_libraries(${pkgName} PRIVATE yaml ${LIBWEBSOCKETS_LIBRARY})
+set_target_properties(${pkgName} PROPERTIES LINKER_LANGUAGE C)
diff --git a/kubernetes/PreTarget.cmake b/kubernetes/PreTarget.cmake
index 6187644..8ab09e3 100644
--- a/kubernetes/PreTarget.cmake
+++ b/kubernetes/PreTarget.cmake
@@ -44,5 +44,6 @@ list(APPEND HDRS
         include/generic.h
         include/utils.h)

-find_package(libwebsockets CONFIG REQUIRED)
-find_package(yaml CONFIG REQUIRED)
\ No newline at end of file
+find_path(LIBWEBSOCKETS_INCLUDE_DIR NAMES libwebsockets.h PATHS /usr/include)
+find_library(LIBWEBSOCKETS_LIBRARY NAMES websockets PATHS /usr/lib64)
+find_package(yaml CONFIG REQUIRED)

Any thoughts?

rishithaminol commented 2 months ago

Apology. This already there I think.

ityuhui commented 2 months ago

Thanks for your advice. This is what I've been planning to do since Ubuntu 22.04 LTS was released (the libwebsockets-dev package is compatible with the c client library from then).