Browse Source

SuperLU find

add-code-of-conduct-1
Trevor Irons 5 years ago
parent
commit
e023e2fff3
2 changed files with 100 additions and 0 deletions
  1. 97
    0
      CMake/FindSuperLU.cmake
  2. 3
    0
      CMakeLists.txt

+ 97
- 0
CMake/FindSuperLU.cmake View File

@@ -0,0 +1,97 @@
1
+
2
+# Umfpack lib usually requires linking to a blas library.
3
+# It is up to the user of this module to find a BLAS and link to it.
4
+
5
+if (SUPERLU_INCLUDES AND SUPERLU_LIBRARIES)
6
+  set(SUPERLU_FIND_QUIETLY TRUE)
7
+endif (SUPERLU_INCLUDES AND SUPERLU_LIBRARIES)
8
+
9
+find_path(SUPERLU_INCLUDES
10
+  NAMES
11
+  supermatrix.h
12
+  PATHS
13
+  $ENV{SUPERLUDIR}
14
+  ${INCLUDE_INSTALL_DIR}
15
+  PATH_SUFFIXES
16
+  superlu
17
+  SRC
18
+)
19
+
20
+find_library(SUPERLU_LIBRARIES
21
+  NAMES "superlu_5.2.1" "superlu_5.2" "superlu_5.1.1" "superlu_5.1" "superlu_5.0" "superlu_4.3" "superlu_4.2" "superlu_4.1" "superlu_4.0" "superlu_3.1" "superlu_3.0" "superlu"
22
+  PATHS $ENV{SUPERLUDIR} ${LIB_INSTALL_DIR}
23
+  PATH_SUFFIXES lib)
24
+
25
+if(SUPERLU_INCLUDES AND SUPERLU_LIBRARIES)
26
+
27
+include(CheckCXXSourceCompiles)
28
+include(CMakePushCheckState)
29
+cmake_push_check_state()
30
+
31
+set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${SUPERLU_INCLUDES})
32
+
33
+# check whether struct mem_usage_t is globally defined
34
+check_cxx_source_compiles("
35
+typedef int int_t;
36
+#include <supermatrix.h>
37
+#include <slu_util.h>
38
+int main() {
39
+  mem_usage_t mem;
40
+  return 0;
41
+}"
42
+SUPERLU_HAS_GLOBAL_MEM_USAGE_T)
43
+
44
+
45
+check_cxx_source_compiles("
46
+typedef int int_t;
47
+#include <supermatrix.h>
48
+#include <superlu_enum_consts.h>
49
+int main() {
50
+  return SLU_SINGLE;
51
+}"
52
+SUPERLU_HAS_CLEAN_ENUMS)
53
+
54
+check_cxx_source_compiles("
55
+typedef int int_t;
56
+#include <supermatrix.h>
57
+#include <slu_util.h>
58
+int main(void)
59
+{
60
+  GlobalLU_t glu;
61
+  return 0;
62
+}"
63
+SUPERLU_HAS_GLOBALLU_T)
64
+
65
+if(SUPERLU_HAS_GLOBALLU_T)
66
+  # at least 5.0
67
+  set(SUPERLU_VERSION_VAR "5.0")
68
+elseif(SUPERLU_HAS_CLEAN_ENUMS)
69
+  # at least 4.3
70
+  set(SUPERLU_VERSION_VAR "4.3")
71
+elseif(SUPERLU_HAS_GLOBAL_MEM_USAGE_T)
72
+  # at least 4.0
73
+  set(SUPERLU_VERSION_VAR "4.0")
74
+else()
75
+  set(SUPERLU_VERSION_VAR "3.0")
76
+endif()
77
+
78
+cmake_pop_check_state()
79
+
80
+if(SuperLU_FIND_VERSION)
81
+  if(${SUPERLU_VERSION_VAR} VERSION_LESS ${SuperLU_FIND_VERSION})
82
+    set(SUPERLU_VERSION_OK FALSE)
83
+  else()
84
+    set(SUPERLU_VERSION_OK TRUE)
85
+  endif()
86
+else()
87
+  set(SUPERLU_VERSION_OK TRUE)
88
+endif()
89
+
90
+endif()
91
+
92
+include(FindPackageHandleStandardArgs)
93
+find_package_handle_standard_args(SUPERLU
94
+                                  REQUIRED_VARS SUPERLU_INCLUDES SUPERLU_LIBRARIES SUPERLU_VERSION_OK
95
+                                  VERSION_VAR SUPERLU_VERSION_VAR)
96
+
97
+mark_as_advanced(SUPERLU_INCLUDES SUPERLU_LIBRARIES)

+ 3
- 0
CMakeLists.txt View File

@@ -40,6 +40,9 @@ option (LEMMA_VTK8_SUPPORT "VTK 8.x library for visualisation and grids" OFF)
40 40
 
41 41
 #option (CMAKE_CROSSCOMPILING "Target different arch than you are on" OFF)
42 42
 
43
+SET( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMake/ )
44
+message( STATUS "MODULE PATH ${CMAKE_MODULE_PATH}" )
45
+
43 46
 SET (CMAKE_CROSSCOMPILING TRUE)
44 47
 
45 48
 ##########################################################################################

Loading…
Cancel
Save