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)