Skip to content

Inconsistent install directory #87

@pasbi

Description

@pasbi

Following script:

cmake \
  -GNinja \
  -S $src  \
  -B $build \
  -DCMAKE_INSTALL_PREFIX=/tmp/bar

cmake --build $build
cmake --install $build --prefix /tmp/foo

produces following:

-- Install configuration: ""
-- Up-to-date: /tmp/foo/lib/libQGLViewer.so
-- Up-to-date: /tmp/bar/include/QGLViewer/camera.h
-- Up-to-date: /tmp/bar/include/QGLViewer/config.h
-- Up-to-date: /tmp/bar/include/QGLViewer/constraint.h
...

I.e., the library is written into the correct path supplied with --prefix in the install directive, while the headers are installed into the -DCMAKE_INSTALL_PREFIX.

The CMake documentation clearly says that --prefix in an --install directive overwrites -DCMAKE_PREFIX_PATH.

The problem is, as far as I can tell, the usage of CMAKE_INSTALL_FULL_INCLUDEDIR, which is expanded at configuration time to an absolute path.
So there's no way for --prefix to change that in a later change.
CMAKE_INSTALL_LIBDIR, however, expands only to a relative path (lib) which is properly handled by the install script later.

GNUInstallDirs documentation also warns about this issue:

These variables shouldn't be used in install() commands as they do not work with the cmake --install command's --prefix option, or with the cpack installer generators.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions