From e0b7bf82aa655d4e1c63012c3be6216b4818dc04 Mon Sep 17 00:00:00 2001 From: Tobias Frost Date: Sun, 14 Jul 2024 12:14:36 +0200 Subject: [PATCH] Use packaged version of pugixml, if it is installed --- CMakeLists.txt | 8 ++++++++ libs/xmlutil/CMakeLists.txt | 5 +++++ libs/xmlutil/Document.h | 2 +- libs/xmlutil/Node.h | 3 +-- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index df5d53ee7..3d9fa7b7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,14 @@ pkg_check_modules(ZLIB zlib REQUIRED) pkg_check_modules(GLIB glib-2.0 REQUIRED) pkg_check_modules(EIGEN eigen3 REQUIRED) +# Locate a packaged pugixml, if installed if not, fall back to embedded code copy. +find_package(pugixml QUIET) +if (TARGET pugixml::pugixml) + message(NOTICE "Distribution pugixml found and used.") +else() + include_directories(libs/pugixml) +endif() + # Locate wxWidgets find_package(wxWidgets REQUIRED COMPONENTS base core stc adv gl xrc aui) diff --git a/libs/xmlutil/CMakeLists.txt b/libs/xmlutil/CMakeLists.txt index 2ab3b9bc6..8e9ed1ab9 100644 --- a/libs/xmlutil/CMakeLists.txt +++ b/libs/xmlutil/CMakeLists.txt @@ -1 +1,6 @@ add_library(xmlutil Document.cpp Node.cpp) + +# link with system puixml if we have it. +if (TARGET pugixml::pugixml) + target_link_libraries(xmlutil PUBLIC pugixml::pugixml) +endif() diff --git a/libs/xmlutil/Document.h b/libs/xmlutil/Document.h index 5e4b74149..98af92ed5 100644 --- a/libs/xmlutil/Document.h +++ b/libs/xmlutil/Document.h @@ -1,8 +1,8 @@ #pragma once #include "Node.h" -#include "pugixml/pugixml.hpp" +#include #include #include #include diff --git a/libs/xmlutil/Node.h b/libs/xmlutil/Node.h index 901dd9184..260a77bfe 100644 --- a/libs/xmlutil/Node.h +++ b/libs/xmlutil/Node.h @@ -1,7 +1,6 @@ #pragma once -#include "pugixml/pugixml.hpp" - +#include #include #include