git: 8f5541298099 - main - devel/gdcm: Use latest VTK-9 instead of ancient VTK-6; Add USES=python

From: Stephen Montgomery-Smith <stephen_at_FreeBSD.org>
Date: Sun, 26 Jun 2022 23:09:17 UTC
The branch main has been updated by stephen:

URL: https://cgit.FreeBSD.org/ports/commit/?id=8f5541298099b722e34632ca9ed388bda91064e7

commit 8f5541298099b722e34632ca9ed388bda91064e7
Author:     Stephen Montgomery-Smith <stephen@FreeBSD.org>
AuthorDate: 2022-06-26 23:03:43 +0000
Commit:     Stephen Montgomery-Smith <stephen@FreeBSD.org>
CommitDate: 2022-06-26 23:03:43 +0000

    devel/gdcm: Use latest VTK-9 instead of ancient VTK-6; Add USES=python
    
    Bump portrevision.
    
    PR:             264917
    Reported by:    yuri@freebsd.org
---
 devel/gdcm/Makefile                                | 29 +++++++++++++---------
 ...ilities_VTK_vtkImageMapToWindowLevelColors2.cxx | 13 ++++++++++
 .../files/patch-Wrapping_Python_CMakeLists.txt     | 15 +++++++++++
 3 files changed, 45 insertions(+), 12 deletions(-)

diff --git a/devel/gdcm/Makefile b/devel/gdcm/Makefile
index ed25fcdf768d..8ec698fca3c1 100644
--- a/devel/gdcm/Makefile
+++ b/devel/gdcm/Makefile
@@ -2,6 +2,7 @@
 
 PORTNAME=	gdcm
 PORTVERSION=	${GDCM_MAJOR}.${GDCM_MINOR}.${GDCM_PATCH}
+PORTREVISION=	1
 CATEGORIES=	devel
 MASTER_SITES=	SF/gdcm/gdcm%20${GDCM_MAJOR}.x/GDCM%20${PORTVERSION}
 
@@ -13,17 +14,20 @@ LICENSE=	BSD3CLAUSE
 LIB_DEPENDS=	libopenjp2.so:graphics/openjpeg \
 		libexpat.so:textproc/expat2
 
-USES=		alias cmake compiler:c++11-lang pkgconfig tar:bzip2 ssl
+USES=		alias cmake compiler:c++11-lang pkgconfig python:build tar:bzip2 ssl
+USE_LDCONFIG=	yes
 
-OPTIONS_DEFINE=		VTK6
+OPTIONS_DEFINE=		VTK
 OPTIONS_SUB=		yes
 
-VTK6_DESC=		Build VTK 6 integration classes
-VTK6_LIB_DEPENDS=	libvtkCommonCore-${VTK6_VERSION}.so:math/vtk6
-VTK6_CMAKE_ON=		-DGDCM_USE_VTK:BOOL=ON \
-			-DVTK_DIR:PATH=${LOCALBASE}/lib/vtk-${VTK6_VERSION}
-VTK6_USES=		gl
-VTK6_USE=		GL=glu
+VTK_DESC=		Build VTK integration classes
+VTK_CXXFLAGS=		-I${LOCALBASE}/include/vtk-${VTK_VERSION}
+VTK_LIB_DEPENDS=	libvtkCommonCore-${VTK_VERSION}.so:math/vtk${VTK_VERSION:R}
+VTK_CMAKE_ON=		-DGDCM_USE_VTK:BOOL=ON \
+			-DVTK_DIR:PATH=${LOCALBASE}/lib/vtk-${VTK_VERSION}
+VTK_USES=		gl
+VTK_USE=		GL=glu
+#VTK_BROKEN=		Fails to compile with VTK-9.1, see https://sourceforge.net/p/gdcm/bugs/537/
 
 # Change this when updating the port
 GDCM_MAJOR=	3
@@ -31,9 +35,8 @@ GDCM_MINOR=	0
 GDCM_PATCH=	14
 
 # Change this whenever VTK is updated
-VTK6_VERSION=	6.2
+VTK_VERSION=	9.1
 
-USE_LDCONFIG=	yes
 CFLAGS+=	-I${LOCALBASE}/include
 CMAKE_ARGS=	-DGDCM_USE_SYSTEM_OPENSSL:BOOL=ON \
 		-DGDCM_USE_SYSTEM_EXPAT:BOOL=ON \
@@ -44,11 +47,13 @@ CMAKE_ARGS=	-DGDCM_USE_SYSTEM_OPENSSL:BOOL=ON \
 		-DGDCM_BUILD_EXAMPLES:BOOL=OFF \
 		-DGDCM_INSTALL_DATA_DIR:PATH=${DATADIR_REL} \
 		-DGDCM_DOCUMENTATION:BOOL=OFF \
-		-DGDCM_BUILD_DOCBOOK_MANPAGES:BOOL=OFF
+		-DGDCM_BUILD_DOCBOOK_MANPAGES:BOOL=OFF \
+		-DPython3_EXECUTABLE=${PYTHON_CMD} \
+		-DGDCM_DEFAULT_PYTHON_VERSION=${PYTHON_VER}
 
 .include <bsd.port.options.mk>
 
-.if ${PORT_OPTIONS:MVTK6}
+.if ${PORT_OPTIONS:MVTK}
 DESKTOP_ENTRIES="Gdcmviewer" "Simple DICOM Viewer" "" "gdcmviewer" "" ""
 PLIST_SUB+=	VTK=""
 .else
diff --git a/devel/gdcm/files/patch-Utilities_VTK_vtkImageMapToWindowLevelColors2.cxx b/devel/gdcm/files/patch-Utilities_VTK_vtkImageMapToWindowLevelColors2.cxx
new file mode 100644
index 000000000000..74ffcd464f6a
--- /dev/null
+++ b/devel/gdcm/files/patch-Utilities_VTK_vtkImageMapToWindowLevelColors2.cxx
@@ -0,0 +1,13 @@
+- workaround for https://sourceforge.net/p/gdcm/bugs/536/
+
+--- Utilities/VTK/vtkImageMapToWindowLevelColors2.cxx.orig	2022-06-26 20:39:45 UTC
++++ Utilities/VTK/vtkImageMapToWindowLevelColors2.cxx
+@@ -37,6 +37,8 @@
+ #include "vtkScalarsToColors.h"
+ #include "vtkPointData.h"
+ 
++#include <math.h>
++
+ //vtkCxxRevisionMacro(vtkImageMapToWindowLevelColors2, "$Revision: 1.3 $")
+ vtkStandardNewMacro(vtkImageMapToWindowLevelColors2)
+ 
diff --git a/devel/gdcm/files/patch-Wrapping_Python_CMakeLists.txt b/devel/gdcm/files/patch-Wrapping_Python_CMakeLists.txt
new file mode 100644
index 000000000000..922d601e6df6
--- /dev/null
+++ b/devel/gdcm/files/patch-Wrapping_Python_CMakeLists.txt
@@ -0,0 +1,15 @@
+- Choose exact Python version, see https://sourceforge.net/p/gdcm/bugs/538/
+
+--- Wrapping/Python/CMakeLists.txt.orig	2022-06-26 20:16:42 UTC
++++ Wrapping/Python/CMakeLists.txt
+@@ -48,8 +48,8 @@ include_directories(
+   ${CMAKE_CURRENT_SOURCE_DIR}
+ )
+ 
+-find_package(PythonInterp ${GDCM_DEFAULT_PYTHON_VERSION} REQUIRED)
+-find_package(PythonLibs ${GDCM_DEFAULT_PYTHON_VERSION} REQUIRED)
++find_package(PythonInterp ${GDCM_DEFAULT_PYTHON_VERSION} EXACT REQUIRED)
++find_package(PythonLibs ${GDCM_DEFAULT_PYTHON_VERSION} EXACT REQUIRED)
+ # TODO Need to check consistency python interp and python libs...
+ mark_as_advanced(PYTHON_LIBRARY PYTHON_INCLUDE_PATH)
+ # Lamest excuse ever: