Add libxml++5.0 link on cmake

This commit is contained in:
sha512sum 2024-09-27 19:28:22 +00:00
parent 77c1b81e95
commit f1ac4222e1
2 changed files with 61 additions and 3 deletions

5
.gitignore vendored
View file

@ -24,4 +24,9 @@ examples/output
lib__cmake_cxx23.a
liblarra_xmpp.a
liblarra_xmpp.so
CPackConfig.cmake
CPackSourceConfig.cmake
ext/
libxmlplusplus-prefix/
spdlog.pc
build*

View file

@ -36,7 +36,7 @@ find_package(OpenSSL REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTKMM gtkmm-4.0)
pkg_check_modules(GTKMM gtkmm-4.0 REQUIRED)
link_directories(
${GTKMM_LIBRARY_DIRS} )
@ -75,7 +75,60 @@ CPMAddPackage(
)
set(CPM_USE_LOCAL_PACKAGES ${TMP})
pkg_check_modules(xmlplusplus libxml++-5.0)
if(xmlplusplus_FOUND)
add_library(xmlplusplus INTERFACE EXCLUDE_FROM_ALL)
target_include_directories(xmlplusplus INTERFACE ${xmlplusplus_INCLUDE_DIRS})
target_link_libraries(xmlplusplus INTERFACE ${xmlplusplus_LINK_LIBRARIES})
install(TARGETS xmlplusplus
EXPORT larraXMPPTargets)
else()
include(ExternalProject)
find_program(Meson_EXECUTABLE meson)
if(NOT Meson_EXECUTABLE)
message(FATAL_ERROR "Meson is required!")
endif()
find_program(Ninja_EXECUTABLE ninja)
if(NOT Ninja_EXECUTABLE)
message(FATAL_ERROR "Ninja is required!")
endif()
set(XMLPLUSPLUS "libxmlplusplus")
set(XMLPLUSPLUS_INSTALL_PREFIX
"${CMAKE_CURRENT_BINARY_DIR}/ext/${XMLPLUSPLUS}")
ExternalProject_Add(${XMLPLUSPLUS}
URL https://github.com/libxmlplusplus/libxmlplusplus/releases/download/5.4.0/libxml++-5.4.0.tar.xz
INSTALL_DIR ${XMLPLUSPLUS_INSTALL_PREFIX}
CONFIGURE_COMMAND env C=${CMAKE_C_COMPILER} CC=${CMAKE_CXX_COMPILER}
${Meson_EXECUTABLE} -Ddefault_library=static --prefix=<INSTALL_DIR> <BINARY_DIR> <SOURCE_DIR>
CONFIGURE_HANDLED_BY_BUILD ON
BUILD_COMMAND ${Ninja_EXECUTABLE} -C <BINARY_DIR>
INSTALL_COMMAND ${Ninja_EXECUTABLE} -C <BINARY_DIR> install
BUILD_BYPRODUCTS
${XMLPLUSPLUS_INSTALL_PREFIX}/lib64/libxml++-5.0.${CMAKE_STATIC_LIBRARY_SUFFIX_CPP}
)
add_library(xmlplusplus STATIC IMPORTED GLOBAL)
add_dependencies(xmlplusplus ${XMLPLUSPLUS})
set_target_properties(
xmlplusplus
PROPERTIES IMPORTED_LOCATION
${XMLPLUSPLUS_INSTALL_PREFIX}/lib64/libxml++-5.0.${CMAKE_STATIC_LIBRARY_SUFFIX_CPP}
INTERFACE_INCLUDE_DIRECTORIES ${XMLPLUSPLUS_INSTALL_PREFIX}/include
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${XMLPLUSPLUS_INSTALL_PREFIX}/include)
endif()
cmake_policy(SET CMP0079 NEW)
@ -103,12 +156,12 @@ target_include_directories(larra_xmpp PUBLIC
if(TARGET Boost::pfr)
target_link_libraries(larra_xmpp PUBLIC
Boost::asio Boost::serialization utempl::utempl pugixml::pugixml OpenSSL::SSL
OpenSSL::Crypto spdlog)
OpenSSL::Crypto spdlog xmlplusplus)
else()
find_package(Boost 1.85.0 REQUIRED)
target_link_libraries(larra_xmpp PUBLIC
utempl::utempl ${Boost_LIBRARIES} pugixml::pugixml OpenSSL::SSL
OpenSSL::Crypto spdlog)
OpenSSL::Crypto spdlog xmlplusplus)
endif()