Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 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 | |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 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 | |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 92 | include(FindPackageHandleStandardArgs) |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 93 | find_package_handle_standard_args(SUPERLU |
| 94 | REQUIRED_VARS SUPERLU_INCLUDES SUPERLU_LIBRARIES SUPERLU_VERSION_OK |
| 95 | VERSION_VAR SUPERLU_VERSION_VAR) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 96 | |
| 97 | mark_as_advanced(SUPERLU_INCLUDES SUPERLU_LIBRARIES) |