Skip to content

ITK_INSTALL_*_DIR are assumed relative to CMAKE_INSTALL_PREFIX; absolute values yield wrong paths #6896

Description

@hjmjohnson

ITK_INSTALL_RUNTIME_DIR and ITK_INSTALL_LIBRARY_DIR are joined to CMAKE_INSTALL_PREFIX in several places, so an absolute value silently yields a malformed path. CMake installs an absolute DESTINATION outside the prefix, so the two disagree.

Where the assumption is made
Site Expression
CMake/ITKModuleMacros.cmake:533 "\${ITK_INSTALL_PREFIX}/${ITK_INSTALL_RUNTIME_DIR}"
CMake/ITKModuleMacros.cmake:542 "\${ITK_INSTALL_PREFIX}/${ITK_INSTALL_LIBRARY_DIR}"
Modules/Core/TestKernel/src/CMakeLists.txt the installed itkTestDriver RPATH

The first two feed <module>_RUNTIME_LIBRARY_DIRS in the exported configuration, so a consumer of an installed ITK inherits the wrong directories, not just the test driver.

Defaults are relative (bin, and ${CMAKE_INSTALL_LIBDIR} which defaults to lib), so the supported configurations are unaffected.

What support would require

Each site needs to branch on IS_ABSOLUTE and skip the prefix join, and the exported ITKConfig would need the same treatment so that relocation logic does not rewrite a deliberately absolute path. That is a repo-wide change to the module macros and the exported configuration, which is why it is filed separately rather than folded into a single install rule.

A narrower alternative is to state in the documentation that these variables must be relative and keep the configure-time guards.

Found by an automated review on PR #6894, which added the itkTestDriver install RPATH. That PR guards its own computation with IS_ABSOLUTE and fails at configure time rather than emitting a wrong RPATH; the other two sites are unguarded.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions