From f1ac4222e1f2b1ecd072156c3228a16c6485d482 Mon Sep 17 00:00:00 2001 From: sha512sum Date: Fri, 27 Sep 2024 19:28:22 +0000 Subject: [PATCH] Add libxml++5.0 link on cmake --- .gitignore | 5 +++++ CMakeLists.txt | 59 +++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 3cd684b..6ceee8b 100644 --- a/.gitignore +++ b/.gitignore @@ -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* diff --git a/CMakeLists.txt b/CMakeLists.txt index c687087..4e358d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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= + CONFIGURE_HANDLED_BY_BUILD ON + BUILD_COMMAND ${Ninja_EXECUTABLE} -C + INSTALL_COMMAND ${Ninja_EXECUTABLE} -C 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()