$NetBSD: patch-CMakeLists.txt,v 1.5 2021/11/23 22:45:01 wiz Exp $ Avoid installation of LAPACK CMake and pkg-config files when not installing LAPACK, also allowing explicitly to switch off LAPACK build for BLAS-only packaging. --- CMakeLists.txt.orig 2021-06-28 16:39:12.000000000 +0000 +++ CMakeLists.txt @@ -157,6 +157,9 @@ endif() # -------------------------------------------------- + +if(LAPACK) + set(LAPACK_INSTALL_EXPORT_NAME ${LAPACKLIB}-targets) macro(lapack_install_library lib) @@ -168,6 +171,18 @@ macro(lapack_install_library lib) ) endmacro() +else() + +macro(lapack_install_library lib) + install(TARGETS ${lib} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT RuntimeLibraries + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT RuntimeLibraries + ) +endmacro() + +endif() + set(PKG_CONFIG_DIR ${CMAKE_INSTALL_LIBDIR}/pkgconfig) # -------------------------------------------------- @@ -298,6 +313,10 @@ endif() option(USE_OPTIMIZED_LAPACK "Whether or not to use an optimized LAPACK library instead of included netlib LAPACK" OFF) +option(LAPACK "Whether to build or use LAPACK (to enable a BLAS-only build)") + +if(LAPACK) + # -------------------------------------------------- # LAPACK # User did not provide a LAPACK Library but specified to search for one @@ -339,6 +358,8 @@ else() CACHE STRING "Linker flags for shared libs" FORCE) endif() +endif() + if(BUILD_TESTING) add_subdirectory(TESTING) endif() @@ -464,10 +485,14 @@ if(NOT BLAS_FOUND) set(ALL_TARGETS ${ALL_TARGETS} ${BLASLIB}) endif() +if(LAPACK) if(NOT LATESTLAPACK_FOUND) set(ALL_TARGETS ${ALL_TARGETS} ${LAPACKLIB}) + set(BUILD_LAPACK ON) +endif() endif() +if(LAPACK) # Export lapack targets, not including lapacke, from the # install tree, if any. set(_lapack_config_install_guard_target "") @@ -481,6 +506,7 @@ if(ALL_TARGETS) # lapack-config.cmake to load targets from the install tree. list(GET ALL_TARGETS 0 _lapack_config_install_guard_target) endif() +endif() # Include cblas in targets exported from the build tree. if(CBLAS) @@ -496,6 +522,8 @@ if(NOT LAPACK_WITH_TMGLIB_FOUND AND LAPA set(ALL_TARGETS ${ALL_TARGETS} ${TMGLIB}) endif() +if(BUILD_LAPACK) + # Export lapack and lapacke targets from the build tree, if any. set(_lapack_config_build_guard_target "") if(ALL_TARGETS) @@ -533,6 +561,9 @@ install(FILES DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${LAPACKLIB}-${LAPACK_VERSION} COMPONENT Development ) + +endif() # BUILD_LAPACK + if (LAPACK++) install( DIRECTORY "${LAPACK_BINARY_DIR}/lib/"