-
Notifications
You must be signed in to change notification settings - Fork 2
/
FindHypre.cmake
76 lines (66 loc) · 2.6 KB
/
FindHypre.cmake
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
################################################################################
#
# \file FindHypre.cmake
# \copyright 2012-2015 J. Bakosi,
# 2016-2018 Los Alamos National Security, LLC.,
# 2019-2021 Triad National Security, LLC.
# All rights reserved. See the LICENSE file for details.
# \brief Find the Hypre library from LLNL
#
################################################################################
# Hypre: https://github.com/LLNL/hypre
#
# HYPRE_FOUND - System has Hypre
# HYPRE_INCLUDE_DIRS - The Hypre include directory
# HYPRE_LIBRARIES - The libraries needed to use Hypre
#
# Set HYPRE_ROOT before calling find_package to a path to add an additional
# search path, e.g.,
#
# Usage:
#
# set(HYPRE_ROOT "/path/to/custom/hypre") # prefer over system
# find_package(Hypre)
# if(HYPRE_FOUND)
# target_link_libraries (TARGET ${HYPRE_LIBRARIES})
# endif()
function(_HYPRE_GET_VERSION _OUT_ver _version_hdr)
file(STRINGS ${_version_hdr} _contents REGEX "#define HYPRE_RELEASE_VERSION[ \t]+")
if(_contents)
string(REGEX REPLACE "\"" "" _cont "${_contents}")
string(REGEX REPLACE ".*#define HYPRE_RELEASE_VERSION[ \t]+([0-9.]+).*" "\\1" ${_OUT_ver} "${_cont}")
if(NOT ${${_OUT_ver}} MATCHES "[0-9]+")
message(FATAL_ERROR "Version parsing failed for HYPRE_RELEASE_VERSION in ${_version_hdr}!")
endif()
set(${_OUT_ver} ${${_OUT_ver}} PARENT_SCOPE)
elseif(EXISTS ${_version_hdr})
message(FATAL_ERROR "No HYPRE_RELEASE_VERSION in ${_version_hdr}")
else()
message(FATAL_ERROR "Include file ${_version_hdr} does not exist")
endif()
endfunction()
# If already in cache, be silent
if(HYPRE_INCLUDE_DIRS AND HYPRE_LIBRARIES)
set (HYPRE_FIND_QUIETLY TRUE)
endif()
if (HYPRE_ROOT)
set(HYPRE_SEARCH_OPTS NO_DEFAULT_PATH)
endif()
find_path(HYPRE_INCLUDE_DIR NAMES HYPRE.h
PATH_SUFFIXES hypre
HINTS ${HYPRE_ROOT}/include
${HYPRE_SEARCH_OPTS})
if(HYPRE_INCLUDE_DIR)
_HYPRE_GET_VERSION(HYPRE_VERSION ${HYPRE_INCLUDE_DIR}/HYPRE_config.h)
set(HYPRE_INCLUDE_DIRS ${HYPRE_INCLUDE_DIR})
else()
set(HYPRE_VERSION 0.0.0)
set(HYPRE_INCLUDE_DIRS "")
endif()
find_library(HYPRE_LIBRARY NAMES HYPRE HINTS ${HYPRE_ROOT}/lib)
set(HYPRE_LIBRARIES ${HYPRE_LIBRARY})
# Handle the QUIETLY and REQUIRED arguments and set HYPRE_FOUND to TRUE if
# all listed variables are TRUE.
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Hypre REQUIRED_VARS HYPRE_LIBRARIES HYPRE_INCLUDE_DIRS VERSION_VAR HYPRE_VERSION)
MARK_AS_ADVANCED(HYPRE_INCLUDE_DIRS HYPRE_LIBRARIES)