Reference-ScaLAPACK / scalapack

ScaLAPACK development repository
Other
132 stars 59 forks source link

use CMAKE_INSTALL_LIBDIR to allow for library installation in multiarch contexts #87

Open drew-parsons opened 1 year ago

drew-parsons commented 1 year ago

The scalapack library gets installed in /usr/lib (or /usr/lib64, if LIB_SUFFIX=64), defined in the SCALAPACK_install_library macro at https://github.com/Reference-ScaLAPACK/scalapack/blob/2072b8602f0a5a84d77a712121f7715c58a2e80d/CMakeLists.txt#L83

Some systems provide a multiarch library installation, for instance installing amd64 libraries into /usr/lib/x86_64-linux-gnu rather than /usr/lib. This allows the same filesystem to be shared with multiple systems. Debian and Ubuntu, for instance, provide multiarch installations.

Cmake provides flexibility to manage both types of installation via the CMAKE_INSTALL_LIBDIR variable. This can be easily done for scalapack by replacing

    LIBRARY DESTINATION lib${LIB_SUFFIX}

with

    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LIB_SUFFIX}

In the "default" case CMAKE_INSTALL_LIBDIR is set to lib, so nothing would change, see https://cmake.org/cmake/help/latest/command/install.html#directory

Systems that need the multiarch location can get it by adding GNUInstallDirs

include(GNUInstallDirs)

Scalapack could perhaps add a configuration variable to choose whether to include it or not.

CMAKE_INSTALL_LIBDIR could then also be used instead of lib for the pkg-config and cmake file installations at ll.124,330,334 (perhaps the libdir variable at l.124 is redundant). It would also want to be applied to ARCHIVE at l.82.

If the multiarch (GNUInstallDirs) destination is activated then probably LIB_SUFFIX should be left empty. But that's a matter for the build configuration, LIB_SUFFIX handling in CMakeLists.txt would not need to be specifically changed.

An example of this kind of patch has been applied to the debian builds (2.2.1-3), build logs at https://buildd.debian.org/status/package.php?p=scalapack

drew-parsons commented 1 year ago

I'd be interested also to hear from Redhat maintainers and Windows users what the impact would be of simply always having include(GNUInstallDirs). I suspect cmake is smart enough for it not to actually be a problem if it's always used.