Added very basic XML support using libxml2. (0.35.0)
This commit is contained in:
parent
ecf64d6ac2
commit
e65756226d
17 changed files with 436 additions and 3 deletions
|
|
@ -1,5 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.10)
|
||||
project(fun VERSION 0.34.1 LANGUAGES C)
|
||||
project(fun VERSION 0.35.0 LANGUAGES C)
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
|
|
@ -120,6 +120,40 @@ if(FUN_WITH_INI)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
# Optional XML (libxml2) support
|
||||
option(FUN_WITH_XML2 "Enable XML (libxml2) support" OFF)
|
||||
set(LIBXML2_INCLUDE_DIRS "")
|
||||
set(LIBXML2_LINK_LIBS "")
|
||||
if(FUN_WITH_XML2)
|
||||
message(STATUS "Building with XML (libxml2) support")
|
||||
add_definitions(-DFUN_WITH_XML2)
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(LIBXML2 QUIET libxml-2.0)
|
||||
endif()
|
||||
if(LIBXML2_FOUND)
|
||||
list(APPEND LIBXML2_INCLUDE_DIRS ${LIBXML2_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIRS})
|
||||
list(APPEND LIBXML2_LINK_LIBS ${LIBXML2_LINK_LIBS} ${LIBXML2_LIBRARIES})
|
||||
include_directories(${LIBXML2_INCLUDE_DIRS})
|
||||
else()
|
||||
find_library(LIBXML2_LIB NAMES xml2 libxml2)
|
||||
if(LIBXML2_LIB)
|
||||
list(APPEND LIBXML2_LINK_LIBS ${LIBXML2_LIB})
|
||||
# Common system include location for libxml2 headers
|
||||
if(EXISTS "/usr/include/libxml2")
|
||||
list(APPEND LIBXML2_INCLUDE_DIRS "/usr/include/libxml2")
|
||||
include_directories(${LIBXML2_INCLUDE_DIRS})
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "libxml2 not found. Install libxml2 (dev headers) or disable FUN_WITH_XML2.")
|
||||
endif()
|
||||
endif()
|
||||
# As a robust fallback, add standard system include path for libxml2 if present
|
||||
if(EXISTS "/usr/include/libxml2")
|
||||
include_directories("/usr/include/libxml2")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Optional libsql support (independent from SQLite)
|
||||
option(FUN_WITH_LIBSQL "Enable libsql (Turso) client support" OFF)
|
||||
set(LIBSQL_INCLUDE_DIRS "")
|
||||
|
|
@ -281,6 +315,19 @@ if(LIBSQL_LINK_LIBS)
|
|||
target_link_libraries(fun_core PUBLIC ${LIBSQL_LINK_LIBS})
|
||||
endif()
|
||||
|
||||
# libxml2 include and link (if enabled)
|
||||
if(LIBXML2_INCLUDE_DIRS)
|
||||
target_include_directories(fun_core PRIVATE ${LIBXML2_INCLUDE_DIRS})
|
||||
endif()
|
||||
if(LIBXML2_LINK_LIBS)
|
||||
target_link_libraries(fun_core PUBLIC ${LIBXML2_LINK_LIBS})
|
||||
endif()
|
||||
if(FUN_WITH_XML2)
|
||||
if(EXISTS "/usr/include/libxml2")
|
||||
target_include_directories(fun_core PRIVATE "/usr/include/libxml2")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Link threads if available on UNIX
|
||||
if(Threads_FOUND)
|
||||
target_link_libraries(fun_core PUBLIC Threads::Threads)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue