# Disable LTO - causes linker issues with VTK on Fedora 43+ %global _lto_cflags %{nil} %global commit 1407f01043d0df0cecbf6a0655d23a8f8833d4ff %global shortcommit %(c=%{commit}; echo ${c:0:8}) %global snapdate 20260603 Name: vtkAddon Version: 0.1.0 Release: 0.5.%{snapdate}git%{shortcommit}%{?dist} Summary: VTK extension classes for 3D Slicer # 3D Slicer Contribution and Software License Agreement (BSD-style) License: 3D-Slicer-1.0 URL: https://github.com/Slicer/vtkAddon Source0: %{url}/archive/%{commit}/%{name}-%{shortcommit}.tar.gz # https://fedoraproject.org/wiki/Changes/EncourageI686LeafRemoval ExcludeArch: %{ix86} BuildRequires: cmake >= 3.20 BuildRequires: gcc-c++ BuildRequires: make BuildRequires: vtk-devel # Python wrapping: the VTK_WRAP_PYTHON3 macro needs the wrapper tool from # vtk-devel plus the VTK python link libs (python3-vtk) and Python headers. BuildRequires: python3-vtk # VTK cmake config transitive deps (COPR vtk-devel doesn't Require these) BuildRequires: python3-devel BuildRequires: json-devel BuildRequires: jsoncpp-devel BuildRequires: hdf5-devel BuildRequires: utf8cpp-devel BuildRequires: fmt-devel BuildRequires: libglvnd-devel BuildRequires: libtheora-devel BuildRequires: libogg-devel BuildRequires: libjpeg-turbo-devel BuildRequires: libpng-devel BuildRequires: libtiff-devel BuildRequires: freetype-devel BuildRequires: fontconfig-devel BuildRequires: expat-devel BuildRequires: lz4-devel BuildRequires: xz-devel BuildRequires: zlib-devel BuildRequires: sqlite-devel BuildRequires: libxml2-devel BuildRequires: netcdf-devel BuildRequires: pugixml-devel BuildRequires: proj-devel BuildRequires: tbb-devel BuildRequires: qt6-qtbase-devel BuildRequires: qt6-qtdeclarative-devel BuildRequires: PEGTL-devel BuildRequires: libharu-devel BuildRequires: gl2ps-devel BuildRequires: double-conversion-devel BuildRequires: eigen3-devel BuildRequires: cli11-devel BuildRequires: boost-devel BuildRequires: gdal-devel BuildRequires: postgresql-server-devel # Pin the exact VTK ABI this package was built against. VTK freezes its soname at # libvtk*.so.1 across all of 9.x, so rpm cannot tell 9.5 from 9.6 from 9.7: a consumer # built against one installs cleanly against another and fails at LOAD with undefined # symbols. A >= floor does not help -- 9.7.0 satisfies >= 9.6.2 -- so this is an exact # match. %%vtk_abi comes from vtk-devel's macros.vtk, so it re-pins on every rebuild. # # The missing-macro check lives in %%build, deliberately, NOT at parse time. A # parse-time %%error cannot distinguish "COPR is generating the SRPM" from "this is a # real buildroot": rpkg srpm parses the spec with no buildroot and therefore no # vtk-devel, so a parse-time guard killed every SCM build of every guarded package # before any chroot existed (python-simpleitk 10980296 failed in 0 minutes with # "can't parse specfile"). Expanding to UNSET keeps the SRPM parse alive, and the # %%build test still fails loudly in a buildroot lacking vtk-devel, so no RPM carrying # the placeholder can ever be produced. Requires: vtk(abi) = %{?vtk_abi}%{!?vtk_abi:UNSET} %description vtkAddon provides general-purpose VTK extension classes that may be integrated into VTK library in the future. These include spline generators, oriented transforms, streaming volume codecs, and other utilities used by 3D Slicer and related applications. %package devel Summary: Development files for %{name} Requires: %{name}%{?_isa} = %{version}-%{release} Requires: vtk-devel %description devel Development headers and CMake config files for building applications that use %{name}. %package -n python3-vtkAddon Summary: Python bindings for %{name} Requires: %{name}%{?_isa} = %{version}-%{release} Requires: python3-vtk %description -n python3-vtkAddon VTK Python wrapper (vtkAddonPython) for the vtkAddon classes. Required by 3D Slicer's Python environment, whose bin/Python/vtkAddon.py does "from vtkAddonPython import *". %prep %autosetup -n %{name}-%{commit} # Fix cmake minimum version for CMake 4 compatibility sed -i 's|cmake_minimum_required(VERSION 3.20.6)|cmake_minimum_required(VERSION 3.20.6...3.31)|' CMakeLists.txt # Library and cmake config install paths are fixed via cmake flags below # (upstream uses ${PROJECT_NAME} in variable names, making sed unreliable) %build # vtk_abi comes from vtk-devel's macros.vtk. Absent means BuildRequires: vtk-devel is # missing, and the Requires above would ship as the vacuous "vtk(abi) = UNSET". test -n "%{?vtk_abi}" || { echo "ERROR: vtk_abi undefined - add 'BuildRequires: vtk-devel'" >&2; exit 1; } # GCC 15 / Fedora 43+ fixes export CXXFLAGS="$(echo "%{optflags}" | sed 's/-flto=auto//') -std=c++17 -include cstdint" export CFLAGS="$(echo "%{optflags}" | sed 's/-flto=auto//') -std=gnu17" %cmake \ -DBUILD_SHARED_LIBS=ON \ -DBUILD_TESTING=OFF \ -DCMAKE_CXX_STANDARD=17 \ -DCMAKE_CXX_STANDARD_REQUIRED=ON \ -DCMAKE_SKIP_INSTALL_RPATH=ON \ -DvtkAddon_INSTALL_NO_DEVELOPMENT=OFF \ -DvtkAddon_INSTALL_LIB_DIR=%{_lib} \ -DvtkAddon_INSTALL_CMAKE_DIR=%{_lib}/cmake/vtkAddon \ `# Build the VTK Python wrapper (vtkAddonPython.so). 3D Slicer's` \ `# bin/Python/vtkAddon.py does "from vtkAddonPython import *"; in a` \ `# non-superbuild RPM Slicer does NOT wrap the external vtkAddon, so` \ `# the module must come from this package (3dslicer bug #9c). Install` \ `# it into the system sitearch, which Slicer's embedded interpreter` \ `# already has on sys.path (numpy/SimpleITK load from there).` \ -DVTK_WRAP_PYTHON:BOOL=ON \ -DvtkAddon_WRAP_PYTHON:BOOL=ON \ -DvtkAddon_INSTALL_PYTHON_MODULE_LIB_DIR:PATH=%{python3_sitearch} \ -DvtkAddon_INSTALL_PYTHON_LIB_DIR:PATH=%{python3_sitearch} %cmake_build %install %cmake_install %files %license LICENSE %doc README.md %{_libdir}/libvtkAddon.so %files devel %{_includedir}/vtkAddon/ %{_libdir}/cmake/vtkAddon/ %files -n python3-vtkAddon %{python3_sitearch}/vtkAddonPython.so %changelog * Sun Aug 23 2026 Morgan Hough - 0.1.0-0.4.20260603git1407f010 - Rebuild against VTK 9.7.0. VTK here installs unversioned sonames (libvtk*.so.1), so 9.7 replaces 9.6 in place and every consumer must be rebuilt or it fails at runtime with undefined symbols. * Wed Jun 17 2026 Morgan Hough - 0.1.0-0.3.20260603git1407f010 - Bump to master 1407f010: the previous pin (2ed3e222, Dec 2025) predates install(EXPORT vtkAddonTargets), so vtkAddonTargets.cmake was never shipped and consumers that include() it (IGSIO) failed. Master ships it; also closer to the packaged Slicer commit. Unblocks the SlicerIGT (igsio) chain. * Sat Jun 13 2026 Morgan Hough - 0.1.0-0.2.20251224git2ed3e222 - Fix 3D Slicer bug #9c: build the VTK Python wrapper. Enable vtkAddon_WRAP_PYTHON (vtkMacroKitPythonWrap) and ship vtkAddonPython.so in a new python3-vtkAddon subpackage, installed into %{python3_sitearch}. Slicer's bin/Python/vtkAddon.py does "from vtkAddonPython import *"; in a non-superbuild RPM Slicer doesn't wrap the external vtkAddon, so the module never existed and "import vtkAddon" failed. sitearch is already on Slicer's embedded sys.path. * Wed Mar 04 2026 Morgan Hough - 0.1.0-0.1.20251224git2ed3e22 - Initial package (git snapshot for VTK 9.6 compatibility) - VTK extension classes for 3D Slicer