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.

118 lines
4.2 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. --- a/CMakeLists.txt
  34. +++ b/CMakeLists.txt
  35. @@ -694,6 +694,7 @@ endif(WITH_LIBUSB)
  36. #
  37. if(USE_STATIC_OPENZWAVE)
  38. find_library(OpenZWave NAMES libopenzwave.a HINTS "../open-zwave-read-only" "../open-zwave-read-only/cpp/build")
  39. + find_path(OPENZWAVE_INCLUDE_DIRS NAMES OZWException.h HINTS "../open-zwave-read-only/cpp/src")
  40. set(OPENZWAVE_LIB ${OpenZWave})
  41. else()
  42. pkg_check_modules(OPENZWAVE libopenzwave)
  43. @@ -707,16 +708,12 @@ IF(OpenZWave)
  44. message(STATUS "OpenZWave library found at: ${OpenZWave}")
  45. target_link_libraries(domoticz ${OpenZWave})
  46. - find_path(OPENZWAVE_INCLUDE_DIRS NAMES openzwave/Manager.h)
  47. + find_path(OPENZWAVE_INCLUDE_DIRS NAMES OZWException.h)
  48. if (OPENZWAVE_INCLUDE_DIRS)
  49. - IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
  50. - include_directories(${OPENZWAVE_INCLUDE_DIRS})
  51. - ELSE()
  52. - include_directories(${OPENZWAVE_INCLUDE_DIRS}/openzwave)
  53. - ENDIF()
  54. + include_directories(${OPENZWAVE_INCLUDE_DIRS})
  55. message(STATUS "OpenZWave includes found at: ${OPENZWAVE_INCLUDE_DIRS}")
  56. else()
  57. - message(FATAL_ERROR "OpenZWave includes not found. Did you not issue 'sudo make install' after building OpenZWave?")
  58. + message(FATAL_ERROR "OpenZWave includes not found.")
  59. endif (OPENZWAVE_INCLUDE_DIRS)
  60. add_definitions(-DWITH_OPENZWAVE)
  61. ELSE()
  62. --- a/hardware/OpenZWave.cpp
  63. +++ b/hardware/OpenZWave.cpp
  64. @@ -22,10 +22,10 @@
  65. #include "../main/localtime_r.h"
  66. //OpenZWave includes
  67. -#include <openzwave/Options.h>
  68. -#include <openzwave/Manager.h>
  69. -#include <openzwave/platform/Log.h>
  70. -#include <openzwave/ValueIDIndexesDefines.h>
  71. +#include <Options.h>
  72. +#include <Manager.h>
  73. +#include <platform/Log.h>
  74. +#include <ValueIDIndexesDefines.h>
  75. #include "ZWaveCommands.h"
  76. --- a/hardware/openzwave/control_panel/ozwcp.cpp
  77. +++ b/hardware/openzwave/control_panel/ozwcp.cpp
  78. @@ -39,11 +39,11 @@
  79. #include <stdlib.h>
  80. #include <time.h>
  81. #include <string.h>
  82. -#include <openzwave/Options.h>
  83. -#include <openzwave/Manager.h>
  84. -#include <openzwave/Node.h>
  85. -#include <openzwave/Group.h>
  86. -#include <openzwave/Notification.h>
  87. +#include <Options.h>
  88. +#include <Manager.h>
  89. +#include <Node.h>
  90. +#include <Group.h>
  91. +#include <Notification.h>
  92. #include "../../../main/Logger.h"
  93. #include <sys/stat.h>
  94. --- a/hardware/openzwave/control_panel/ozwcp.h
  95. +++ b/hardware/openzwave/control_panel/ozwcp.h
  96. @@ -38,8 +38,8 @@
  97. #include <list>
  98. #include <algorithm>
  99. -#include <openzwave/Driver.h>
  100. -#include <openzwave/Notification.h>
  101. +#include <Driver.h>
  102. +#include <Notification.h>
  103. #define MAX_NODES 255