Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

ManageString.cmake 16 KB

You have to be logged in to leave a comment. Sign In
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
  1. #
  2. # $Id$
  3. #
  4. # - Collection of String utility macros.
  5. # Defines the following macros:
  6. # STRING_ESCAPE(var str [NOESCAPE_SEMICOLON] [ESCAPE_VARIABLE])
  7. # - Encode characters that would be expanded '\', ';', '$', '#'
  8. # * Parameters:
  9. # + var: A variable that stores the result.
  10. # + str: The NAME of a variable that holds the string.
  11. # + NOESCAPE_SEMICOLON: (Optional) Do not escape semicolons.
  12. # + ESCAPE_VARIABLE: (Optional) Also escape '$'
  13. #
  14. # STRING_UNESCAPE(var str [NOESCAPE_SEMICOLON] [ESCAPE_VARIABLE])
  15. # - Decode '\', ';', '$', '#', the reverse of STRING_ESCAPE
  16. # * Parameters:
  17. # + var: A variable that stores the result.
  18. # + str: The encoded string
  19. # + NOESCAPE_SEMICOLON: (Optional) Do not decode semicolons.
  20. # + ESCAPE_VARIABLE: (Optional) Also decode '$'
  21. #
  22. # STRING_UNQUOTE(var str)
  23. # - Remove double quote marks and quote marks around a string.
  24. # * Parameters:
  25. # + var: A variable that stores the result.
  26. # + str: The NAME of a variable that holds the string.
  27. #
  28. # STRING_JOIN(var delimiter str_list [str...])
  29. # - Concatenate strings, with delimiter inserted between strings.
  30. # * Parameters:
  31. # + var: A variable that stores the result.
  32. # + str_list: A list of string.
  33. # + str: (Optional) more string to be join.
  34. #
  35. # STRING_SPLIT(var delimiter str [NOESCAPE_SEMICOLON] [ESCAPE_VARIABLE] [NOENCODE])
  36. # - Split a string into a list using a delimiter, which can be in 1 or more
  37. # characters long.
  38. # * Parameters:
  39. # + var: A variable that stores the result.
  40. # + delimiter: The NAME of a variable that holds the delimiter.
  41. # + str: The NAME of a variable that holds the string to split.
  42. # + NOESCAPE_SEMICOLON: (Optional) Do not escape semicolons.
  43. # + NOENCODE: (Optional) Do not encode/decode string
  44. #
  45. # FILE2LIST (var filename [filename...])
  46. # - Read a file to list, escape '#', '\' and ';'
  47. # * Parameters:
  48. # + var: A variable that stores the list.
  49. # + filename: Files to read
  50. #
  51. # GREP (pattern var filename [filename...] [LITERALLY] [INVERT])
  52. # - Read a file to list, escape '#', '\' and ';'
  53. # * Parameters:
  54. # + pattern: Regex to match
  55. # + var: A variable that stores the matching lines.
  56. # + filename: Files to read
  57. # + LITERALLY: (Optional) Match the pattern string literally
  58. # + INVERT: (Optional) Invert match
  59. #
  60. # LIST_REGEX_REPLACE (<regular_expression> <replace_expression>
  61. # <output list> <list> [<list>...] [MATCHES_ONLY] [STRIP])
  62. # - Do REGEX REPLACE for each lelement of list individually.
  63. # * Parameters:
  64. # + MATCHES_ONLY: (Optional) Return only matched elements in output list
  65. # + STRIP: (Optional) Strip whitespace of each element in output list
  66. #
  67. # LIST_REGEX_GET (<regular_expression> <output list>
  68. # <list> [<list>...] [INVERT])
  69. # - Return list with matched elements.
  70. # * Parameters:
  71. # + INVERT: (Optional) invert the selection
  72. #
  73. # STRING_PAD (string length [RIGHT] [PADDING])
  74. # - Pad a string with spaces to the given length. String will be left
  75. # aligned.
  76. # * Parameters:
  77. # + RIGHT: (Optional) right-align the string
  78. # + PADDING: (Optional) apply padding at the location by the marker
  79. # string PADDING
  80. #
  81. # Copyright (c) 1991-2015 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
  82. # See LICENSE.TXT file for copying and redistribution conditions.
  83. #
  84. # This program is free software; you can redistribute it and/or modify
  85. # it under the terms of the GNU Lesser General Public License as published by
  86. # the Free Software Foundation; version 3 or any later version.
  87. #
  88. # This program is distributed in the hope that it will be useful,
  89. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  90. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  91. # GNU Lesser General Public License for more details.
  92. #
  93. # Contact info: gmt.soest.hawaii.edu
  94. #-------------------------------------------------------------------------------
  95. if(NOT DEFINED _MANAGE_STRING_CMAKE_)
  96. set(_MANAGE_STRING_CMAKE_ "DEFINED")
  97. cmake_policy(SET CMP0010 NEW)
  98. cmake_policy(SET CMP0011 NEW)
  99. # STRING_ESCAPE(var str [NOESCAPE_SEMICOLON] [ESCAPE_VARIABLE])
  100. macro(STRING_ESCAPE var str)
  101. # ';' and '\' are tricky, need to be encoded.
  102. # '#' => '#H'
  103. # '$' => '#D'
  104. # ';' => '#S'
  105. # '\' => '#B'
  106. # '|' => '#P'
  107. set(_ESCAPE_VARIABLE)
  108. set(_NOESCAPE_SEMICOLON)
  109. string(REPLACE "#" "#H" _ret "${${str}}")
  110. string(REPLACE "\\" "#B" _ret "${_ret}")
  111. #string(REPLACE "|" "#P" _ret "${_ret}")
  112. foreach(_arg ${ARGN})
  113. if(${_arg} STREQUAL "NOESCAPE_SEMICOLON")
  114. set(_NOESCAPE_SEMICOLON "NOESCAPE_SEMICOLON")
  115. elseif(${_arg} STREQUAL "ESCAPE_VARIABLE")
  116. set(_ESCAPE_VARIABLE "ESCAPE_VARIABLE")
  117. string(REPLACE "$" "#D" _ret "${_ret}")
  118. endif(${_arg} STREQUAL "NOESCAPE_SEMICOLON")
  119. endforeach(_arg)
  120. if(NOT _NOESCAPE_SEMICOLON)
  121. string(REPLACE ";" "#S" _ret "${_ret}")
  122. endif(NOT _NOESCAPE_SEMICOLON)
  123. set(${var} "${_ret}")
  124. endmacro(STRING_ESCAPE var str)
  125. # STRING_UNESCAPE(var str [NOESCAPE_SEMICOLON] [ESCAPE_VARIABLE])
  126. macro(STRING_UNESCAPE var str)
  127. # '#B' => '\'
  128. # '#D' => '$'
  129. # '#H' => '#'
  130. # '#P' => '|'
  131. # '#S' => ';'
  132. set(_ESCAPE_VARIABLE)
  133. set(_NOESCAPE_SEMICOLON)
  134. set(_ret "${str}")
  135. foreach(_arg ${ARGN})
  136. if(${_arg} STREQUAL "NOESCAPE_SEMICOLON")
  137. set(_NOESCAPE_SEMICOLON "NOESCAPE_SEMICOLON")
  138. elseif(${_arg} STREQUAL "ESCAPE_VARIABLE")
  139. set(_ESCAPE_VARIABLE "ESCAPE_VARIABLE")
  140. string(REPLACE "#D" "$" _ret "${_ret}")
  141. endif(${_arg} STREQUAL "NOESCAPE_SEMICOLON")
  142. endforeach(_arg)
  143. if(_NOESCAPE_SEMICOLON)
  144. # ';' => '#s'
  145. string(REPLACE "#S" ";" _ret "${_ret}")
  146. else(_NOESCAPE_SEMICOLON)
  147. string(REPLACE "#S" "\\;" _ret "${_ret}")
  148. endif(_NOESCAPE_SEMICOLON)
  149. if(_ESCAPE_VARIABLE)
  150. # '#d' => '$'
  151. string(REPLACE "#D" "$" _ret "${_ret}")
  152. endif(_ESCAPE_VARIABLE)
  153. #string(REPLACE "#P" "|" _ret "${_ret}")
  154. string(REPLACE "#B" "\\" _ret "${_ret}")
  155. string(REPLACE "#H" "#" _ret "${_ret}")
  156. set(${var} "${_ret}")
  157. endmacro(STRING_UNESCAPE var str)
  158. # STRING_UNQUOTE(var str)
  159. macro(STRING_UNQUOTE var str)
  160. # escape special chars
  161. string_escape(_str ${str} NOESCAPE_SEMICOLON)
  162. if(_str MATCHES "^[ \t\r\n]+")
  163. string(REGEX REPLACE "^[ \t\r\n]+" "" _str "${_str}")
  164. endif(_str MATCHES "^[ \t\r\n]+")
  165. if(_str MATCHES "^\"")
  166. # double quote
  167. string(REGEX REPLACE "\"\(.*\)\"[ \t\r\n]*$" "\\1" _str "${_str}")
  168. elseif(_str MATCHES "^'")
  169. # single quote
  170. string(REGEX REPLACE "'\(.*\)'[ \t\r\n]*$" "\\1" _str "${_str}")
  171. else(_str MATCHES "^\"")
  172. set(_str)
  173. endif(_str MATCHES "^\"")
  174. # unencoding
  175. string_unescape(${var} "${_str}" NOESCAPE_SEMICOLON)
  176. endmacro(STRING_UNQUOTE _var _str)
  177. # STRING_JOIN(var delimiter str_list [str...])
  178. macro(STRING_JOIN var delimiter str_list)
  179. set(_ret)
  180. foreach(_str ${str_list})
  181. if(_ret)
  182. set(_ret "${_ret}${delimiter}${_str}")
  183. else(_ret)
  184. set(_ret "${_str}")
  185. endif(_ret)
  186. endforeach(_str ${str_list})
  187. foreach(_str ${ARGN})
  188. if(_ret)
  189. set(_ret "${_ret}${delimiter}${_str}")
  190. else(_ret)
  191. set(_ret "${_str}")
  192. endif(_ret)
  193. endforeach(_str ${str_list})
  194. set(${var} "${_ret}")
  195. endmacro(STRING_JOIN var delimiter str_list)
  196. # STRING_SPLIT(var delimiter str [NOESCAPE_SEMICOLON] [ESCAPE_VARIABLE] [NOENCODE])
  197. macro(STRING_SPLIT var delimiter str)
  198. set(_max_tokens)
  199. set(_NOESCAPE_SEMICOLON)
  200. set(_ESCAPE_VARIABLE)
  201. set(_NOENCODE)
  202. foreach(_arg ${ARGN})
  203. if(${_arg} STREQUAL "NOESCAPE_SEMICOLON")
  204. set(_NOESCAPE_SEMICOLON "NOESCAPE_SEMICOLON")
  205. elseif(${_arg} STREQUAL "ESCAPE_VARIABLE")
  206. set(_ESCAPE_VARIABLE "ESCAPE_VARIABLE")
  207. elseif(${_arg} STREQUAL "NOENCODE")
  208. set(_NOENCODE "NOENCODE")
  209. else(${_arg} STREQUAL "NOESCAPE_SEMICOLON")
  210. set(_max_tokens ${_arg})
  211. endif(${_arg} STREQUAL "NOESCAPE_SEMICOLON")
  212. endforeach(_arg)
  213. if(NOT _max_tokens)
  214. set(_max_tokens -1)
  215. endif(NOT _max_tokens)
  216. if(_NOENCODE)
  217. set(_str ${${str}})
  218. set(_delimiter ${${delimiter}})
  219. else(_NOENCODE)
  220. string_escape(_str ${str} ${_NOESCAPE_SEMICOLON} ${_ESCAPE_VARIABLE})
  221. string_escape(_delimiter ${delimiter} ${_NOESCAPE_SEMICOLON} ${_ESCAPE_VARIABLE})
  222. endif(_NOENCODE)
  223. set(_str_list)
  224. set(_token_count 0)
  225. string(LENGTH "${_delimiter}" _de_len)
  226. while(NOT _token_count EQUAL _max_tokens)
  227. math(EXPR _token_count ${_token_count}+1)
  228. if(_token_count EQUAL _max_tokens)
  229. # last token, no need splitting
  230. set(_str_list ${_str_list} "${_str}")
  231. else(_token_count EQUAL _max_tokens)
  232. # in case encoded characters are delimiters
  233. string(LENGTH "${_str}" _str_len)
  234. set(_index 0)
  235. set(_token)
  236. set(_str_remain)
  237. math(EXPR _str_end ${_str_len}-${_de_len}+1)
  238. set(_bound "k")
  239. while(_index LESS _str_end)
  240. string(SUBSTRING "${_str}" ${_index} ${_de_len} _str_cursor)
  241. if(_str_cursor STREQUAL _delimiter)
  242. # get the token
  243. string(SUBSTRING "${_str}" 0 ${_index} _token)
  244. # get the rest
  245. math(EXPR _rest_index ${_index}+${_de_len})
  246. math(EXPR _rest_len ${_str_len}-${_index}-${_de_len})
  247. string(SUBSTRING "${_str}" ${_rest_index} ${_rest_len} _str_remain)
  248. set(_index ${_str_end})
  249. else(_str_cursor STREQUAL _delimiter)
  250. math(EXPR _index ${_index}+1)
  251. endif(_str_cursor STREQUAL _delimiter)
  252. endwhile(_index LESS _str_end)
  253. if(_str_remain)
  254. list(APPEND _str_list "${_token}")
  255. set(_str "${_str_remain}")
  256. else(_str_remain)
  257. # meaning: end of string
  258. list(APPEND _str_list "${_str}")
  259. set(_max_tokens ${_token_count})
  260. endif(_str_remain)
  261. endif(_token_count EQUAL _max_tokens)
  262. endwhile(NOT _token_count EQUAL _max_tokens)
  263. if(_NOENCODE)
  264. set(${var} "${_str_list}")
  265. else(_NOENCODE)
  266. # unencoding
  267. string_unescape(${var} "${_str_list}" ${_NOESCAPE_SEMICOLON} ${_ESCAPE_VARIABLE})
  268. endif(_NOENCODE)
  269. endmacro(STRING_SPLIT var delimiter str)
  270. # FILE2LIST (var filename [filename...])
  271. macro (FILE2LIST _OUT _FILE)
  272. set(${_OUT}) # clear
  273. if (NOT FILESIZE_LIMIT)
  274. # default: read max 512KiB
  275. set(FILESIZE_LIMIT 524288)
  276. endif (NOT FILESIZE_LIMIT)
  277. foreach (_file ${_FILE} ${ARGN})
  278. file (READ ${_file} _file_content LIMIT ${FILESIZE_LIMIT})
  279. string_escape (_file_content _file_content) # ; -> #S and \ -> #B
  280. # strip trainling "\n" and convert to list
  281. string (REGEX REPLACE "\n+$" "" _file_content ${_file_content})
  282. string (REPLACE "\n" ";" _file_content ${_file_content})
  283. list(APPEND ${_OUT} "${_file_content}") # quotes -> also append empty lines
  284. endforeach (_file ${_FILE} ${ARGN})
  285. endmacro (FILE2LIST _OUT _FILE)
  286. # HEAD (string): print at most 80 chars of a string
  287. macro (HEAD _STR)
  288. string(LENGTH "${_STR}" _len)
  289. if (_len GREATER 80)
  290. set(_len 80)
  291. endif ()
  292. string(SUBSTRING "${_STR}" 0 ${_len} _prn)
  293. message("H> ${_prn}")
  294. endmacro (HEAD _STR)
  295. # GREP (pattern var filename [filename...] [LITERALLY] [INVERT])
  296. macro (GREP _PATTERN _OUT _FILE)
  297. set (_args ${ARGN})
  298. list (FIND _args "LITERALLY" _LITERALLY)
  299. if (_LITERALLY EQUAL -1)
  300. set(_LITERALLY)
  301. else(_LITERALLY EQUAL -1)
  302. set(_LITERALLY TRUE)
  303. list(REMOVE_ITEM _args "LITERALLY")
  304. endif(_LITERALLY EQUAL -1)
  305. list (FIND _args "INVERT" _INVERT)
  306. if (_INVERT EQUAL -1)
  307. set(_INVERT)
  308. else(_INVERT EQUAL -1)
  309. set(_INVERT TRUE)
  310. list(REMOVE_ITEM _args "INVERT")
  311. endif(_INVERT EQUAL -1)
  312. set(_matches)
  313. foreach (_file ${_FILE} ${_args})
  314. file2list (_list ${_file})
  315. foreach (_line IN LISTS _list)
  316. #message("i> ${_line}")
  317. set(_ismatching)
  318. if (_LITERALLY)
  319. string(FIND "${_line}" ${_PATTERN} _position)
  320. if (_position GREATER 0)
  321. set(_ismatching TRUE)
  322. endif ()
  323. else (_LITERALLY)
  324. string(REGEX MATCH ${_PATTERN} _ismatching "${_line}")
  325. endif (_LITERALLY)
  326. if ((_ismatching AND NOT _INVERT) OR (NOT _ismatching AND _INVERT))
  327. list (APPEND _matches "${_line}")
  328. endif ()
  329. #message("f> ${_file}")
  330. #head(${_line})
  331. endforeach (_line)
  332. endforeach (_file)
  333. set (${_OUT} "${_matches}")
  334. #message("p: ${_PATTERN}")
  335. endmacro(GREP _PATTERN _OUT _FILE)
  336. # LIST_REGEX_REPLACE (<regular_expression> <replace_expression> <output list> <list> [<list>...])
  337. # Note: have to double all escapes!
  338. macro (LIST_REGEX_REPLACE _REGEX _REP _OUT _LIST)
  339. #message("pattern: \"${_REGEX}\"")
  340. set (_args ${ARGN})
  341. list (FIND _args "MATCHES_ONLY" _MATCHES_ONLY)
  342. if (_MATCHES_ONLY EQUAL -1)
  343. set(_MATCHES_ONLY)
  344. else(_MATCHES_ONLY EQUAL -1)
  345. set(_MATCHES_ONLY TRUE)
  346. list(REMOVE_ITEM _args "MATCHES_ONLY")
  347. endif(_MATCHES_ONLY EQUAL -1)
  348. list (FIND _args "STRIP" _STRIP)
  349. if (_STRIP EQUAL -1)
  350. set(_STRIP)
  351. else(_STRIP EQUAL -1)
  352. set(_STRIP TRUE)
  353. list(REMOVE_ITEM _args "STRIP")
  354. endif(_STRIP EQUAL -1)
  355. set(${_OUT})
  356. foreach (_line ${_LIST} ${_args})
  357. string (REGEX REPLACE
  358. "${_REGEX}"
  359. "${_REP}" _replacement ${_line})
  360. if (_MATCHES_ONLY AND (_replacement STREQUAL _line))
  361. set(_replacement)
  362. endif ()
  363. if (_STRIP)
  364. string (STRIP "${_replacement}" _replacement)
  365. endif (_STRIP)
  366. list (APPEND ${_OUT} ${_replacement})
  367. #head("l: ${_line}")
  368. #head("r: ${_replacement}")
  369. endforeach (_line ${_LIST} ${_args})
  370. endmacro (LIST_REGEX_REPLACE _REGEX _REP _OUT _LIST)
  371. # LIST_REGEX_GET (<regular_expression> <output list> <list> [<list>...])
  372. # Note: have to double all escapes!
  373. macro (LIST_REGEX_GET _REGEX _OUT _LIST)
  374. #message("pattern: ${_REGEX}")
  375. set (_args ${ARGN})
  376. list (FIND _args "INVERT" _INVERT)
  377. if (_INVERT EQUAL -1)
  378. set(_INVERT)
  379. else(_INVERT EQUAL -1)
  380. set(_INVERT TRUE)
  381. list(REMOVE_ITEM _args "INVERT")
  382. endif(_INVERT EQUAL -1)
  383. set(${_OUT})
  384. foreach (_line ${_LIST} ${_args})
  385. set(_ismatching)
  386. string(REGEX MATCH ${_REGEX} _ismatching ${_line})
  387. if ((_ismatching AND NOT _INVERT) OR (NOT _ismatching AND _INVERT))
  388. list (APPEND ${_OUT} ${_line})
  389. endif ()
  390. endforeach (_line ${_LIST} ${_args})
  391. endmacro (LIST_REGEX_GET _REGEX _OUT _LIST)
  392. # STRING_PAD (string length): pad a string with spaces to the given length
  393. macro (STRING_PAD _STR _LEN)
  394. set (_args ${ARGN})
  395. list (FIND _args "RIGHT" _RIGHT)
  396. if (_RIGHT EQUAL -1)
  397. set (_RIGHT)
  398. else (_RIGHT EQUAL -1)
  399. set (_RIGHT TRUE)
  400. list (REMOVE_ITEM _args "RIGHT")
  401. endif (_RIGHT EQUAL -1)
  402. # get maker string, split string at marker,
  403. # and make woring copy
  404. list (LENGTH _args _padding)
  405. if (_padding)
  406. list(GET _args 0 _padding)
  407. string_split (_split _padding ${_STR}
  408. NOESCAPE_SEMICOLON
  409. NOENCODE)
  410. if (_RIGHT)
  411. # need to right align 2nd part
  412. list (GET _split 1 _copy)
  413. else (_RIGHT)
  414. # left align 1st part
  415. list (GET _split 0 _copy)
  416. endif (_RIGHT)
  417. else (_padding)
  418. # no marker: copy complete string
  419. set (_copy ${${_STR}})
  420. endif (_padding)
  421. string (LENGTH ${_copy} _orig_len)
  422. if (_orig_len LESS ${_LEN})
  423. set (_big_space " ")
  424. if (_RIGHT)
  425. # right align: prepend space
  426. math (EXPR _extra_len "${_LEN} - ${_orig_len}")
  427. string (SUBSTRING ${_big_space} 0 ${_extra_len} _extra_space)
  428. set (_copy "${_extra_space}${_copy}")
  429. else (_RIGHT)
  430. # left align: append space
  431. set (_big_str "${_copy}${_big_space}")
  432. string (SUBSTRING ${_big_str} 0 ${_LEN} _copy)
  433. endif (_RIGHT)
  434. endif (_orig_len LESS ${_LEN})
  435. # join split string
  436. if (_padding)
  437. if (_RIGHT)
  438. # join copy w 1st part
  439. list (GET _split 0 _part)
  440. set (_copy "${_part}${_copy}")
  441. else (_RIGHT)
  442. # join copy w 2nd part
  443. list (GET _split 1 _part)
  444. set (_copy "${_copy}${_part}")
  445. endif (_RIGHT)
  446. endif (_padding)
  447. # replace string with working copy
  448. set (${_STR} ${_copy})
  449. endmacro (STRING_PAD _STR _LEN)
  450. endif(NOT DEFINED _MANAGE_STRING_CMAKE_)
  451. # vim: textwidth=78 noexpandtab tabstop=2 softtabstop=2 shiftwidth=2
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...