$NetBSD: patch-CMakeLists.txt,v 1.4 2021/05/17 11:31:29 thor 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-03-25 18:25:15.000000000 +0000 +++ CMakeLists.txt @@ -160,6 +160,9 @@ endif() # -------------------------------------------------- + +if(LAPACK) + set(LAPACK_INSTALL_EXPORT_NAME ${LAPACKLIB}-targets) macro(lapack_install_library lib) @@ -171,6 +174,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) # -------------------------------------------------- @@ -301,6 +316,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 @@ -342,6 +361,8 @@ else() CACHE STRING "Linker flags for shared libs" FORCE) endif() +endif() + if(BUILD_TESTING) add_subdirectory(TESTING) endif() @@ -450,14 +471,18 @@ 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(BUILD_TESTING OR LAPACKE_WITH_TMG) set(ALL_TARGETS ${ALL_TARGETS} ${TMGLIB}) endif() +if(LAPACK) # Export lapack targets, not including lapacke, from the # install tree, if any. set(_lapack_config_install_guard_target "") @@ -471,6 +496,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) @@ -482,6 +508,8 @@ if(LAPACKE) set(ALL_TARGETS ${ALL_TARGETS} ${LAPACKELIB}) endif() +if(BUILD_LAPACK) + # Export lapack and lapacke targets from the build tree, if any. set(_lapack_config_build_guard_target "") if(ALL_TARGETS) @@ -519,6 +547,9 @@ install(FILES DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${LAPACKLIB}-${LAPACK_VERSION} COMPONENT Development ) + +endif() # BUILD_LAPACK + if (LAPACK++) install( DIRECTORY "${LAPACK_BINARY_DIR}/lib/"