You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
4.6 KiB

  1. From 632695fe3ee704c1c1c539d79172ac0f9f9ce77b Mon Sep 17 00:00:00 2001
  2. From: David Woodhouse <dwmw2@infradead.org>
  3. Date: Thu, 4 Jun 2020 12:41:27 +0100
  4. Subject: [PATCH] Fix up OpenZWave include path handling
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. The path specified by the pkg-config file will be, for example,
  9. /usr/include/openzwave.
  10. That directory needs to be on the compiler's include path, because
  11. OpenZWave's own include files assume they can include each other
  12. simply as (e.g.) "ValueIDIndexes.h"; not "openzwave/ValueIDIndexes.h"
  13. Our own files do include <openzwave/Foo.h> though, which means that
  14. the *parent* directory needs to be on the compilers's include path
  15. too. We generally get lucky because /usr/include is automatically
  16. included, so we find /usr/include/openzwave/Foo.h anyway.
  17. Fix our C files to rely on the correct include path discovered from
  18. pkg-config, and to include OpenZWave headers by name without the
  19. erroneous openzwave/ prefix.
  20. That means we can fix the ../open-zwave-read-only static build to use
  21. the header files directly from there just like it does the static
  22. library .a file, without requiring the 'sudo make install' step — and
  23. without suffering a mismatch of static openzwave build vs. headers of
  24. a different version that were installed on the system, which could
  25. previously happen.
  26. Tested with both static and dynamic builds of OpenZWave.
  27. ---
  28. CMakeLists.txt | 11 ++++-------
  29. hardware/OpenZWave.cpp | 8 ++++----
  30. hardware/openzwave/control_panel/ozwcp.cpp | 10 +++++-----
  31. hardware/openzwave/control_panel/ozwcp.h | 4 ++--
  32. 4 files changed, 15 insertions(+), 18 deletions(-)
  33. diff --git a/CMakeLists.txt b/CMakeLists.txt
  34. index fa5b3099d..1f4b6fb57 100644
  35. --- a/CMakeLists.txt
  36. +++ b/CMakeLists.txt
  37. @@ -694,6 +694,7 @@ endif(WITH_LIBUSB)
  38. #
  39. if(USE_STATIC_OPENZWAVE)
  40. find_library(OpenZWave NAMES libopenzwave.a HINTS "../open-zwave-read-only" "../open-zwave-read-only/cpp/build")
  41. + find_path(OPENZWAVE_INCLUDE_DIRS NAMES OZWException.h HINTS "../open-zwave-read-only/cpp/src")
  42. set(OPENZWAVE_LIB ${OpenZWave})
  43. else()
  44. pkg_check_modules(OPENZWAVE libopenzwave)
  45. @@ -707,16 +708,12 @@ IF(OpenZWave)
  46. message(STATUS "OpenZWave library found at: ${OpenZWave}")
  47. target_link_libraries(domoticz ${OpenZWave})
  48. - find_path(OPENZWAVE_INCLUDE_DIRS NAMES openzwave/Manager.h)
  49. + find_path(OPENZWAVE_INCLUDE_DIRS NAMES OZWException.h)
  50. if (OPENZWAVE_INCLUDE_DIRS)
  51. - IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
  52. - include_directories(${OPENZWAVE_INCLUDE_DIRS})
  53. - ELSE()
  54. - include_directories(${OPENZWAVE_INCLUDE_DIRS}/openzwave)
  55. - ENDIF()
  56. + include_directories(${OPENZWAVE_INCLUDE_DIRS})
  57. message(STATUS "OpenZWave includes found at: ${OPENZWAVE_INCLUDE_DIRS}")
  58. else()
  59. - message(FATAL_ERROR "OpenZWave includes not found. Did you not issue 'sudo make install' after building OpenZWave?")
  60. + message(FATAL_ERROR "OpenZWave includes not found.")
  61. endif (OPENZWAVE_INCLUDE_DIRS)
  62. add_definitions(-DWITH_OPENZWAVE)
  63. ELSE()
  64. diff --git a/hardware/OpenZWave.cpp b/hardware/OpenZWave.cpp
  65. index 272e3d0a7..a226a8924 100644
  66. --- a/hardware/OpenZWave.cpp
  67. +++ b/hardware/OpenZWave.cpp
  68. @@ -22,10 +22,10 @@
  69. #include "../main/localtime_r.h"
  70. //OpenZWave includes
  71. -#include <openzwave/Options.h>
  72. -#include <openzwave/Manager.h>
  73. -#include <openzwave/platform/Log.h>
  74. -#include <openzwave/ValueIDIndexesDefines.h>
  75. +#include <Options.h>
  76. +#include <Manager.h>
  77. +#include <platform/Log.h>
  78. +#include <ValueIDIndexesDefines.h>
  79. #include "ZWaveCommands.h"
  80. diff --git a/hardware/openzwave/control_panel/ozwcp.cpp b/hardware/openzwave/control_panel/ozwcp.cpp
  81. index 0b21a9cf3..5e401b2f1 100644
  82. --- a/hardware/openzwave/control_panel/ozwcp.cpp
  83. +++ b/hardware/openzwave/control_panel/ozwcp.cpp
  84. @@ -39,11 +39,11 @@
  85. #include <stdlib.h>
  86. #include <time.h>
  87. #include <string.h>
  88. -#include <openzwave/Options.h>
  89. -#include <openzwave/Manager.h>
  90. -#include <openzwave/Node.h>
  91. -#include <openzwave/Group.h>
  92. -#include <openzwave/Notification.h>
  93. +#include <Options.h>
  94. +#include <Manager.h>
  95. +#include <Node.h>
  96. +#include <Group.h>
  97. +#include <Notification.h>
  98. #include "../../../main/Logger.h"
  99. #include <sys/stat.h>
  100. diff --git a/hardware/openzwave/control_panel/ozwcp.h b/hardware/openzwave/control_panel/ozwcp.h
  101. index ebfef1791..96d14b3bf 100644
  102. --- a/hardware/openzwave/control_panel/ozwcp.h
  103. +++ b/hardware/openzwave/control_panel/ozwcp.h
  104. @@ -38,8 +38,8 @@
  105. #include <list>
  106. #include <algorithm>
  107. -#include <openzwave/Driver.h>
  108. -#include <openzwave/Notification.h>
  109. +#include <Driver.h>
  110. +#include <Notification.h>
  111. #define MAX_NODES 255
  112. --
  113. 2.26.2