Description: Use system tinyxml library instead of building a local copy
Author: Felix Geyer <fgeyer@debian.org>

--- a/src/FileRead.cpp
+++ b/src/FileRead.cpp
@@ -29,7 +29,7 @@
 #include <boost/crc.hpp>
 #include <boost/algorithm/string.hpp>
 
-#include "tinyxml2.h"
+#include <tinyxml2.h>
 #include <lua.hpp>
 
 
--- a/src/replays/ReplayRecorder.cpp
+++ b/src/replays/ReplayRecorder.cpp
@@ -27,7 +27,7 @@
 
 #include <boost/algorithm/string/trim_all.hpp>
 
-#include "tinyxml2.h"
+#include <tinyxml2.h>
 
 #include "raknet/BitStream.h"
 
--- a/src/TextManager.cpp
+++ b/src/TextManager.cpp
@@ -26,7 +26,7 @@
 #include <algorithm>
 #include <set>
 
-#include "tinyxml2.h"
+#include <tinyxml2.h>
 
 #include "FileRead.h"
 
--- a/src/UserConfig.cpp
+++ b/src/UserConfig.cpp
@@ -27,7 +27,7 @@
 #include <limits>
 #include <utility>
 
-#include "tinyxml2.h"
+#include <tinyxml2.h>
 
 #include "Global.h"
 #include "FileRead.h"
--- a/src/state/NetworkSearchState.cpp
+++ b/src/state/NetworkSearchState.cpp
@@ -36,7 +36,7 @@
 #include "blobnet/layer/Http.hpp"
 #include "blobnet/exception/HttpException.hpp"
 
-#include "tinyxml2.h"
+#include <tinyxml2.h>
 
 #include "NetworkState.h"
 #include "LobbyStates.h"
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -85,6 +85,8 @@
 find_package(Boost REQUIRED)
 find_package(OpenGL)
 find_package(Lua REQUIRED)
+find_package(PkgConfig)
+pkg_check_modules(TINYXML2 REQUIRED tinyxml2)
 add_subdirectory(raknet)
 add_subdirectory(blobnet)
 
@@ -101,7 +103,7 @@
 	add_definitions("-DBLOBBY_DATA_DIR=\"${CMAKE_INSTALL_PREFIX}/share/blobby\"")
 endif()
 
-set(BLOBBY_COMMON_LIBS ${LUA_LIBRARIES} blobnet::blobnet tinyxml2::tinyxml2 PhysFS::PhysFS SDL2::SDL2main SDL2::SDL2 Boost::boost)
+set(BLOBBY_COMMON_LIBS ${LUA_LIBRARIES} blobnet::blobnet ${TINYXML2_LIBRARIES} PhysFS::PhysFS SDL2::SDL2main SDL2::SDL2 Boost::boost)
 
 # other additional dependencies
 if (NOT WIN32)
@@ -131,13 +133,13 @@
 	endif ()
 endif ()
 
-target_include_directories(blobby PRIVATE ${LUA_INCLUDE_DIR})
+target_include_directories(blobby PRIVATE ${LUA_INCLUDE_DIR} ${TINYXML2_INCLUDE_DIRS})
 target_link_libraries(blobby ${BLOBBY_COMMON_LIBS} ${OPENGL_LIBRARIES})
 
 
 if (UNIX AND (NOT ANDROID) OR WIN32)
 	add_executable(blobby-server ${blobby-server_SRC})
-	target_include_directories(blobby-server PRIVATE ${LUA_INCLUDE_DIR})
+	target_include_directories(blobby-server PRIVATE ${LUA_INCLUDE_DIR} ${TINYXML2_INCLUDE_DIRS})
 	target_link_libraries(blobby-server ${BLOBBY_COMMON_LIBS})
 endif ()
 if (UNIX AND (NOT ANDROID))
