Gentoo Archives: gentoo-commits

From: Andrew Ammerlaan <andrewammerlaan@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/sci:master commit in: sci-libs/itk/, sci-libs/itk/files/
Date: Tue, 23 Aug 2022 10:58:35
Message-Id: 1661252289.b4acbb5f52ed06ad45b5a4e877498a6c9f683d4e.andrewammerlaan@gentoo
1 commit: b4acbb5f52ed06ad45b5a4e877498a6c9f683d4e
2 Author: François-Xavier Carton <fx.carton91 <AT> gmail <DOT> com>
3 AuthorDate: Fri Jun 10 13:16:57 2022 +0000
4 Commit: Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org>
5 CommitDate: Tue Aug 23 10:58:09 2022 +0000
6 URL: https://gitweb.gentoo.org/proj/sci.git/commit/?id=b4acbb5f
7
8 sci-libs/itk: bump to 5.2.1
9
10 Signed-off-by: François-Xavier Carton <fx.carton91 <AT> gmail.com>
11 Signed-off-by: Andrew Ammerlaan <andrewammerlaan <AT> gentoo.org>
12 Closes: https://github.com/gentoo/sci/pull/1154
13
14 .../itk-5.2.1-fix-castxml-clang-attr-malloc.patch | 25 +
15 sci-libs/itk/files/itk-5.2.1-system-openjpeg.patch | 558 +++++++++++++++++++++
16 .../itk/files/itk-5.2.1-system-tiff-has-64.patch | 18 +
17 sci-libs/itk/files/itk-5.2.1-upstream-fixes.patch | 255 ++++++++++
18 sci-libs/itk/itk-5.2.1.ebuild | 246 +++++++++
19 5 files changed, 1102 insertions(+)
20
21 diff --git a/sci-libs/itk/files/itk-5.2.1-fix-castxml-clang-attr-malloc.patch b/sci-libs/itk/files/itk-5.2.1-fix-castxml-clang-attr-malloc.patch
22 new file mode 100644
23 index 000000000..05c9d5635
24 --- /dev/null
25 +++ b/sci-libs/itk/files/itk-5.2.1-fix-castxml-clang-attr-malloc.patch
26 @@ -0,0 +1,25 @@
27 +From: François-Xavier Carton <fx.carton91@×××××.com>
28 +Date: Thu, 9 Jun 2022 14:56:22 +0200
29 +Subject: [PATCH] fix attr malloc error with recent glibc/gcc
30 +
31 +Recent GCC has support for __attribute__((__malloc__)) with arguments, but clang
32 +does not. castxml uses clang internally. And recent glibc/gcc uses the attribute
33 +with arguments. Mix all this, and you get:
34 +
35 +error: '__malloc__' attribute takes no arguments
36 +
37 +when compiling itk with python wrapping.
38 +
39 +To fix this, we add a define to castxml flags to remove the extra arguments.
40 +
41 +--- a/Wrapping/Generators/CastXML/CMakeLists.txt 2022-06-09 14:53:15.582352715 +0200
42 ++++ b/Wrapping/Generators/CastXML/CMakeLists.txt 2022-06-09 14:54:38.182351433 +0200
43 +@@ -237,7 +237,7 @@
44 + set(_castxml_cc ${_castxml_cc} "-D_HAS_TR1=0")
45 + endif()
46 + else()
47 +- set(_castxml_cc --castxml-cc-gnu ( "${CMAKE_CXX_COMPILER}" ${_castxml_cc_flags} ))
48 ++ set(_castxml_cc --castxml-cc-gnu ( "${CMAKE_CXX_COMPILER}" ${_castxml_cc_flags} -D__malloc__\(a,b\)=__malloc__ ))
49 + endif()
50 + set(_target)
51 + if(CMAKE_CROSSCOMPILING)
52
53 diff --git a/sci-libs/itk/files/itk-5.2.1-system-openjpeg.patch b/sci-libs/itk/files/itk-5.2.1-system-openjpeg.patch
54 new file mode 100644
55 index 000000000..ad717f677
56 --- /dev/null
57 +++ b/sci-libs/itk/files/itk-5.2.1-system-openjpeg.patch
58 @@ -0,0 +1,558 @@
59 +--- a/Modules/ThirdParty/OpenJPEG/CMakeLists.txt
60 ++++ b/Modules/ThirdParty/OpenJPEG/CMakeLists.txt
61 +@@ -1,16 +1,32 @@
62 + project(ITKOpenJPEG)
63 + set(ITKOpenJPEG_THIRD_PARTY 1)
64 +
65 +-set(ITKOpenJPEG_INCLUDE_DIRS
66 +- ${ITKOpenJPEG_BINARY_DIR}/src/openjpeg
67 +- ${ITKOpenJPEG_SOURCE_DIR}/src/openjpeg
68 +- )
69 +-set(ITKOpenJPEG_LIBRARIES itkopenjpeg)
70 ++option(ITK_USE_SYSTEM_OPENJPEG "Use system-installed openjpeg" ${ITK_USE_SYSTEM_LIBRARIES})
71 ++mark_as_advanced(ITK_USE_SYSTEM_OPENJPEG)
72 ++
73 ++if(ITK_USE_SYSTEM_OPENJPEG)
74 ++ find_package(OpenJPEG REQUIRED)
75 ++ set(ITKOpenJPEG_INCLUDE_DIRS
76 ++ ${ITKOpenJPEG_BINARY_DIR}/src
77 ++ )
78 ++ set(ITKOpenJPEG_SYSTEM_INCLUDE_DIRS
79 ++ ${OPENJPEG_INCLUDE_DIRS}
80 ++ )
81 ++ set(ITKOpenJPEG_LIBRARIES "${OPENJPEG_LIBRARIES}")
82 ++ set(ITKOpenJPEG_NO_SRC 1)
83 ++else()
84 ++ set(ITKOpenJPEG_INCLUDE_DIRS
85 ++ ${ITKOpenJPEG_BINARY_DIR}/src/openjpeg
86 ++ ${ITKOpenJPEG_SOURCE_DIR}/src/openjpeg
87 ++ )
88 ++ set(ITKOpenJPEG_LIBRARIES itkopenjpeg)
89 ++endif()
90 ++
91 ++configure_file(src/itk_openjpeg.h.in src/itk_openjpeg.h)
92 + set(ITK_LIBRARY_PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS FALSE)
93 +-
94 + itk_module_impl()
95 +
96 +-install(FILES ${ITKOpenJPEG_SOURCE_DIR}/src/itk_openjpeg.h
97 ++install(FILES ${ITKOpenJPEG_BINARY_DIR}/src/itk_openjpeg.h
98 + DESTINATION ${ITKOpenJPEG_INSTALL_INCLUDE_DIR}
99 + COMPONENT Development
100 + )
101 +diff --git a/Modules/ThirdParty/OpenJPEG/src/itk_openjpeg.h b/Modules/ThirdParty/OpenJPEG/src/itk_openjpeg.h.in
102 +rename from Modules/ThirdParty/OpenJPEG/src/itk_openjpeg.h
103 +rename to Modules/ThirdParty/OpenJPEG/src/itk_openjpeg.h.in
104 +--- a/Modules/ThirdParty/OpenJPEG/src/itk_openjpeg.h
105 ++++ b/Modules/ThirdParty/OpenJPEG/src/itk_openjpeg.h.in
106 +@@ -25,6 +25,12 @@
107 + #ifndef itk_openjpeg_h
108 + #define itk_openjpeg_h
109 +
110 +-#include <itkopenjpeg/openjpeg.h>
111 ++/* Use the openjpeg library configured for ITK. */
112 ++#cmakedefine ITK_USE_SYSTEM_OPENJPEG
113 ++#ifdef ITK_USE_SYSTEM_OPENJPEG
114 ++# include <openjpeg.h>
115 ++#else
116 ++# include <itkopenjpeg/openjpeg.h>
117 ++#endif
118 +
119 + #endif
120 +--- a/Modules/IO/JPEG2000/src/itkJPEG2000ImageIO.cxx
121 ++++ b/Modules/IO/JPEG2000/src/itkJPEG2000ImageIO.cxx
122 +@@ -27,8 +27,6 @@
123 + extern "C"
124 + {
125 + #include "openjpeg.h"
126 +-#include "j2k.h"
127 +-#include "jp2.h"
128 + }
129 +
130 +
131 +@@ -139,11 +137,11 @@
132 + {
133 + itkDebugMacro(<< "ReadImageInformation()");
134 +
135 +- FILE * l_file = fopen(this->m_FileName.c_str(), "rb");
136 +-
137 +- /* decompression parameters */
138 ++ /* set decoding parameters to default values */
139 ++ opj_set_default_decoder_parameters(&(this->m_Internal->m_DecompressionParameters));
140 +
141 +- if (!l_file)
142 ++ opj_stream_t * cio = opj_stream_create_default_file_stream(this->m_FileName.c_str(), true);
143 ++ if (!cio)
144 + {
145 + itkExceptionMacro("JPEG2000ImageIO failed to open file for reading: " << this->GetFileName() << std::endl
146 + << "Reason: "
147 +@@ -151,10 +149,5 @@
148 + }
149 +
150 +- /* set decoding parameters to default values */
151 +- opj_set_default_decoder_parameters(&(this->m_Internal->m_DecompressionParameters));
152 +-
153 +- opj_stream_t * cio = opj_stream_create_default_file_stream(l_file, true);
154 +-
155 + this->m_Internal->m_Dinfo = nullptr; /* handle to a decompressor */
156 +
157 + opj_image_t * l_image = nullptr;
158 +@@ -188,9 +181,8 @@
159 +
160 + /* get a decoder handle */
161 +- this->m_Internal->m_Dinfo = opj_create_decompress(CODEC_J2K);
162 ++ this->m_Internal->m_Dinfo = opj_create_decompress(OPJ_CODEC_J2K);
163 + if (!this->m_Internal->m_Dinfo)
164 + {
165 + opj_stream_destroy(cio);
166 +- fclose(l_file);
167 + itkExceptionMacro("JPEG2000ImageIO failed to read file: "
168 + << this->GetFileName() << std::endl
169 +@@ -202,10 +194,9 @@
170 + {
171 + /* JPEG 2000 compressed image data */
172 + /* get a decoder handle */
173 +- this->m_Internal->m_Dinfo = opj_create_decompress(CODEC_JP2);
174 ++ this->m_Internal->m_Dinfo = opj_create_decompress(OPJ_CODEC_JP2);
175 + if (!this->m_Internal->m_Dinfo)
176 + {
177 + opj_stream_destroy(cio);
178 +- fclose(l_file);
179 + itkExceptionMacro("JPEG2000ImageIO failed to read file: "
180 + << this->GetFileName() << std::endl
181 +@@ -217,10 +208,9 @@
182 + {
183 + /* JPEG 2000, JPIP */
184 + /* get a decoder handle */
185 +- this->m_Internal->m_Dinfo = opj_create_decompress(CODEC_JPT);
186 ++ this->m_Internal->m_Dinfo = opj_create_decompress(OPJ_CODEC_JPT);
187 + if (!this->m_Internal->m_Dinfo)
188 + {
189 + opj_stream_destroy(cio);
190 +- fclose(l_file);
191 + itkExceptionMacro("JPEG2000ImageIO failed to read file: "
192 + << this->GetFileName() << std::endl
193 +@@ -230,7 +220,6 @@
194 + }
195 + default:
196 + opj_stream_destroy(cio);
197 +- fclose(l_file);
198 + itkExceptionMacro("JPEG2000ImageIO failed to read file: "
199 + << this->GetFileName() << std::endl
200 + << "Reason: "
201 +@@ -248,26 +237,8 @@
202 + }
203 +
204 +- // Image parameters - first tile
205 +- OPJ_INT32 l_tile_x0;
206 +- OPJ_INT32 l_tile_y0;
207 +-
208 +- // Image parameters - tile width, height and number of tiles
209 +- OPJ_UINT32 l_tile_width;
210 +- OPJ_UINT32 l_tile_height;
211 +- OPJ_UINT32 l_nb_tiles_x;
212 +- OPJ_UINT32 l_nb_tiles_y;
213 +-
214 + itkDebugMacro(<< "Trying to read header now...");
215 +
216 +- bResult = opj_read_header(this->m_Internal->m_Dinfo,
217 +- &l_image,
218 +- &l_tile_x0,
219 +- &l_tile_y0,
220 +- &l_tile_width,
221 +- &l_tile_height,
222 +- &l_nb_tiles_x,
223 +- &l_nb_tiles_y,
224 +- cio);
225 ++ bResult = opj_read_header(cio, this->m_Internal->m_Dinfo, &l_image);
226 +
227 + if (!bResult)
228 + {
229 +@@ -284,13 +255,21 @@
230 + }
231 +
232 +- this->m_Internal->m_TileStartX = l_tile_x0;
233 +- this->m_Internal->m_TileStartY = l_tile_y0;
234 ++ opj_codestream_info_v2_t* cp = opj_get_cstr_info(this->m_Internal->m_Dinfo);
235 ++ if (!cp)
236 ++ {
237 ++ opj_stream_destroy(cio);
238 ++ opj_image_destroy(l_image);
239 ++ itkExceptionMacro("JPEG2000ImageIO failed to read file: " << this->GetFileName() << std::endl
240 ++ << "Reason: Error while reading image header");
241 ++ }
242 ++ this->m_Internal->m_TileStartX = cp->tx0;
243 ++ this->m_Internal->m_TileStartY = cp->ty0;
244 +
245 +- this->m_Internal->m_TileWidth = l_tile_width;
246 +- this->m_Internal->m_TileHeight = l_tile_height;
247 ++ this->m_Internal->m_TileWidth = cp->tdx;
248 ++ this->m_Internal->m_TileHeight = cp->tdy;
249 +
250 +- this->m_Internal->m_NumberOfTilesInX = l_nb_tiles_x;
251 +- this->m_Internal->m_NumberOfTilesInY = l_nb_tiles_y;
252 ++ this->m_Internal->m_NumberOfTilesInX = cp->tw;
253 ++ this->m_Internal->m_NumberOfTilesInY = cp->th;
254 +
255 +
256 + itkDebugMacro(<< "Number of Components = " << l_image->numcomps);
257 +@@ -307,6 +286,7 @@
258 + else
259 + {
260 + opj_stream_destroy(cio);
261 ++ opj_image_destroy(l_image);
262 + itkExceptionMacro("JPEG2000ImageIO failed to read file: " << this->GetFileName() << std::endl
263 + << "Reason: "
264 + << "Unknown precision in file: "
265 +@@ -320,6 +300,6 @@
266 + break;
267 + case 3:
268 +- if (l_image->color_space != CLRSPC_SRGB)
269 ++ if (l_image->color_space != OPJ_CLRSPC_SRGB)
270 + {
271 + itkWarningMacro(<< "file does not specify color space, assuming sRGB");
272 + }
273 +@@ -349,7 +329,6 @@
274 +
275 + /* close the byte stream */
276 + opj_stream_destroy(cio);
277 +- fclose(l_file);
278 +
279 + if (this->m_Internal->m_Dinfo)
280 + {
281 +@@ -368,16 +347,7 @@
282 + {
283 + itkDebugMacro(<< "JPEG2000ImageIO::Read() Begin");
284 +
285 +- FILE * l_file = fopen(this->m_FileName.c_str(), "rb");
286 +-
287 +- if (!l_file)
288 +- {
289 +- itkExceptionMacro("JPEG2000ImageIO failed to open file for reading: " << this->GetFileName() << std::endl
290 +- << "Reason: "
291 +- << itksys::SystemTools::GetLastSystemError());
292 +- }
293 +-
294 +- opj_stream_t * l_stream = opj_stream_create_default_file_stream(l_file, true);
295 ++ opj_stream_t * l_stream = opj_stream_create_default_file_stream(this->m_FileName.c_str(), true);
296 + if (!l_stream)
297 + {
298 + itkExceptionMacro("JPEG2000ImageIO failed to read file: "
299 +@@ -397,9 +367,10 @@
300 + {
301 + /* JPEG-2000 codestream */
302 + /* get a decoder handle */
303 +- this->m_Internal->m_Dinfo = opj_create_decompress(CODEC_J2K);
304 ++ this->m_Internal->m_Dinfo = opj_create_decompress(OPJ_CODEC_J2K);
305 + if (!this->m_Internal->m_Dinfo)
306 + {
307 ++ opj_stream_destroy(l_stream);
308 + itkExceptionMacro("JPEG2000ImageIO failed to read file: "
309 + << this->GetFileName() << std::endl
310 + << "Reason: opj_create_decompress(CODEC_J2K) returns nullptr");
311 +@@ -410,9 +381,10 @@
312 + {
313 + /* JPEG 2000 compressed image data */
314 + /* get a decoder handle */
315 +- this->m_Internal->m_Dinfo = opj_create_decompress(CODEC_JP2);
316 ++ this->m_Internal->m_Dinfo = opj_create_decompress(OPJ_CODEC_JP2);
317 + if (!this->m_Internal->m_Dinfo)
318 + {
319 ++ opj_stream_destroy(l_stream);
320 + itkExceptionMacro("JPEG2000ImageIO failed to read file: "
321 + << this->GetFileName() << std::endl
322 + << "Reason: opj_create_decompress(CODEC_JP2) returns nullptr");
323 +@@ -423,9 +395,10 @@
324 + {
325 + /* JPEG 2000, JPIP */
326 + /* get a decoder handle */
327 +- this->m_Internal->m_Dinfo = opj_create_decompress(CODEC_JPT);
328 ++ this->m_Internal->m_Dinfo = opj_create_decompress(OPJ_CODEC_JPT);
329 + if (!this->m_Internal->m_Dinfo)
330 + {
331 ++ opj_stream_destroy(l_stream);
332 + itkExceptionMacro("JPEG2000ImageIO failed to read file: "
333 + << this->GetFileName() << std::endl
334 + << "Reason: opj_create_decompress(CODEC_JPT) returns nullptr");
335 +@@ -433,7 +406,7 @@
336 + break;
337 + }
338 + default:
339 +- fclose(l_file);
340 ++ opj_stream_destroy(l_stream);
341 + itkExceptionMacro("JPEG2000ImageIO failed to read file: "
342 + << this->GetFileName() << std::endl
343 + << "Reason: "
344 +@@ -445,32 +418,17 @@
345 + if (!opj_setup_decoder(this->m_Internal->m_Dinfo, &(this->m_Internal->m_DecompressionParameters)))
346 + {
347 ++ opj_stream_destroy(l_stream);
348 + itkExceptionMacro("JPEG2000ImageIO failed to read file: " << this->GetFileName() << std::endl
349 + << "Reason: opj_setup_decoder returns false");
350 + }
351 +
352 +- OPJ_INT32 l_tile_x0, l_tile_y0;
353 +-
354 +- OPJ_UINT32 l_tile_width;
355 +- OPJ_UINT32 l_tile_height;
356 +- OPJ_UINT32 l_nb_tiles_x;
357 +- OPJ_UINT32 l_nb_tiles_y;
358 +-
359 +- bool bResult = opj_read_header(this->m_Internal->m_Dinfo,
360 +- &l_image,
361 +- &l_tile_x0,
362 +- &l_tile_y0,
363 +- &l_tile_width,
364 +- &l_tile_height,
365 +- &l_nb_tiles_x,
366 +- &l_nb_tiles_y,
367 +- l_stream);
368 ++ bool bResult = opj_read_header(l_stream, this->m_Internal->m_Dinfo, &l_image);
369 +
370 + if (!bResult)
371 + {
372 + opj_destroy_codec(this->m_Internal->m_Dinfo);
373 + this->m_Internal->m_Dinfo = nullptr;
374 + opj_stream_destroy(l_stream);
375 +- fclose(l_file);
376 + itkExceptionMacro("JPEG2000ImageIO failed to read file: " << this->GetFileName() << std::endl
377 + << "Reason: opj_read_header returns false");
378 + }
379 +@@ -499,7 +457,7 @@
380 + itkDebugMacro(<< "p_end_x = " << p_end_x);
381 + itkDebugMacro(<< "p_end_y = " << p_end_y);
382 +
383 +- bResult = opj_set_decode_area(this->m_Internal->m_Dinfo, p_start_x, p_start_y, p_end_x, p_end_y);
384 ++ bResult = opj_set_decode_area(this->m_Internal->m_Dinfo, l_image, p_start_x, p_start_y, p_end_x, p_end_y);
385 +
386 + itkDebugMacro(<< "opj_set_decode_area() after");
387 +
388 +@@ -509,6 +467,5 @@
389 + this->m_Internal->m_Dinfo = nullptr;
390 + opj_stream_destroy(l_stream);
391 +- fclose(l_file);
392 + itkExceptionMacro("JPEG2000ImageIO failed to read file: " << this->GetFileName() << std::endl
393 + << "Reason: opj_set_decode_area returns false");
394 + }
395 +@@ -525,13 +482,14 @@
396 +
397 + OPJ_UINT32 l_max_data_size = 1000;
398 +
399 +- bool l_go_on = true;
400 ++ OPJ_BOOL l_go_on = true;
401 +
402 + auto * l_data = (OPJ_BYTE *)malloc(1000);
403 +
404 + while (l_go_on)
405 + {
406 + bool tileHeaderRead = opj_read_tile_header(this->m_Internal->m_Dinfo,
407 ++ l_stream,
408 + &l_tile_index,
409 + &l_data_size,
410 + &l_current_tile_x0,
411 +@@ -540,13 +498,11 @@
412 + &l_current_tile_y1,
413 + &l_nb_comps,
414 +- &l_go_on,
415 +- l_stream);
416 ++ &l_go_on);
417 +
418 + if (!tileHeaderRead)
419 + {
420 + free(l_data);
421 + opj_stream_destroy(l_stream);
422 +- fclose(l_file);
423 + opj_destroy_codec(this->m_Internal->m_Dinfo);
424 + opj_image_destroy(l_image);
425 + itkExceptionMacro("JPEG2000ImageIO failed to read file: " << this->GetFileName() << std::endl
426 +@@ -571,7 +527,6 @@
427 + if (!l_data)
428 + {
429 + opj_stream_destroy(l_stream);
430 +- fclose(l_file);
431 + opj_destroy_codec(this->m_Internal->m_Dinfo);
432 + opj_image_destroy(l_image);
433 + itkExceptionMacro("JPEG2000ImageIO failed to read file: " << this->GetFileName() << std::endl
434 +@@ -590,7 +545,6 @@
435 + {
436 + free(l_data);
437 + opj_stream_destroy(l_stream);
438 +- fclose(l_file);
439 + opj_destroy_codec(this->m_Internal->m_Dinfo);
440 + opj_image_destroy(l_image);
441 + itkExceptionMacro("JPEG2000ImageIO failed to read file: " << this->GetFileName() << std::endl
442 +@@ -654,7 +608,6 @@
443 + {
444 + free(l_data);
445 + opj_stream_destroy(l_stream);
446 +- fclose(l_file);
447 + opj_destroy_codec(this->m_Internal->m_Dinfo);
448 + opj_image_destroy(l_image);
449 + itkExceptionMacro("JPEG2000ImageIO failed to read file: " << this->GetFileName() << std::endl
450 +@@ -667,13 +620,11 @@
451 + this->m_Internal->m_Dinfo = nullptr;
452 + opj_stream_destroy(l_stream);
453 +- fclose(l_file);
454 + itkExceptionMacro("JPEG2000ImageIO failed to read file: " << this->GetFileName() << std::endl
455 + << "Reason: error whle reading image");
456 + }
457 +
458 + /* close the byte stream */
459 + opj_stream_destroy(l_stream);
460 +- fclose(l_file);
461 +
462 + if (this->m_Internal->m_Dinfo)
463 + {
464 +@@ -775,6 +726,6 @@
465 + }
466 +
467 +- for (int i = 0; i < parameters.numpocs; i++)
468 ++ for (OPJ_UINT32 i = 0; i < parameters.numpocs; i++)
469 + {
470 + if (parameters.POC[i].prg == -1)
471 + {
472 +@@ -840,13 +791,13 @@
473 +
474 + parameters.numresolution = numberOfResolutions;
475 +
476 +- OPJ_COLOR_SPACE color_space = CLRSPC_GRAY;
477 ++ OPJ_COLOR_SPACE color_space = OPJ_CLRSPC_GRAY;
478 + opj_image_cmptparm_t cmptparms[3];
479 +
480 + if (this->GetNumberOfComponents() == 3)
481 + {
482 +
483 +- color_space = (this->GetPixelType() == IOPixelEnum::RGB) ? CLRSPC_SRGB : CLRSPC_UNSPECIFIED;
484 ++ color_space = (this->GetPixelType() == IOPixelEnum::RGB) ? OPJ_CLRSPC_SRGB : OPJ_CLRSPC_UNSPECIFIED;
485 +
486 + /* initialize image components */
487 + memset(&cmptparms[0], 0, 3 * sizeof(opj_image_cmptparm_t));
488 +@@ -864,7 +815,7 @@
489 +
490 + if (this->GetNumberOfComponents() == 1)
491 + {
492 +- color_space = CLRSPC_GRAY;
493 ++ color_space = OPJ_CLRSPC_GRAY;
494 +
495 + /* initialize image components */
496 + memset(&cmptparms[0], 0, sizeof(opj_image_cmptparm_t));
497 +@@ -941,8 +892,9 @@
498 + if (extension == ".j2k")
499 + {
500 +- cinfo = opj_create_compress(CODEC_J2K);
501 ++ cinfo = opj_create_compress(OPJ_CODEC_J2K);
502 + if (!cinfo)
503 + {
504 ++ opj_image_destroy(l_image);
505 + itkExceptionMacro("JPEG2000ImageIO failed to write file: "
506 + << this->GetFileName() << std::endl
507 + << "Reason: opj_create_compress(CODEC_J2K) returns nullptr");
508 +@@ -950,9 +902,10 @@
509 + }
510 + else if (extension == ".jp2")
511 + {
512 +- cinfo = opj_create_compress(CODEC_JP2);
513 ++ cinfo = opj_create_compress(OPJ_CODEC_JP2);
514 + if (!cinfo)
515 + {
516 ++ opj_image_destroy(l_image);
517 + itkExceptionMacro("JPEG2000ImageIO failed to write file: "
518 + << this->GetFileName() << std::endl
519 + << "Reason: opj_create_compress(CODEC_JP2) returns nullptr");
520 +@@ -960,9 +913,10 @@
521 + }
522 + else if (extension == ".jpt")
523 + {
524 +- cinfo = opj_create_compress(CODEC_JPT);
525 ++ cinfo = opj_create_compress(OPJ_CODEC_JPT);
526 + if (!cinfo)
527 + {
528 ++ opj_image_destroy(l_image);
529 + itkExceptionMacro("JPEG2000ImageIO failed to write file: "
530 + << this->GetFileName() << std::endl
531 + << "Reason: opj_create_compress(CODEC_JPT) returns nullptr");
532 +@@ -970,6 +924,7 @@
533 + }
534 + else
535 + {
536 ++ opj_image_destroy(l_image);
537 + itkExceptionMacro("JPEG2000ImageIO failed to write file: " << this->GetFileName() << std::endl
538 + << "Reason: unknown encode format: " << extension);
539 + }
540 +@@ -985,23 +940,19 @@
541 +
542 + if (!opj_setup_encoder(cinfo, &parameters, l_image))
543 + {
544 ++ opj_destroy_codec(cinfo);
545 ++ opj_image_destroy(l_image);
546 + itkExceptionMacro("JPEG2000ImageIO failed to write file: " << this->GetFileName() << std::endl
547 + << "Reason: opj_setup_encoder returns false");
548 + }
549 +
550 +- FILE * l_file = fopen(parameters.outfile, "wb");
551 +- if (!l_file)
552 +- {
553 +- itkExceptionMacro("JPEG2000ImageIO failed to open file for writing: " << this->GetFileName() << std::endl
554 +- << "Reason: "
555 +- << itksys::SystemTools::GetLastSystemError());
556 +- }
557 +-
558 + /* open a byte stream for writing */
559 + /* allocate memory for all tiles */
560 +- opj_stream_t * cio = opj_stream_create_default_file_stream(l_file, false);
561 ++ opj_stream_t * cio = opj_stream_create_default_file_stream(parameters.outfile, false);
562 + if (!cio)
563 + {
564 ++ opj_destroy_codec(cinfo);
565 ++ opj_image_destroy(l_image);
566 + itkExceptionMacro("JPEG2000ImageIO failed to write file: "
567 + << this->GetFileName() << std::endl
568 + << "Reason: "
569 +@@ -1017,7 +968,8 @@
570 + if (!bSuccess)
571 + {
572 + opj_stream_destroy(cio);
573 +- fclose(l_file);
574 ++ opj_destroy_codec(cinfo);
575 ++ opj_image_destroy(l_image);
576 + itkExceptionMacro("JPEG2000ImageIO failed to write file: " << this->GetFileName() << std::endl
577 + << "Reason: opj_start_compress returns false");
578 + }
579 +@@ -1026,7 +978,8 @@
580 + if (!bSuccess)
581 + {
582 + opj_stream_destroy(cio);
583 +- fclose(l_file);
584 ++ opj_destroy_codec(cinfo);
585 ++ opj_image_destroy(l_image);
586 + itkExceptionMacro("JPEG2000ImageIO failed to write file: " << this->GetFileName() << std::endl
587 + << "Reason: opj_encode returns false");
588 + }
589 +@@ -1035,14 +988,14 @@
590 + if (!bSuccess)
591 + {
592 + opj_stream_destroy(cio);
593 +- fclose(l_file);
594 ++ opj_destroy_codec(cinfo);
595 ++ opj_image_destroy(l_image);
596 + itkExceptionMacro("JPEG2000ImageIO failed to write file: " << this->GetFileName() << std::endl
597 + << "Reason: opj_end_compress returns false");
598 + }
599 +
600 + /* close and free the byte stream */
601 + opj_stream_destroy(cio);
602 +- fclose(l_file);
603 +
604 + /* free remaining compression structures */
605 + opj_destroy_codec(cinfo);
606 +--- a/Modules/Nonunit/Review/src/CMakeLists.txt
607 ++++ b/Modules/Nonunit/Review/src/CMakeLists.txt
608 +@@ -5,7 +5,7 @@
609 +
610 + add_library(ITKReview ${ITKReview_SRC})
611 + itk_module_link_dependencies()
612 +-target_link_libraries(ITKReview LINK_PUBLIC ${ITKTestKernel_LIBRARIES} ${ITKIOLSM_LIBRARIES} itkopenjpeg)
613 ++target_link_libraries(ITKReview LINK_PUBLIC ${ITKTestKernel_LIBRARIES} ${ITKIOLSM_LIBRARIES} ${ITKOpenJPEG_LIBRARIES})
614 + itk_module_target(ITKReview)
615 +
616 +
617
618 diff --git a/sci-libs/itk/files/itk-5.2.1-system-tiff-has-64.patch b/sci-libs/itk/files/itk-5.2.1-system-tiff-has-64.patch
619 new file mode 100644
620 index 000000000..25c44db2c
621 --- /dev/null
622 +++ b/sci-libs/itk/files/itk-5.2.1-system-tiff-has-64.patch
623 @@ -0,0 +1,18 @@
624 +From: François-Xavier Carton <fx.carton91@×××××.com>
625 +Date: Wed, 8 Jun 2022 19:36:48 +0200
626 +Subject: [PATCH] system libtiff has INT64
627 +
628 +Enabling this, otherwise using system libtiff leads to errors. In particular
629 +tests fail because there is some IFD8 data but the itkTIFFDataSize function
630 +returns 0 instead of 8, resulting in invalid mem access.
631 +
632 +--- a/Modules/ThirdParty/TIFF/src/itk_tiff.h.in.orig 2022-06-08 19:34:04.412431969 +0200
633 ++++ b/Modules/ThirdParty/TIFF/src/itk_tiff.h.in 2022-06-08 19:34:26.240431631 +0200
634 +@@ -34,6 +34,7 @@
635 + #cmakedefine ITK_TIFF_HAS_TIFFFieldReadCount
636 + #cmakedefine ITK_TIFF_HAS_TIFFField
637 + #ifdef ITK_USE_SYSTEM_TIFF
638 ++# define TIFF_INT64_T int64_t
639 + # include <tiffio.h>
640 + #else
641 + # include "itktiff/tiffio.h"
642
643 diff --git a/sci-libs/itk/files/itk-5.2.1-upstream-fixes.patch b/sci-libs/itk/files/itk-5.2.1-upstream-fixes.patch
644 new file mode 100644
645 index 000000000..2e547d9ca
646 --- /dev/null
647 +++ b/sci-libs/itk/files/itk-5.2.1-upstream-fixes.patch
648 @@ -0,0 +1,255 @@
649 +https://github.com/InsightSoftwareConsortium/ITK/commit/2a7f5ed199926999b67f61a97c2c9a2595a11558.patch
650 +https://github.com/InsightSoftwareConsortium/ITK/commit/0c31aa688e82a34e5430873bc6176740fd09ad75.patch
651 +https://github.com/InsightSoftwareConsortium/ITK/commit/28325d921a9b8793e6aaefd612f53989f951d19c.patch
652 +
653 +From 2a7f5ed199926999b67f61a97c2c9a2595a11558 Mon Sep 17 00:00:00 2001
654 +From: Niels Dekker <N.Dekker@××××.nl>
655 +Date: Thu, 24 Jun 2021 18:00:01 +0200
656 +Subject: [PATCH] COMP: Add missing `#include <iostream>` to Deprecated module
657 + test
658 +
659 +Fixed a Visual C++ 2019 error, saying:
660 +
661 +> Deprecated\test\itkSimpleFastMutexLockTest.cxx(48,12): error C2039: 'cout': is not a member of 'std'
662 +---
663 + .../Deprecated/test/itkSimpleFastMutexLockTest.cxx | 2 ++
664 + 1 file changed, 2 insertions(+)
665 +
666 +diff --git a/Modules/Compatibility/Deprecated/test/itkSimpleFastMutexLockTest.cxx b/Modules/Compatibility/Deprecated/test/itkSimpleFastMutexLockTest.cxx
667 +index 11ad0c52700..60aa1c065b4 100644
668 +--- a/Modules/Compatibility/Deprecated/test/itkSimpleFastMutexLockTest.cxx
669 ++++ b/Modules/Compatibility/Deprecated/test/itkSimpleFastMutexLockTest.cxx
670 +@@ -19,6 +19,8 @@
671 +
672 + #include "itkSimpleFastMutexLock.h"
673 +
674 ++#include <iostream> // For cout.
675 ++
676 +
677 + int
678 + itkSimpleFastMutexLockTest(int, char *[])
679 +From 0c31aa688e82a34e5430873bc6176740fd09ad75 Mon Sep 17 00:00:00 2001
680 +From: Pablo Hernandez-Cerdan <pablo.hernandez.cerdan@×××××××.com>
681 +Date: Tue, 20 Apr 2021 17:21:21 +0200
682 +Subject: [PATCH] COMP: CastXML, ITKVtkGlue, include only when property exists
683 +
684 +Some targets (VTK libraries) didn't have the property INTERFACE_INCLUDE_DIRECTORIES
685 +
686 +```bash
687 +CMake Error in Modules/Bridge/VtkGlue/wrapping/CMakeLists.txt:
688 + Found relative path while evaluating include directories of
689 + "ITKVtkGluePython":
690 +
691 + "_vtk_lib_include_dirs-NOTFOUND"
692 +```
693 +
694 +Triggered when compiling Slicer with `Slicer_BUILD_ITKPython:BOOL=ON`
695 +aka `ITK_WRAP_PYTHON:BOOL=ON`.
696 +
697 +Full error log with extra printing:
698 +
699 +```bash
700 +
701 +CMake Warning at Modules/Bridge/VtkGlue/wrapping/CMakeLists.txt:3 (message):
702 + ITKVtkGlue_VTK_LIBRARIES:
703 + VTK::IOImage;VTK::ImagingSources;VTK::WrappingPythonCore;VTK::CommonCore;VTK::CommonDataModel;VTK::kwiml;VTK::CommonExecutionModel;VTK::RenderingOpenGL2;VTK::RenderingFreeType;VTK::InteractionStyle;VTK::InteractionWidgets
704 +
705 +CMake Warning at Modules/Bridge/VtkGlue/wrapping/CMakeLists.txt:6 (message):
706 + _vtk_lib_include_dirs: _vtk_lib_include_dirs-NOTFOUND
707 +
708 +CMake Warning at Modules/Bridge/VtkGlue/wrapping/CMakeLists.txt:6 (message):
709 + _vtk_lib_include_dirs: _vtk_lib_include_dirs-NOTFOUND
710 +
711 +CMake Warning at Modules/Bridge/VtkGlue/wrapping/CMakeLists.txt:6 (message):
712 + _vtk_lib_include_dirs:
713 + build/VTK-build/Wrapping/PythonCore;build/VTK/Wrapping/PythonCore
714 +
715 +CMake Warning at Modules/Bridge/VtkGlue/wrapping/CMakeLists.txt:6 (message):
716 + _vtk_lib_include_dirs: _vtk_lib_include_dirs-NOTFOUND
717 +
718 +CMake Warning at Modules/Bridge/VtkGlue/wrapping/CMakeLists.txt:6 (message):
719 + _vtk_lib_include_dirs: _vtk_lib_include_dirs-NOTFOUND
720 +
721 +CMake Warning at Modules/Bridge/VtkGlue/wrapping/CMakeLists.txt:6 (message):
722 + _vtk_lib_include_dirs:
723 + build/VTK-build/Utilities/KWIML;build/VTK/Utilities/KWIML
724 +
725 +CMake Warning at Modules/Bridge/VtkGlue/wrapping/CMakeLists.txt:6 (message):
726 + _vtk_lib_include_dirs: _vtk_lib_include_dirs-NOTFOUND
727 +
728 +CMake Warning at Modules/Bridge/VtkGlue/wrapping/CMakeLists.txt:6 (message):
729 + _vtk_lib_include_dirs: _vtk_lib_include_dirs-NOTFOUND
730 +
731 +CMake Warning at Modules/Bridge/VtkGlue/wrapping/CMakeLists.txt:6 (message):
732 + _vtk_lib_include_dirs: _vtk_lib_include_dirs-NOTFOUND
733 +
734 +CMake Warning at Modules/Bridge/VtkGlue/wrapping/CMakeLists.txt:6 (message):
735 + _vtk_lib_include_dirs: _vtk_lib_include_dirs-NOTFOUND
736 +
737 +CMake Warning at Modules/Bridge/VtkGlue/wrapping/CMakeLists.txt:6 (message):
738 + _vtk_lib_include_dirs: _vtk_lib_include_dirs-NOTFOUND
739 +
740 +-- ITKVtkGlue: Creating module.
741 +-- ITKVtkGlue: Creating itkImageToVTKImageFilter submodule.
742 +-- ITKVtkGlue: Creating itkVTKImageToImageFilter submodule.
743 +-- ITKVtkGlue: Creating itkViewImage submodule.
744 +-- MGHIO: Creating module.
745 +-- MGHIO: Creating itkMGHImageIO submodule.
746 +-- MorphologicalContourInterpolation: Creating module.
747 +-- MorphologicalContourInterpolation: Creating itkMorphologicalContourInterpolator submodule.
748 +-- ITKPyUtils: Creating module.
749 +-- ITKPyUtils: Creating itkPyCommand submodule.
750 +-- ITKPyUtils: Creating itkPyImageFilter submodule.
751 +-- Configuring done
752 +CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
753 +Please set them or make sure they are set and tested correctly in the CMake files:
754 +_vtk_lib_include_dirs
755 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
756 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
757 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
758 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
759 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
760 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
761 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
762 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
763 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
764 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
765 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
766 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
767 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
768 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
769 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
770 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
771 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
772 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
773 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
774 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
775 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
776 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
777 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
778 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
779 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
780 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
781 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
782 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
783 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
784 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
785 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
786 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
787 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
788 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
789 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
790 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
791 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
792 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
793 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
794 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
795 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
796 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
797 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
798 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
799 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
800 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
801 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
802 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
803 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
804 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
805 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
806 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
807 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
808 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
809 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
810 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
811 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
812 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
813 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
814 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
815 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
816 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
817 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
818 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
819 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
820 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
821 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
822 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
823 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
824 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
825 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
826 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
827 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
828 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
829 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
830 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
831 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
832 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
833 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
834 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
835 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
836 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
837 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
838 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
839 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
840 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
841 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
842 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
843 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
844 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
845 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
846 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
847 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
848 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
849 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
850 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
851 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
852 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
853 + used as include directory in directory build/ITK/Modules/Bridge/VtkGlue/wrapping
854 +
855 +CMake Error in Modules/Bridge/VtkGlue/wrapping/CMakeLists.txt:
856 + Found relative path while evaluating include directories of
857 + "ITKVtkGluePython":
858 +
859 + "_vtk_lib_include_dirs-NOTFOUND"
860 +
861 +```
862 +---
863 + Modules/Bridge/VtkGlue/wrapping/CMakeLists.txt | 4 +++-
864 + 1 file changed, 3 insertions(+), 1 deletion(-)
865 +
866 +diff --git a/Modules/Bridge/VtkGlue/wrapping/CMakeLists.txt b/Modules/Bridge/VtkGlue/wrapping/CMakeLists.txt
867 +index 3f3322957e1..2fd6a5af8f6 100644
868 +--- a/Modules/Bridge/VtkGlue/wrapping/CMakeLists.txt
869 ++++ b/Modules/Bridge/VtkGlue/wrapping/CMakeLists.txt
870 +@@ -2,7 +2,9 @@
871 + if(NOT VTK_RENDERING_BACKEND STREQUAL "None")
872 + foreach(_vtk_lib IN LISTS ITKVtkGlue_VTK_LIBRARIES)
873 + get_target_property(_vtk_lib_include_dirs ${_vtk_lib} INTERFACE_INCLUDE_DIRECTORIES)
874 +- include_directories(${_vtk_lib_include_dirs})
875 ++ if(_vtk_lib_include_dirs)
876 ++ include_directories(${_vtk_lib_include_dirs})
877 ++ endif()
878 + endforeach()
879 + endif()
880 +
881 +From 28325d921a9b8793e6aaefd612f53989f951d19c Mon Sep 17 00:00:00 2001
882 +From: Butui Hu <hot123tea123@×××××.com>
883 +Date: Mon, 1 Aug 2022 14:26:39 +0800
884 +Subject: [PATCH] COMP: use sysconfig.get_path as PEP 632 deprecate distutils
885 + module
886 +
887 +---
888 + Wrapping/Generators/Python/CMakeLists.txt | 2 +-
889 + 1 file changed, 1 insertion(+), 1 deletion(-)
890 +
891 +diff --git a/Wrapping/Generators/Python/CMakeLists.txt b/Wrapping/Generators/Python/CMakeLists.txt
892 +index fca3d999b87..3b7a1d37334 100644
893 +--- a/Wrapping/Generators/Python/CMakeLists.txt
894 ++++ b/Wrapping/Generators/Python/CMakeLists.txt
895 +@@ -36,7 +36,7 @@ file(MAKE_DIRECTORY ${WRAPPER_MASTER_INDEX_OUTPUT_DIR}/python)
896 + ###############################################################################
897 + # Configure Python wrapping installation
898 + if(Python3_EXECUTABLE AND NOT PY_SITE_PACKAGES_PATH)
899 +- set(python_check "try:\n import distutils.sysconfig\n print(distutils.sysconfig.get_python_lib(plat_specific=1, prefix=''))\nexcept:\n pass")
900 ++ set(python_check "try:\n import sysconfig\n print(sysconfig.get_path('platlib'))\nexcept:\n pass")
901 + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/detect_site_package_path.py ${python_check})
902 + execute_process(COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_BINARY_DIR}/detect_site_package_path.py"
903 + OUTPUT_VARIABLE py_spp
904
905 diff --git a/sci-libs/itk/itk-5.2.1.ebuild b/sci-libs/itk/itk-5.2.1.ebuild
906 new file mode 100644
907 index 000000000..25292269f
908 --- /dev/null
909 +++ b/sci-libs/itk/itk-5.2.1.ebuild
910 @@ -0,0 +1,246 @@
911 +# Copyright 1999-2022 Gentoo Authors
912 +# Distributed under the terms of the GNU General Public License v2
913 +
914 +EAPI=8
915 +
916 +PYTHON_COMPAT=( python3_{9..10} )
917 +VIRTUALX_REQUIRED="manual"
918 +
919 +inherit cmake python-single-r1 virtualx
920 +
921 +MY_PN="InsightToolkit"
922 +MY_P="${MY_PN}-${PV}"
923 +GLI_HASH="89da9305f5750d3990ca9fd35ecc5ce0b39c71a6"
924 +TEST_HASH="7ab9d41ad5b42ccbe8adcaf0b24416d439a264d0"
925 +declare -a GLI_TEST_HASHES=(
926 + "a5e11ea71164ff78c65fcf259db01ea5db981a9d868e60045ff2bffca92984df1174bf984a1076e450f0d5d69b4f0191ed1a61465c220e2c91a893b5df150c0a"
927 + "bcdbb347f3704262d1f00be7179d6a0a6e68aed56c0653e8072ee5a94985c713bd229c935b1226a658af84fb7f1fffc2458c98364fc35303a2303b12f9f7ce2f"
928 +)
929 +
930 +GLI_TEST_SRC=""
931 +for i in "${GLI_TEST_HASHES[@]}"; do
932 + GLI_TEST_SRC+="https://data.kitware.com/api/v1/file/hashsum/sha512/${i}/download -> ${PN}-test-${i} "
933 +done
934 +
935 +DESCRIPTION="NLM Insight Segmentation and Registration Toolkit"
936 +HOMEPAGE="https://itk.org"
937 +SRC_URI="
938 + https://github.com/InsightSoftwareConsortium/ITK/releases/download/v${PV}/${MY_P}.tar.gz
939 + https://github.com/InsightSoftwareConsortium/ITKGenericLabelInterpolator/archive/${GLI_HASH}.tar.gz -> ITKGenericLabelInterpolator-${PV}.tar.gz
940 + test? (
941 + https://github.com/InsightSoftwareConsortium/ITK/releases/download/v${PV}/InsightData-${PV}.tar.gz
942 + https://github.com/InsightSoftwareConsortium/ITKTestingData/archive/${TEST_HASH}.tar.gz -> ${P}-testingdata.tar.gz
943 + ${GLI_TEST_SRC}
944 + )
945 + "
946 +
947 +LICENSE="Apache-2.0"
948 +SLOT="0"
949 +KEYWORDS="~amd64 ~x86"
950 +IUSE="debug doc examples fftw itkv4-compat python review test vtkglue"
951 +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
952 +
953 +RESTRICT="!test? ( test )"
954 +
955 +RDEPEND="
956 + dev-cpp/eigen:3
957 + dev-libs/double-conversion:0=
958 + dev-libs/expat:0=
959 + media-libs/openjpeg:2
960 + media-libs/libpng:0=
961 + media-libs/tiff:0=[jpeg]
962 + sci-libs/dcmtk:0=
963 + sci-libs/hdf5:0=[cxx]
964 + sci-libs/gdcm:0=
965 + sys-libs/zlib:0=
966 + media-libs/libjpeg-turbo:0=
967 + fftw? ( sci-libs/fftw:3.0= )
968 + vtkglue? (
969 + sci-libs/vtk:0=[rendering]
970 + python? (
971 + sci-libs/vtk:0=[python,${PYTHON_SINGLE_USEDEP}]
972 + )
973 + )
974 + python? ( ${PYTHON_DEPS} )
975 +"
976 +DEPEND="${RDEPEND}
977 + sys-apps/coreutils
978 + python? (
979 + >=dev-lang/swig-2.0:0
980 + dev-libs/castxml
981 + )
982 + doc? ( app-doc/doxygen )
983 +"
984 +BDEPEND="
985 + test? (
986 + vtkglue? ( ${VIRTUALX_DEPEND} )
987 + python? (
988 + $(python_gen_cond_dep 'dev-python/numpy[${PYTHON_USEDEP}]')
989 + )
990 + )
991 +"
992 +
993 +S="${WORKDIR}/${MY_P}"
994 +
995 +PATCHES=(
996 + "${FILESDIR}/${P}-upstream-fixes.patch"
997 + "${FILESDIR}/${P}-system-tiff-has-64.patch"
998 + "${FILESDIR}/${P}-fix-castxml-clang-attr-malloc.patch"
999 + "${FILESDIR}/${P}-system-openjpeg.patch"
1000 +)
1001 +
1002 +pkg_pretend() {
1003 + if [[ -z ${ITK_COMPUTER_MEMORY_SIZE} ]]; then
1004 + elog "To tune ITK to make the best use of working memory you can set"
1005 + elog " ITK_COMPUTER_MEMORY_SIZE=XX"
1006 + elog "in make.conf, default is 1 (unit is GB)"
1007 + fi
1008 + if use python && [[ -z ${ITK_WRAP_DIMS} ]]; then
1009 + elog "For Python language bindings, you can define the dimensions"
1010 + elog "you want to create bindings for by setting"
1011 + elog " ITK_WRAP_DIMS=X;Y;Z..."
1012 + elog "in make.conf, default is 2;3 for 2D and 3D data"
1013 + fi
1014 +}
1015 +
1016 +src_prepare() {
1017 + # drop bundled libs
1018 + local -a DROPS=(
1019 + DoubleConversion/src/double-conversion
1020 + Eigen3/src/itkeigen
1021 + Expat/src/expat
1022 + GDCM/src/gdcm
1023 + JPEG/src/itkjpeg
1024 + HDF5/src/itkhdf5
1025 + OpenJPEG/src/openjpeg
1026 + PNG/src/itkpng
1027 + TIFF/src/itktiff
1028 + ZLIB/src/itkzlib
1029 + )
1030 + local x
1031 + for x in "${DROPS[@]}"; do
1032 + ebegin "Dropping bundled ${x%%/*}"
1033 + rm -r "Modules/ThirdParty/${x}" || die
1034 + eend $?
1035 + done
1036 + {
1037 + find Modules/ThirdParty -mindepth 2 -maxdepth 2 -type d -name src -printf '%P\n'
1038 + printf '%s\n' "${DROPS[@]}" | sed 's,/[^/]*$,,'
1039 + } | sort | uniq -u | xargs -n 1 ewarn "Using bundled" || die
1040 +
1041 + # Remote modules
1042 + ln -sr "../ITKGenericLabelInterpolator-${GLI_HASH}" Modules/External/ITKGenericLabelInterpolator || die
1043 +
1044 + cmake_src_prepare
1045 +
1046 + if use test; then
1047 + cp -rf "../ITKTestingData-${TEST_HASH}/"* ".ExternalData/" || die
1048 + mv "../ITKTestingData-${TEST_HASH}" "${BUILD_DIR}/.ExternalData" || die
1049 + for i in "${GLI_TEST_HASHES[@]}"; do
1050 + cp "${DISTDIR}/${PN}-test-${i}" ".ExternalData/SHA512/${i}" || die
1051 + cp "${DISTDIR}/${PN}-test-${i}" "${BUILD_DIR}/.ExternalData/SHA512/${i}" || die
1052 + done
1053 + fi
1054 +}
1055 +
1056 +src_configure() {
1057 + local mycmakeargs=(
1058 + -DITK_BUILD_DOCUMENTATION="$(usex doc ON OFF)"
1059 + -DITK_INSTALL_DOC_DIR="share/doc/${P}"
1060 + -DBUILD_EXAMPLES="$(usex examples ON OFF)"
1061 + -DBUILD_SHARED_LIBS=ON
1062 + -DBUILD_TESTING="$(usex test ON OFF)"
1063 + -Ddouble-conversion_INCLUDE_DIRS="${EPREFIX}/usr/include/double-conversion"
1064 + -DExternalData_OBJECT_STORES="${WORKDIR}/InsightToolkit-${PV}/.ExternalData"
1065 + -DGDCM_USE_SYSTEM_OPENJPEG=ON
1066 + -DITK_FORBID_DOWNLOADS:BOOL=ON
1067 + -DITK_INSTALL_LIBRARY_DIR=$(get_libdir)
1068 + -DITK_USE_REVIEW="$(usex review ON OFF)"
1069 + -DITK_USE_SYSTEM_DCMTK=ON
1070 + -DITK_USE_SYSTEM_DOUBLECONVERSION=ON
1071 + -DITK_USE_SYSTEM_CASTXML=ON
1072 + -DITK_USE_SYSTEM_EIGEN=ON
1073 + -DITK_USE_SYSTEM_EXPAT=ON
1074 + -DITK_USE_SYSTEM_GDCM=ON
1075 + -DITK_USE_SYSTEM_HDF5=ON
1076 + -DITK_USE_SYSTEM_JPEG=ON
1077 + -DITK_USE_SYSTEM_OPENJPEG=ON
1078 + -DITK_USE_SYSTEM_PNG=ON
1079 + -DITK_USE_SYSTEM_SWIG=ON
1080 + -DITK_USE_SYSTEM_TIFF=ON
1081 + -DITK_USE_SYSTEM_ZLIB=ON
1082 + -DITK_USE_KWSTYLE=OFF
1083 + -DITK_BUILD_DEFAULT_MODULES=ON
1084 + -DITK_COMPUTER_MEMORY_SIZE="${ITK_COMPUTER_MEMORY_SIZE:-1}"
1085 + -DModule_GenericLabelInterpolator:BOOL=ON
1086 + -DModule_ITKReview:BOOL=ON
1087 + -DWRAP_ITK_JAVA=OFF
1088 + -DWRAP_ITK_TCL=OFF
1089 + -DITKV4_COMPATIBILITY:BOOL=$(usex itkv4-compat)
1090 + )
1091 + if use fftw; then
1092 + mycmakeargs+=(
1093 + -DUSE_FFTWD=ON
1094 + -DUSE_FFTWF=ON
1095 + -DUSE_SYSTEM_FFTW=ON
1096 + -DITK_WRAP_double=ON
1097 + -DITK_WRAP_vector_double=ON
1098 + -DITK_WRAP_covariant_vector_double=ON
1099 + -DITK_WRAP_complex_double=ON
1100 + )
1101 + fi
1102 + if use vtkglue; then
1103 + mycmakeargs+=(
1104 + -DModule_ITKVtkGlue=ON
1105 + )
1106 + fi
1107 + if use python; then
1108 + mycmakeargs+=(
1109 + -DITK_WRAP_PYTHON=ON
1110 + -DPython3_EXECUTABLE="${PYTHON}"
1111 + -DITK_WRAP_DIMS="${ITK_WRAP_DIMS:-2;3}"
1112 + )
1113 + else
1114 + mycmakeargs+=(
1115 + -DITK_WRAP_PYTHON=OFF
1116 + )
1117 + fi
1118 + cmake_src_configure
1119 +}
1120 +
1121 +src_install() {
1122 + cmake_src_install
1123 +
1124 + if use examples; then
1125 + docinto examples
1126 + docompress -x /usr/share/doc/${PF}/examples
1127 + dodoc -r "${S}"/Examples/*
1128 + fi
1129 +
1130 + echo "ITK_DATA_ROOT=${EPREFIX}/usr/share/${PN}/data" > ${T}/40${PN} || die
1131 + local ldpath="${EPREFIX}/usr/$(get_libdir)/InsightToolkit"
1132 + if use python; then
1133 + echo "PYTHONPATH=${EPREFIX}/usr/$(get_libdir)/InsightToolkit/WrapITK/Python" >> "${T}"/40${PN} || die
1134 + ldpath="${ldpath}:${EPREFIX}/usr/$(get_libdir)/InsightToolkit/WrapITK/lib"
1135 + fi
1136 + echo "LDPATH=${ldpath}" >> "${T}"/40${PN} || die
1137 + doenvd "${T}"/40${PN}
1138 +
1139 + if use doc; then
1140 + cd "${WORKDIR}"/html || die
1141 + rm *.md5 || die "Failed to remove superfluous hashes"
1142 + einfo "Installing API docs. This may take some time."
1143 + docinto api-docs
1144 + dodoc -r *
1145 + fi
1146 +
1147 + use python && python_optimize
1148 +}
1149 +
1150 +src_test() {
1151 + if use vtkglue; then
1152 + virtx cmake_src_test
1153 + else
1154 + cmake_src_test
1155 + fi
1156 +}