summarylogtreecommitdiffstats
path: root/0001-Add_finder_for_uthash.patch
blob: c27fe27a92b959c6a733b56058ef2dfb79c4c05b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
From ba026f32aa87c6deefdfabf1bcc48b205622c708 Mon Sep 17 00:00:00 2001
From: tytan652 <tytan652@tytanium.xyz>
Date: Mon, 24 Jul 2023 10:50:14 +0200
Subject: [PATCH] cmake: Add finder for uthash

---
 cmake/Modules/FindUthash.cmake | 84 ++++++++++++++++++++++++++++++++++
 cmake/finders/FindUthash.cmake | 84 ++++++++++++++++++++++++++++++++++
 2 files changed, 168 insertions(+)
 create mode 100644 cmake/Modules/FindUthash.cmake
 create mode 100644 cmake/finders/FindUthash.cmake

diff --git a/cmake/Modules/FindUthash.cmake b/cmake/Modules/FindUthash.cmake
new file mode 100644
index 0000000000000..fde6bd5d12321
--- /dev/null
+++ b/cmake/Modules/FindUthash.cmake
@@ -0,0 +1,84 @@
+#[=======================================================================[.rst
+FindUthash
+----------
+
+FindModule for uthash and the associated library
+
+Imported Targets
+^^^^^^^^^^^^^^^^
+
+.. versionadded:: 3.0
+
+This module defines the :prop_tgt:`IMPORTED` target ``Uthash::Uthash``.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module sets the following variables:
+
+``Uthash_FOUND``
+  True, if the library was found.
+``Uthash_VERSION``
+  Detected version of found uthash library.
+
+Cache variables
+^^^^^^^^^^^^^^^
+
+The following cache variables may also be set:
+
+``Uthash_INCLUDE_DIR``
+  Directory containing ``uthash.h``.
+
+#]=======================================================================]
+
+# cmake-format: off
+# cmake-lint: disable=C0103
+# cmake-lint: disable=C0301
+# cmake-format: on
+
+include(FindPackageHandleStandardArgs)
+
+find_path(
+  Uthash_INCLUDE_DIR
+  NAMES uthash.h
+  PATHS /usr/include /usr/local/include
+  DOC "uthash include directory")
+
+if(EXISTS "${Uthash_INCLUDE_DIR}/uthash.h")
+  file(STRINGS "${Uthash_INCLUDE_DIR}/uthash.h" _version_string
+       REGEX "#define[ \t]+UTHASH_VERSION[ \t]+[0-9]+\\.[0-9]+\\.[0-9]+")
+
+  string(REGEX REPLACE "#define[ \t]+UTHASH_VERSION[ \t]+([0-9]+\\.[0-9]+\\.[0-9]+)" "\\1" Uthash_VERSION
+                       "${_version_string}")
+else()
+  if(NOT Uthash_FIND_QUIETLY)
+    message(AUTHOR_WARNING "Failed to find uthash version.")
+  endif()
+  set(Uthash_VERSION 0.0.0)
+endif()
+
+if(CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin|Windows")
+  set(Uthash_ERROR_REASON "Ensure that obs-deps is provided as part of CMAKE_PREFIX_PATH.")
+elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|FreeBSD")
+  set(Uthash_ERROR_REASON "Ensure uthash library is available in local include paths.")
+endif()
+
+find_package_handle_standard_args(
+  Uthash
+  REQUIRED_VARS Uthash_INCLUDE_DIR
+  VERSION_VAR Uthash_VERSION REASON_FAILURE_MESSAGE "${Uthash_ERROR_REASON}")
+mark_as_advanced(Uthash_INCLUDE_DIR)
+unset(Uthash_ERROR_REASON)
+
+if(Uthash_FOUND)
+  if(NOT TARGET Uthash::Uthash)
+    add_library(Uthash::Uthash INTERFACE IMPORTED)
+    set_target_properties(Uthash::Uthash PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Uthash_INCLUDE_DIR}")
+  endif()
+endif()
+
+include(FeatureSummary)
+set_package_properties(
+  Uthash PROPERTIES
+  URL "https://troydhanson.github.io/uthash"
+  DESCRIPTION "A hash table for C structures")
diff --git a/cmake/finders/FindUthash.cmake b/cmake/finders/FindUthash.cmake
new file mode 100644
index 0000000000000..fde6bd5d12321
--- /dev/null
+++ b/cmake/finders/FindUthash.cmake
@@ -0,0 +1,84 @@
+#[=======================================================================[.rst
+FindUthash
+----------
+
+FindModule for uthash and the associated library
+
+Imported Targets
+^^^^^^^^^^^^^^^^
+
+.. versionadded:: 3.0
+
+This module defines the :prop_tgt:`IMPORTED` target ``Uthash::Uthash``.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module sets the following variables:
+
+``Uthash_FOUND``
+  True, if the library was found.
+``Uthash_VERSION``
+  Detected version of found uthash library.
+
+Cache variables
+^^^^^^^^^^^^^^^
+
+The following cache variables may also be set:
+
+``Uthash_INCLUDE_DIR``
+  Directory containing ``uthash.h``.
+
+#]=======================================================================]
+
+# cmake-format: off
+# cmake-lint: disable=C0103
+# cmake-lint: disable=C0301
+# cmake-format: on
+
+include(FindPackageHandleStandardArgs)
+
+find_path(
+  Uthash_INCLUDE_DIR
+  NAMES uthash.h
+  PATHS /usr/include /usr/local/include
+  DOC "uthash include directory")
+
+if(EXISTS "${Uthash_INCLUDE_DIR}/uthash.h")
+  file(STRINGS "${Uthash_INCLUDE_DIR}/uthash.h" _version_string
+       REGEX "#define[ \t]+UTHASH_VERSION[ \t]+[0-9]+\\.[0-9]+\\.[0-9]+")
+
+  string(REGEX REPLACE "#define[ \t]+UTHASH_VERSION[ \t]+([0-9]+\\.[0-9]+\\.[0-9]+)" "\\1" Uthash_VERSION
+                       "${_version_string}")
+else()
+  if(NOT Uthash_FIND_QUIETLY)
+    message(AUTHOR_WARNING "Failed to find uthash version.")
+  endif()
+  set(Uthash_VERSION 0.0.0)
+endif()
+
+if(CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin|Windows")
+  set(Uthash_ERROR_REASON "Ensure that obs-deps is provided as part of CMAKE_PREFIX_PATH.")
+elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|FreeBSD")
+  set(Uthash_ERROR_REASON "Ensure uthash library is available in local include paths.")
+endif()
+
+find_package_handle_standard_args(
+  Uthash
+  REQUIRED_VARS Uthash_INCLUDE_DIR
+  VERSION_VAR Uthash_VERSION REASON_FAILURE_MESSAGE "${Uthash_ERROR_REASON}")
+mark_as_advanced(Uthash_INCLUDE_DIR)
+unset(Uthash_ERROR_REASON)
+
+if(Uthash_FOUND)
+  if(NOT TARGET Uthash::Uthash)
+    add_library(Uthash::Uthash INTERFACE IMPORTED)
+    set_target_properties(Uthash::Uthash PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Uthash_INCLUDE_DIR}")
+  endif()
+endif()
+
+include(FeatureSummary)
+set_package_properties(
+  Uthash PROPERTIES
+  URL "https://troydhanson.github.io/uthash"
+  DESCRIPTION "A hash table for C structures")