1 | # Pastix requires METIS or METIS (partitioning and reordering tools)
|
---|
2 |
|
---|
3 | if (METIS_INCLUDES AND METIS_LIBRARIES)
|
---|
4 | set(METIS_FIND_QUIETLY TRUE)
|
---|
5 | endif (METIS_INCLUDES AND METIS_LIBRARIES)
|
---|
6 |
|
---|
7 | find_path(METIS_INCLUDES
|
---|
8 | NAMES
|
---|
9 | metis.h
|
---|
10 | PATHS
|
---|
11 | $ENV{METISDIR}
|
---|
12 | ${INCLUDE_INSTALL_DIR}
|
---|
13 | PATH_SUFFIXES
|
---|
14 | .
|
---|
15 | metis
|
---|
16 | include
|
---|
17 | )
|
---|
18 |
|
---|
19 | macro(_metis_check_version)
|
---|
20 | file(READ "${METIS_INCLUDES}/metis.h" _metis_version_header)
|
---|
21 |
|
---|
22 | string(REGEX MATCH "define[ \t]+METIS_VER_MAJOR[ \t]+([0-9]+)" _metis_major_version_match "${_metis_version_header}")
|
---|
23 | set(METIS_MAJOR_VERSION "${CMAKE_MATCH_1}")
|
---|
24 | string(REGEX MATCH "define[ \t]+METIS_VER_MINOR[ \t]+([0-9]+)" _metis_minor_version_match "${_metis_version_header}")
|
---|
25 | set(METIS_MINOR_VERSION "${CMAKE_MATCH_1}")
|
---|
26 | string(REGEX MATCH "define[ \t]+METIS_VER_SUBMINOR[ \t]+([0-9]+)" _metis_subminor_version_match "${_metis_version_header}")
|
---|
27 | set(METIS_SUBMINOR_VERSION "${CMAKE_MATCH_1}")
|
---|
28 | if(NOT METIS_MAJOR_VERSION)
|
---|
29 | message(STATUS "Could not determine Metis version. Assuming version 4.0.0")
|
---|
30 | set(METIS_VERSION 4.0.0)
|
---|
31 | else()
|
---|
32 | set(METIS_VERSION ${METIS_MAJOR_VERSION}.${METIS_MINOR_VERSION}.${METIS_SUBMINOR_VERSION})
|
---|
33 | endif()
|
---|
34 | if(${METIS_VERSION} VERSION_LESS ${Metis_FIND_VERSION})
|
---|
35 | set(METIS_VERSION_OK FALSE)
|
---|
36 | else()
|
---|
37 | set(METIS_VERSION_OK TRUE)
|
---|
38 | endif()
|
---|
39 |
|
---|
40 | if(NOT METIS_VERSION_OK)
|
---|
41 | message(STATUS "Metis version ${METIS_VERSION} found in ${METIS_INCLUDES}, "
|
---|
42 | "but at least version ${Metis_FIND_VERSION} is required")
|
---|
43 | endif(NOT METIS_VERSION_OK)
|
---|
44 | endmacro(_metis_check_version)
|
---|
45 |
|
---|
46 | if(METIS_INCLUDES AND Metis_FIND_VERSION)
|
---|
47 | _metis_check_version()
|
---|
48 | else()
|
---|
49 | set(METIS_VERSION_OK TRUE)
|
---|
50 | endif()
|
---|
51 |
|
---|
52 |
|
---|
53 | find_library(METIS_LIBRARIES metis PATHS $ENV{METISDIR} ${LIB_INSTALL_DIR} PATH_SUFFIXES lib)
|
---|
54 |
|
---|
55 | include(FindPackageHandleStandardArgs)
|
---|
56 | find_package_handle_standard_args(METIS DEFAULT_MSG
|
---|
57 | METIS_INCLUDES METIS_LIBRARIES METIS_VERSION_OK)
|
---|
58 |
|
---|
59 | mark_as_advanced(METIS_INCLUDES METIS_LIBRARIES)
|
---|