Skip to content

Commit

Permalink
lib: introduce zlib library
Browse files Browse the repository at this point in the history
Introduce a new "zlib" library which provides simplified bindings for
zlib inflate/deflate operations.

Signed-off-by: Thibaut VARÈNE <[email protected]>
  • Loading branch information
f00b4r0 committed Jun 6, 2024
1 parent 2a0240f commit 93a6314
Show file tree
Hide file tree
Showing 2 changed files with 507 additions and 0 deletions.
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ find_library(libuci NAMES uci)
find_library(libubox NAMES ubox)
find_library(libubus NAMES ubus)
find_library(libblobmsg_json NAMES blobmsg_json)
find_package(ZLIB)

if(LINUX)
find_library(libnl_tiny NAMES nl-tiny)
Expand All @@ -49,6 +50,10 @@ if(libubox)
set(DEFAULT_ULOOP_SUPPORT ON)
endif()

if(ZLIB_FOUND)
set(DEFAULT_ZLIB_SUPPORT ON)
endif()

option(DEBUG_SUPPORT "Debug plugin support" ON)
option(FS_SUPPORT "Filesystem plugin support" ON)
option(MATH_SUPPORT "Math plugin support" ON)
Expand All @@ -61,6 +66,7 @@ option(STRUCT_SUPPORT "Struct plugin support" ON)
option(ULOOP_SUPPORT "Uloop plugin support" ${DEFAULT_ULOOP_SUPPORT})
option(LOG_SUPPORT "Log plugin support" ON)
option(SOCKET_SUPPORT "Socket plugin support" ON)
option(ZLIB_SUPPORT "Zlib plugin support" ${DEFAULT_ZLIB_SUPPORT})

set(LIB_SEARCH_PATH "${CMAKE_INSTALL_PREFIX}/lib/ucode/*.so:${CMAKE_INSTALL_PREFIX}/share/ucode/*.uc:./*.so:./*.uc" CACHE STRING "Default library search path")
string(REPLACE ":" "\", \"" LIB_SEARCH_DEFINE "${LIB_SEARCH_PATH}")
Expand Down Expand Up @@ -276,6 +282,14 @@ if(SOCKET_SUPPORT)
target_link_options(socket_lib PRIVATE ${UCODE_MODULE_LINK_OPTIONS})
endif()

if(ZLIB_SUPPORT)
set(LIBRARIES ${LIBRARIES} zlib_lib)
add_library(zlib_lib MODULE lib/zlib.c)
set_target_properties(zlib_lib PROPERTIES OUTPUT_NAME zlib PREFIX "")
target_link_options(zlib_lib PRIVATE ${UCODE_MODULE_LINK_OPTIONS})
target_link_libraries(zlib_lib ZLIB::ZLIB)
endif()

if(UNIT_TESTING)
enable_testing()
add_definitions(-DUNIT_TESTING)
Expand Down
Loading

0 comments on commit 93a6314

Please sign in to comment.