| 1 |
# Copyright (c), ETH Zurich and UNC Chapel Hill. |
| 2 |
# All rights reserved. |
| 3 |
# |
| 4 |
# Redistribution and use in source and binary forms, with or without |
| 5 |
# modification, are permitted provided that the following conditions are met: |
| 6 |
# |
| 7 |
# * Redistributions of source code must retain the above copyright |
| 8 |
# notice, this list of conditions and the following disclaimer. |
| 9 |
# |
| 10 |
# * Redistributions in binary form must reproduce the above copyright |
| 11 |
# notice, this list of conditions and the following disclaimer in the |
| 12 |
# documentation and/or other materials provided with the distribution. |
| 13 |
# |
| 14 |
# * Neither the name of ETH Zurich and UNC Chapel Hill nor the names of |
| 15 |
# its contributors may be used to endorse or promote products derived |
| 16 |
# from this software without specific prior written permission. |
| 17 |
# |
| 18 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 19 |
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 20 |
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 21 |
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE |
| 22 |
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 23 |
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 24 |
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 25 |
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 26 |
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 27 |
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 28 |
# POSSIBILITY OF SUCH DAMAGE. |
| 29 |
|
| 30 |
|
| 31 |
# Find package module for Metis library. |
| 32 |
# |
| 33 |
# The following variables are set by this module: |
| 34 |
# |
| 35 |
# METIS_FOUND: TRUE if Metis is found. |
| 36 |
# metis: Imported target to link against. |
| 37 |
# |
| 38 |
# The following variables control the behavior of this module: |
| 39 |
# |
| 40 |
# METIS_INCLUDE_DIR_HINTS: List of additional directories in which to |
| 41 |
# search for Metis includes. |
| 42 |
# METIS_LIBRARY_DIR_HINTS: List of additional directories in which to |
| 43 |
# search for Metis libraries. |
| 44 |
|
| 45 |
set(METIS_INCLUDE_DIR_HINTS "" CACHE PATH "Metis include directory") |
| 46 |
set(METIS_LIBRARY_DIR_HINTS "" CACHE PATH "Metis library directory") |
| 47 |
|
| 48 |
unset(METIS_FOUND) |
| 49 |
|
| 50 |
find_package(metis CONFIG QUIET) |
| 51 |
if(TARGET metis) |
| 52 |
set(METIS_FOUND TRUE) |
| 53 |
message(STATUS "Found Metis") |
| 54 |
message(STATUS " Target : metis") |
| 55 |
else() |
| 56 |
list(APPEND METIS_CHECK_INCLUDE_DIRS |
| 57 |
${METIS_INCLUDE_DIR_HINTS} |
| 58 |
/usr/include |
| 59 |
/usr/local/include |
| 60 |
/opt/include |
| 61 |
/opt/local/include |
| 62 |
) |
| 63 |
|
| 64 |
list(APPEND METIS_CHECK_LIBRARY_DIRS |
| 65 |
${METIS_LIBRARY_DIR_HINTS} |
| 66 |
/usr/lib |
| 67 |
/usr/local/lib |
| 68 |
/opt/lib |
| 69 |
/opt/local/lib |
| 70 |
) |
| 71 |
|
| 72 |
find_path(METIS_INCLUDE_DIRS |
| 73 |
NAMES |
| 74 |
metis.h |
| 75 |
PATHS |
| 76 |
${METIS_CHECK_INCLUDE_DIRS}) |
| 77 |
find_library(METIS_LIBRARIES |
| 78 |
NAMES |
| 79 |
metis |
| 80 |
PATHS |
| 81 |
${METIS_CHECK_LIBRARY_DIRS}) |
| 82 |
find_library(GK_LIBRARIES |
| 83 |
NAMES |
| 84 |
GKlib |
| 85 |
PATHS |
| 86 |
${METIS_CHECK_LIBRARY_DIRS}) |
| 87 |
|
| 88 |
if(GK_LIBRARIES) |
| 89 |
set(METIS_LIBRARIES ${METIS_LIBRARIES} ${GK_LIBRARIES}) |
| 90 |
message(STATUS "Found GKlib") |
| 91 |
endif() |
| 92 |
|
| 93 |
if(METIS_INCLUDE_DIRS AND METIS_LIBRARIES) |
| 94 |
set(METIS_FOUND TRUE) |
| 95 |
message(STATUS "Found Metis") |
| 96 |
message(STATUS " Includes : ${METIS_INCLUDE_DIRS}") |
| 97 |
message(STATUS " Libraries : ${METIS_LIBRARIES}") |
| 98 |
endif() |
| 99 |
|
| 100 |
add_library(metis INTERFACE IMPORTED) |
| 101 |
target_include_directories( |
| 102 |
metis INTERFACE ${METIS_INCLUDE_DIRS}) |
| 103 |
target_link_libraries( |
| 104 |
metis INTERFACE ${METIS_LIBRARIES}) |
| 105 |
endif() |
| 106 |
|
| 107 |
if(NOT METIS_FOUND AND METIS_FIND_REQUIRED) |
| 108 |
message(FATAL_ERROR "Could not find Metis") |
| 109 |
endif() |