Skip to content

Commit 157f602

Browse files
committed
Add the project option LAPACK_BINARY_PATH_SUFFIX
It names a subdirectory added to the install location of all LAPACK binaries. It is empty by default. This allows a consumer, to install the Reference LAPACK binaries into a subdirectory of, e.g., `/usr/local/lib` without inadvertantly changing the install location of the CMake package scripts, which remain unchanged in `/usr/local/lib/cmake`. This can be necessary to avoid conflicts with other BLAS/LAPACK distributions. Previously, this would require the consumer to override `CMAKE_INSTALL_LIBDIR` directly. This shouldn't be done, though, because the variable is provided by the core CMake module GNUInstallDirs and is used in many places. Thus, changing it can have unforeseen consequences. Here, overriding it also changed the install locations of the CMake package scripts and PKGConfig files, which prevents them from being discovered by default by their respective tools.
1 parent c4a1f76 commit 157f602

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

CMakeLists.txt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,18 @@ endif()
159159
# --------------------------------------------------
160160
set(LAPACK_INSTALL_EXPORT_NAME ${LAPACKLIB}-targets)
161161

162+
set(LAPACK_BINARY_PATH_SUFFIX "" CACHE STRING "Path suffix appended to the install path of binaries")
163+
164+
if(NOT "${LAPACK_BINARY_PATH_SUFFIX}" STREQUAL "" AND NOT "${LAPACK_BINARY_PATH_SUFFIX}" MATCHES "^/")
165+
set(LAPACK_BINARY_PATH_SUFFIX "/${LAPACK_BINARY_PATH_SUFFIX}")
166+
endif()
167+
162168
macro(lapack_install_library lib)
163169
install(TARGETS ${lib}
164170
EXPORT ${LAPACK_INSTALL_EXPORT_NAME}
165-
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development
166-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT RuntimeLibraries
167-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT RuntimeLibraries
171+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}${LAPACK_BINARY_PATH_SUFFIX}" COMPONENT Development
172+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}${LAPACK_BINARY_PATH_SUFFIX}" COMPONENT RuntimeLibraries
173+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}${LAPACK_BINARY_PATH_SUFFIX}" COMPONENT RuntimeLibraries
168174
)
169175
endmacro()
170176

@@ -557,7 +563,7 @@ install(FILES
557563
if (LAPACK++)
558564
install(
559565
DIRECTORY "${LAPACK_BINARY_DIR}/lib/"
560-
DESTINATION ${CMAKE_INSTALL_LIBDIR}
566+
DESTINATION "${CMAKE_INSTALL_LIBDIR}${LAPACK_BINARY_PATH_SUFFIX}"
561567
FILES_MATCHING REGEX "liblapackpp.(a|so)$"
562568
)
563569
install(
@@ -590,7 +596,7 @@ if (BLAS++)
590596
)
591597
install(
592598
DIRECTORY "${LAPACK_BINARY_DIR}/lib/"
593-
DESTINATION ${CMAKE_INSTALL_LIBDIR}
599+
DESTINATION "${CMAKE_INSTALL_LIBDIR}${LAPACK_BINARY_PATH_SUFFIX}"
594600
FILES_MATCHING REGEX "libblaspp.(a|so)$"
595601
)
596602
install(

0 commit comments

Comments
 (0)