1- cmake_minimum_required (VERSION 3.9 )
1+ cmake_minimum_required (VERSION 3.13 )
22
33project (LAPACK)
44
@@ -107,9 +107,18 @@ else()
107107 set (LAPACKELIB "lapacke" )
108108 set (TMGLIB "tmglib" )
109109endif ()
110- # By default build extended _64 API for supported compilers only
110+
111+ # By default build extended _64 API for supported compilers only. This needs
112+ # CMake >= 3.18! Let's disable it by default for CMake < 3.18.
113+ if (CMAKE_VERSION VERSION_LESS "3.18" )
114+ set (INDEX64_EXT_API_DEFAULT OFF )
115+ else ()
116+ set (INDEX64_EXT_API_DEFAULT ON )
117+ endif ()
111118set (INDEX64_EXT_API_COMPILERS "Intel|GNU" )
112- option (BUILD_INDEX64_EXT_API "Build Index-64 API as extended API with _64 suffix" ON )
119+ option (BUILD_INDEX64_EXT_API
120+ "Build Index-64 API as extended API with _64 suffix (needs CMake >= 3.18)"
121+ ${INDEX64_EXT_API_DEFAULT} )
113122message (STATUS "Build Index-64 API as extended API with _64 suffix: ${BUILD_INDEX64_EXT_API} " )
114123
115124include (GNUInstallDirs)
@@ -119,13 +128,22 @@ include(GNUInstallDirs)
119128# the OSX RPATH settings have been updated per recommendations found
120129# in the CMake Wiki:
121130# http://www.cmake.org/Wiki/CMake_RPATH_handling#Mac_OS_X_and_the_RPATH
122- set (CMAKE_MACOSX_RPATH ON )
123- set (CMAKE_SKIP_BUILD_RPATH FALSE )
124- set (CMAKE_BUILD_WITH_INSTALL_RPATH FALSE )
131+ option (CMAKE_MACOSX_RPATH "Enable macOS RPATH" ON )
132+ message (STATUS "Enable macOS RPATH: ${CMAKE_MACOSX_RPATH} " )
133+ option (CMAKE_SKIP_BUILD_RPATH "Skip build-time RPATH" OFF )
134+ message (STATUS "Skip build-time RPATH: ${CMAKE_SKIP_BUILD_RPATH} " )
135+ option (CMAKE_BUILD_WITH_INSTALL_RPATH "Build with install RPATH" OFF )
136+ message (STATUS "Build with install RPATH: ${CMAKE_BUILD_WITH_INSTALL_RPATH} " )
137+
125138list (FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES ${CMAKE_INSTALL_FULL_LIBDIR} isSystemDir)
126- if ("${isSystemDir} " STREQUAL "-1" )
127- set (CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR} )
128- set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
139+
140+ if ("${isSystemDir} " STREQUAL "-1" )
141+ if (${CMAKE_INSTALL_FULL_LIBDIR} )
142+ set (CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR} )
143+ endif ()
144+ message (STATUS "Install RPATH: ${CMAKE_INSTALL_RPATH} " )
145+ option (CMAKE_INSTALL_RPATH_USE_LINK_PATH "Use link path for RPATH" TRUE )
146+ message (STATUS "Install RPATH use link path: ${CMAKE_INSTALL_RPATH_USE_LINK_PATH} " )
129147endif ()
130148
131149
@@ -256,15 +274,7 @@ if(NOT BLAS_FOUND)
256274 add_subdirectory (BLAS)
257275 set (BLAS_LIBRARIES ${BLASLIB} )
258276else ()
259- set (CMAKE_EXE_LINKER_FLAGS
260- "${CMAKE_EXE_LINKER_FLAGS} ${BLAS_LINKER_FLAGS} "
261- CACHE STRING "Linker flags for executables" FORCE)
262- set (CMAKE_MODULE_LINKER_FLAGS
263- "${CMAKE_MODULE_LINKER_FLAGS} ${BLAS_LINKER_FLAGS} "
264- CACHE STRING "Linker flags for modules" FORCE)
265- set (CMAKE_SHARED_LINKER_FLAGS
266- "${CMAKE_SHARED_LINKER_FLAGS} ${BLAS_LINKER_FLAGS} "
267- CACHE STRING "Linker flags for shared libs" FORCE)
277+ add_link_options (${BLAS_LINKER_FLAGS} )
268278endif ()
269279
270280
@@ -346,15 +356,7 @@ if(NOT LATESTLAPACK_FOUND)
346356
347357 add_subdirectory (SRC)
348358else ()
349- set (CMAKE_EXE_LINKER_FLAGS
350- "${CMAKE_EXE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS} "
351- CACHE STRING "Linker flags for executables" FORCE)
352- set (CMAKE_MODULE_LINKER_FLAGS
353- "${CMAKE_MODULE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS} "
354- CACHE STRING "Linker flags for modules" FORCE)
355- set (CMAKE_SHARED_LINKER_FLAGS
356- "${CMAKE_SHARED_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS} "
357- CACHE STRING "Linker flags for shared libs" FORCE)
359+ add_link_options (${LAPACK_LINKER_FLAGS} )
358360endif ()
359361
360362if (BUILD_TESTING)
0 commit comments