70a7e43
From 694241f7905967bf69af3a31265180c00b73e28c Mon Sep 17 00:00:00 2001
415d1f4
From: Michael Cronenworth <mike@cchtml.com>
70a7e43
Date: Fri, 11 Aug 2017 10:08:27 -0500
415d1f4
Subject: [PATCH] build: Detect and allow external tinyxpath library usage
415d1f4
415d1f4
Signed-off-by: Michael Cronenworth <mike@cchtml.com>
415d1f4
---
70a7e43
 CMakeLists.txt                             | 57 +++++++++++++++++++++---------
24bdab9
 removed from Fedora patch hardware/AnnaThermostat.cpp                |  3 +-
24bdab9
 removed from Fedora patch hardware/RAVEn.cpp                         |  3 +-
24bdab9
 removed from Fedora patch hardware/openzwave/control_panel/ozwcp.cpp |  3 +-
24bdab9
 removed from Fedora patch hardware/plugins/PluginManager.cpp         |  3 +-
24bdab9
 removed from Fedora patch hardware/plugins/Plugins.cpp               |  3 +-
24bdab9
 removed from Fedora patch main/LuaCommon.cpp                         |  7 +++-
24bdab9
 removed from Fedora patch main/LuaHandler.cpp                        |  3 +-
70a7e43
 removed from Fedora patch msbuild/domoticz.vcxproj                   |  6 ++--
70a7e43
 9 files changed, 62 insertions(+), 26 deletions(-)
415d1f4
415d1f4
diff --git a/CMakeLists.txt b/CMakeLists.txt
70a7e43
index bc231d8f6..334f203a6 100644
415d1f4
--- a/CMakeLists.txt
415d1f4
+++ b/CMakeLists.txt
8f1bf90
@@ -365,22 +365,6 @@
1a11e5e
 webserver/server.cpp
1a11e5e
 webserver/Websockets.cpp
1a11e5e
 webserver/WebsocketHandler.cpp
415d1f4
-tinyxpath/action_store.cpp
415d1f4
-tinyxpath/htmlutil.cpp
415d1f4
-tinyxpath/lex_util.cpp
415d1f4
-tinyxpath/node_set.cpp
415d1f4
-tinyxpath/tinystr.cpp
415d1f4
-tinyxpath/tinyxml.cpp
415d1f4
-tinyxpath/tinyxmlerror.cpp
415d1f4
-tinyxpath/tinyxmlparser.cpp
415d1f4
-tinyxpath/tokenlist.cpp
415d1f4
-tinyxpath/xml_util.cpp
415d1f4
-tinyxpath/xpath_expression.cpp
415d1f4
-tinyxpath/xpath_processor.cpp
415d1f4
-tinyxpath/xpath_stream.cpp
415d1f4
-tinyxpath/xpath_stack.cpp
415d1f4
-tinyxpath/xpath_static.cpp
415d1f4
-tinyxpath/xpath_syntax.cpp
415d1f4
 )
415d1f4
 
8f1bf90
 add_executable(domoticz ${domoticz_SRCS})
8f1bf90
@@ -682,6 +666,47 @@
24bdab9
   ENDIF(LIBUSB_FOUND)
24bdab9
 endif(WITH_LIBUSB)
415d1f4
 
70a7e43
+option(USE_BUILTIN_TINYXPATH "Use builtin tinyxpath library" YES)
70a7e43
+IF(USE_BUILTIN_TINYXPATH)
70a7e43
+  include_directories(tinyxpath)
415d1f4
+  target_sources(
415d1f4
+  domoticz
415d1f4
+  PUBLIC
415d1f4
+  tinyxpath/action_store.cpp
415d1f4
+  tinyxpath/htmlutil.cpp
415d1f4
+  tinyxpath/lex_util.cpp
415d1f4
+  tinyxpath/node_set.cpp
415d1f4
+  tinyxpath/tinystr.cpp
415d1f4
+  tinyxpath/tinyxml.cpp
415d1f4
+  tinyxpath/tinyxmlerror.cpp
415d1f4
+  tinyxpath/tinyxmlparser.cpp
415d1f4
+  tinyxpath/tokenlist.cpp
415d1f4
+  tinyxpath/xml_util.cpp
415d1f4
+  tinyxpath/xpath_expression.cpp
415d1f4
+  tinyxpath/xpath_processor.cpp
415d1f4
+  tinyxpath/xpath_stream.cpp
415d1f4
+  tinyxpath/xpath_stack.cpp
415d1f4
+  tinyxpath/xpath_static.cpp
415d1f4
+  tinyxpath/xpath_syntax.cpp
415d1f4
+  )
70a7e43
+else()
70a7e43
+  pkg_check_modules(TinyXML QUIET tinyxml)
70a7e43
+  IF(TinyXML_FOUND)
70a7e43
+    MESSAGE(STATUS "TinyXML found at: ${TinyXML_LIBRARIES}")
70a7e43
+    IF(EXISTS "/usr/include/tinyxpath/xpath_processor.h")
70a7e43
+      MESSAGE(STATUS "TinyXPath found")
70a7e43
+      target_link_libraries(domoticz ${TinyXML_LIBRARIES})
70a7e43
+      target_link_libraries(domoticz tinyxpath)
70a7e43
+      include_directories(/usr/include/tinyxpath)
70a7e43
+      add_definitions(-DWITH_EXTERNAL_TINYXPATH)
70a7e43
+    else()
70a7e43
+      MESSAGE(FATAL_ERROR "TinyXPath not found but USE_BUILTIN_TINYXPATH=NO")
70a7e43
+    ENDIF()
70a7e43
+  else()
70a7e43
+    MESSAGE(FATAL_ERROR "TinyXML not found but USE_BUILTIN_TINYXPATH=NO")
70a7e43
+  ENDIF(TinyXML_FOUND)
70a7e43
+ENDIF(USE_BUILTIN_TINYXPATH)
415d1f4
+
24bdab9
 ## support lua popen on Linux platforms
24bdab9
 #IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
24bdab9
 # SET(OperatingSystem "Linux")
1a11e5e
--- a/hardware/openzwave/control_panel/ozwcp.cpp	2020-03-22 09:16:16.000000000 -0500
1a11e5e
+++ b/hardware/openzwave/control_panel/ozwcp.cpp	2020-03-24 10:53:04.968630391 -0500
1a11e5e
@@ -49,7 +49,7 @@
1a11e5e
 #include <sys/stat.h>
1a11e5e
 #include <fstream>
1a11e5e
 #include <iostream>
1a11e5e
-#include "../../../tinyxpath/tinyxml.h"
1a11e5e
+#include <tinyxml.h>
1a11e5e
 
1a11e5e
 //#include "microhttpd.h"
1a11e5e
 #include "ozwcp.h"
1a11e5e
--- a/hardware/plugins/PluginManager.cpp	2020-03-22 09:16:16.000000000 -0500
1a11e5e
+++ b/hardware/plugins/PluginManager.cpp	2020-03-24 13:53:05.305852598 -0500
1a11e5e
@@ -21,11 +21,12 @@
1a11e5e
 #include "../../main/Logger.h"
1a11e5e
 #include "../../main/SQLHelper.h"
1a11e5e
 #include "../../main/WebServer.h"
1a11e5e
-#include "../../tinyxpath/tinyxml.h"
1a11e5e
 #ifdef WIN32
1a11e5e
+#       include "../../tinyxpath/tinyxml.h"
1a11e5e
 #	include <direct.h>
1a11e5e
 #else
1a11e5e
 #	include <sys/stat.h>
1a11e5e
+#       include <tinyxml.h>
1a11e5e
 #endif
1a11e5e
 
1a11e5e
 #include "DelayedLink.h"
1a11e5e
--- a/hardware/plugins/Plugins.cpp	2020-03-22 09:16:16.000000000 -0500
1a11e5e
+++ b/hardware/plugins/Plugins.cpp	2020-03-24 13:45:46.056965796 -0500
8f1bf90
@@ -16,10 +16,11 @@
8f1bf90
 #include "../../main/SQLHelper.h"
8f1bf90
 #include "../../main/mainworker.h"
8f1bf90
 #include "../../main/localtime_r.h"
8f1bf90
-#include "../../tinyxpath/tinyxml.h"
1a11e5e
 
1a11e5e
 #include "../../notifications/NotificationHelper.h"
1a11e5e
 
1a11e5e
+#include <tinyxml.h>
1a11e5e
+
1a11e5e
 #define ADD_STRING_TO_DICT(pDict, key, value) \
1a11e5e
 		{	\
1a11e5e
 			PyObject*	pObj = Py_BuildValue("s", value.c_str());	\
1a11e5e
--- a/hardware/AnnaThermostat.cpp	2020-03-22 09:16:16.000000000 -0500
1a11e5e
+++ b/hardware/AnnaThermostat.cpp	2020-03-24 10:41:00.530030798 -0500
1a11e5e
@@ -9,7 +9,7 @@
1a11e5e
 #include "../httpclient/HTTPClient.h"
1a11e5e
 #include "../main/mainworker.h"
1a11e5e
 
1a11e5e
-#include "../tinyxpath/tinyxml.h"
1a11e5e
+#include <tinyxml.h>
1a11e5e
 
1a11e5e
 #define round(a) ( int ) ( a + .5 )
1a11e5e
 
1a11e5e
--- a/hardware/EcoDevices.cpp	2020-03-22 09:16:16.000000000 -0500
1a11e5e
+++ b/hardware/EcoDevices.cpp	2020-03-24 10:47:20.095926641 -0500
1a11e5e
@@ -33,11 +33,11 @@
1a11e5e
 #include "hardwaretypes.h"
1a11e5e
 #include "../main/localtime_r.h"
1a11e5e
 #include "../httpclient/HTTPClient.h"
1a11e5e
-#include "../tinyxpath/tinyxml.h"
1a11e5e
-#include "../tinyxpath/xpath_static.h"
1a11e5e
 #include "../webserver/Base64.h"
1a11e5e
 #include "../main/json_helper.h"
1a11e5e
 #include <sstream>
1a11e5e
+#include <tinyxml.h>
1a11e5e
+#include <xpath_static.h>
1a11e5e
 
1a11e5e
 #ifdef _DEBUG
1a11e5e
 #define DEBUG_EcoDevices
24bdab9
--- a/hardware/OnkyoAVTCP.cpp	2018-06-23 09:18:06.000000000 -0500
24bdab9
+++ b/hardware/OnkyoAVTCP.cpp	2018-07-08 14:21:06.884163094 -0500
af0f3ae
@@ -3,15 +3,15 @@
24bdab9
 #include "../main/Logger.h"
24bdab9
 #include "../main/Helper.h"
415d1f4
 #include "../main/SQLHelper.h"
24bdab9
-#include <iostream>
415d1f4
 #include "../main/localtime_r.h"
415d1f4
 #include "../main/mainworker.h"
24bdab9
 #include "../hardware/hardwaretypes.h"
8f1bf90
-#include <json/json.h>
415d1f4
-#include "../tinyxpath/tinyxml.h"
24bdab9
 #include "../main/WebServer.h"
70a7e43
 
24bdab9
+#include <iostream>
24bdab9
 #include <sstream>
8f1bf90
+#include <json/json.h>
70a7e43
+#include <tinyxml.h>
415d1f4
 
24bdab9
 #define RETRY_DELAY 30
415d1f4
 
1a11e5e
--- a/hardware/RAVEn.cpp	2020-03-22 09:16:16.000000000 -0500
1a11e5e
+++ b/hardware/RAVEn.cpp	2020-03-24 12:55:59.616310732 -0500
1a11e5e
@@ -5,8 +5,8 @@
1a11e5e
 #include "../main/Logger.h"
1a11e5e
 #include "../main/mainworker.h"
1a11e5e
 #include "../main/RFXtrx.h"
1a11e5e
-#include "../tinyxpath/tinyxml.h"
1a11e5e
 #include "hardwaretypes.h"
1a11e5e
+#include <tinyxml.h>
1a11e5e
 
1a11e5e
 //Rainforest RAVEn USB ZigBee Smart Meter Adapter
1a11e5e
 //https://rainforestautomation.com/rfa-z106-raven/