Reference-LAPACK / lapack

LAPACK development repository
Other
1.46k stars 430 forks source link

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

Closed lepus2589 closed 3 months ago

lepus2589 commented 3 months ago

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.

langou commented 3 months ago

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.