From f4ec26171952b65a6b059c90fd87a36f2a25b33c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sun, 15 Apr 2018 18:42:56 +0200 Subject: [PATCH] CMake: Use system-wide pugixml if available Makes it possible to use a system-wide pugixml instead of always using Externals. This is nicer for distro packagers. --- CMake/FindPugixml.cmake | 14 ++++++++++++++ CMakeLists.txt | 7 ++++++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 CMake/FindPugixml.cmake diff --git a/CMake/FindPugixml.cmake b/CMake/FindPugixml.cmake new file mode 100644 index 0000000000..32f504c8b0 --- /dev/null +++ b/CMake/FindPugixml.cmake @@ -0,0 +1,14 @@ +find_path(pugixml_INCLUDE_DIRS pugixml.hpp) +find_library(pugixml_LIBRARIES NAMES pugixml) +mark_as_advanced(pugixml_INCLUDE_DIRS pugixml_LIBRARIES) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(pugixml REQUIRED_VARS pugixml_LIBRARIES pugixml_INCLUDE_DIRS) + +if(Pugixml_FOUND AND NOT TARGET pugixml) + add_library(pugixml UNKNOWN IMPORTED) + set_target_properties(pugixml PROPERTIES + IMPORTED_LOCATION "${pugixml_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${pugixml_INCLUDE_DIRS}" + ) +endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index d8f280f534..64e1bb52f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -533,7 +533,12 @@ endif() add_subdirectory(Externals/Bochs_disasm) add_subdirectory(Externals/cpp-optparse) add_subdirectory(Externals/glslang) -add_subdirectory(Externals/pugixml) + +find_package(Pugixml) +if(NOT Pugixml_FOUND) + message(STATUS "Using static pugixml from Externals") + add_subdirectory(Externals/pugixml) +endif() if(USE_SHARED_ENET) check_lib(ENET libenet enet enet/enet.h QUIET)