Skip to content

Stage the bundled NIfTI into the library directory the superbuild installs - #249

Open
gdevenyi wants to merge 1 commit into
BIC-MNI:develop-1.9.18from
gdevenyi:nifti-staging-libdir
Open

gdevenyi wants to merge 1 commit into
BIC-MNI:develop-1.9.18from
gdevenyi:nifti-staging-libdir

Conversation

@gdevenyi

@gdevenyi gdevenyi commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Why

On Fedora, the toolkit installs a NIFTI package (share/cmake/NIFTI) that refers to archives it never installs. Each find_package(NIFTI) against such an install fails:

The imported target "NIFTI::znz" references the file
   ".../lib64/libznz.a"
but this file does not exist.

cmake-modules/BuildNIFTI.cmake stages nifti_clib into ${CMAKE_INSTALL_LIBDIR}, which is lib64 on Fedora. But the superbuild installs only lib${LIB_SUFFIX} from its staging tree (CMakeLists.txt, the INSTALL(DIRECTORY …/lib${LIB_SUFFIX}) rule). So libniftiio.a, libznz.a and libnifti2.a stay in the staging tree.

This defect is already on develop-1.9.18. Nothing loaded the NIFTI package until now, so nobody saw it. BIC-MNI/libminc#156 adds find_dependency(NIFTI) to LIBMINCConfig.cmake, and without this fix, find_package(LIBMINC) fails on each Fedora toolkit install.

What

BuildNIFTI.cmake stages into lib${LIB_SUFFIX}, the directory that the superbuild installs. This is the convention that the rest of the superbuild uses already (LIBMINC_INSTALL_LIB_DIR, CMAKE_INSTALL_RPATH, the staging install rule). The change is to CMAKE_INSTALL_LIBDIR, NIFTI_INSTALL_LIBRARY_DIR, the install RPATH, and the NIFTI_LIBRARY / ZNZ_LIBRARY paths.

Verification

Notes

  • Most other Build*.cmake modules already pass -DCMAKE_INSTALL_LIBDIR=lib${LIB_SUFFIX} (FFTW, freeglut, JPEG, netCDF, OpenBLAS). BuildOpenJPEG.cmake uses ${CMAKE_INSTALL_LIBDIR} too, so a vendored OpenJPEG on a lib64 system is also not installed. That has less effect: its archive is static and linked at build time, and its CMake package is in the same lib64/ directory, so nothing installed refers to a missing file. I left it out of this PR.
  • Merge this before, or together with, the libminc submodule bump that includes Export LIBMINC::nifti, and install the bundled NIfTI with libminc libminc#156.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RCrjXCD1KiTWLtah7wmySX

…talls

BuildNIFTI.cmake staged nifti_clib into ${CMAKE_INSTALL_LIBDIR}, which is
lib64 on Fedora. The superbuild installs only lib${LIB_SUFFIX} from its
staging tree, so on Fedora libniftiio.a, libznz.a and libnifti2.a were
never installed, while the NIFTI package in share/cmake/NIFTI was. Any
find_package(NIFTI) against such an install fails:

  The imported target "NIFTI::znz" references the file
     ".../lib64/libznz.a"
  but this file does not exist.

Stage into lib${LIB_SUFFIX}, as the rest of the superbuild does
(LIBMINC_INSTALL_LIB_DIR, CMAKE_INSTALL_RPATH, the staging install rule).

Verified: configured with -DCMAKE_INSTALL_LIBDIR=lib64 and built the NIFTI
target; the three archives are staged in lib/, and NIFTITargets refers to
lib/.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RCrjXCD1KiTWLtah7wmySX
@gdevenyi

Copy link
Copy Markdown
Contributor Author

This is currently fixing the cmake to be consistent but there's an alternative PR that makes the superbuild use CMAKE_INSTALL_LIBDIR everywhere instead, which would make it closer to standard cmake.

@gdevenyi
gdevenyi requested a review from vfonov September 23, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant