Skip to content

Allow installing binaries to subdirectory while keeping CMake package scripts in the same place #1008

Description

@lepus2589

Currently, both compiled binaries and CMake package scripts are installed to the same location using the CMake variable ${CMAKE_INSTALL_LIBDIR} (CMake scripts go to the subdirectory cmake). If you want to install the binaries to a subdirectory (e. g. /usr/local/lib/lapack to avoid conflicts with other distributions), you have to modify this variable from the command line. Unfortunately, because the CMake scripts also use this variable, their install location changes to /usr/local/lib/lapack/cmake. This is a non-standard location that will not be automatically picked up by CMake.

Proposed new feature: Please support installing the binaries to a subdirectory of ${CMAKE_INSTALL_LIBDIR} while keeping the CMake package scripts in the same, default-discoverable location.

Possible solutions: Introduce project variables for the binary and/or the CMake script install location, that can be individually overridden by the consumer.

Personally, I think it's a bad idea to force the user to override a variable that is provided by the CMake module GNUInstallDirs, if they want to customize the install location. This can have unforeseen consequences.

Thus, I would propose to change this macro to not use ${CMAKE_INSTALL_LIBDIR} and ${CMAKE_INSTALL_BINDIR} directly. Either, one could introduce two new project options containing the binary install paths relative to the install prefix, defaulting to the current values. Or one could introduce a $LAPACK_BINARY_PATH_SUFFIX project option (PATH SUFFIX is the wording CMake uses in their documentation of find_package()) defaulting to the empty string and append that to the current values.

I'm happy to provide a PR, but I'll wait for feedback first.

Activity

  1. langou commented on Apr 12, 2024

    @langou
    Contributor

    Hi @lepus2589, I do not have a strong understanding of all this, so if no one expresses a negative opinion, I'll be happy to review, approve and merge your PR. Overall, this sounds reasonable, and this sounds great, so thanks a lot for making the suggestion and volunteering for a PR. Much appreciated. So if no one expresses concerns, then, yes please by all means, we would be happy to review a PR on this issue from you. If someone expresses concerns, we can discuss some more. Julien.

  2. changed the title [-]Allow installing of binaries to subdirectory while keeping CMake package scripts in the same place[/-] [+]Allow installing binaries to subdirectory while keeping CMake package scripts in the same place[/+] on Apr 17, 2024
  3. added a commit that references this issue on Apr 17, 2024
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