summaryrefslogtreecommitdiff
path: root/math/lapack/patches/patch-CMakeLists.txt
blob: 9a777f4b68914dd312c8c191288b5987396ad030 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
$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/"