From 8f21cfa9571e8fc3518ede92356d97e09f4713de Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 10 Oct 2023 16:06:56 +0200 Subject: lib: introduce log library Introduce a new `log` library which provides bindings for syslog and, if available, the OpenWrt libubox ulog functions. Signed-off-by: Jo-Philipp Wich --- CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index d131698..ce907dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,7 @@ option(NL80211_SUPPORT "Wireless Netlink plugin support" ${DEFAULT_NL_SUPPORT}) option(RESOLV_SUPPORT "NS resolve plugin support" ON) option(STRUCT_SUPPORT "Struct plugin support" ON) option(ULOOP_SUPPORT "Uloop plugin support" ${DEFAULT_ULOOP_SUPPORT}) +option(LOG_SUPPORT "Log plugin support" ON) 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}") @@ -239,6 +240,19 @@ if(ULOOP_SUPPORT) target_link_libraries(uloop_lib ${libubox}) endif() +if(LOG_SUPPORT) + set(LIBRARIES ${LIBRARIES} log_lib) + add_library(log_lib MODULE lib/log.c) + set_target_properties(log_lib PROPERTIES OUTPUT_NAME log PREFIX "") + target_link_options(log_lib PRIVATE ${UCODE_MODULE_LINK_OPTIONS}) + if(libubox) + find_path(ulog_include_dir NAMES libubox/ulog.h) + include_directories(${ulog_include_dir}) + target_link_libraries(log_lib ${libubox}) + set_target_properties(log_lib PROPERTIES COMPILE_DEFINITIONS HAVE_ULOG) + endif() +endif() + if(UNIT_TESTING) enable_testing() add_definitions(-DUNIT_TESTING) -- cgit v1.2.3