1 #-------------------------------------------------------------------------------
3 # | ____| _| |_ / __ \ /\ | \/ |
4 # | |__ _ __ ___ ___ / \| | | | / \ | \ / |
5 # | __| '__/ _ \/ _ ( (| |) ) | | |/ /\ \ | |\/| |
6 # | | | | | __/ __/\_ _/| |__| / ____ \| | | |
7 # |_| |_| \___|\___| |_| \____/_/ \_\_| |_|
9 # FreeFOAM: The Cross-Platform CFD Toolkit
11 # Copyright (C) 2008-2012 Michael Wild <themiwi@users.sf.net>
12 # Gerber van der Graaf <gerber_graaf@users.sf.net>
13 #-------------------------------------------------------------------------------
15 # This file is part of FreeFOAM.
17 # FreeFOAM is free software: you can redistribute it and/or modify it
18 # under the terms of the GNU General Public License as published by the
19 # Free Software Foundation, either version 3 of the License, or (at your
20 # option) any later version.
22 # FreeFOAM is distributed in the hope that it will be useful, but WITHOUT
23 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
24 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27 # You should have received a copy of the GNU General Public License
28 # along with FreeFOAM. If not, see <http://www.gnu.org/licenses/>.
29 #-------------------------------------------------------------------------------
33 # This module looks for metis support and defines the following values
34 # METIS_FOUND TRUE if metis has been found
35 # METIS_INCLUDE_DIRS include path for metis
36 # METIS_LIBRARIES libraries to link against
37 # METIS_FROM_PARMETIS TRUE if the metis library is from ParMetis
38 # METIS_COMPILE_FLAGS compile-flags for metis
39 # METIS_LINK_FLAGS linker-flags for metis
40 # METIS_NEW_API TRUE if the new API introduced in 5.0rc1 is present
42 find_path(METIS_INCLUDE_DIR metis.h
46 find_library(METIS_LIBRARY
50 set(METIS_INCLUDE_DIRS ${METIS_INCLUDE_DIR} ${MPI_INCLUDE_PATH})
51 set(METIS_LIBRARIES ${METIS_LIBRARY})
53 # now check whether that metis.h comes from ParMetis
54 set(METIS_FROM_PARMETIS FALSE)
55 find_package(ParMetis QUIET)
57 include(CheckSymbolExists)
58 set(CMAKE_REQUIRED_INCLUDES ${METIS_INCLUDE_DIRS})
59 set(CMAKE_REQUIRED_LIBRARIES ${PARMETIS_LIBRARIES})
60 set(CMAKE_REQUIRED_FLAGS ${PARMETIS_COMPILE_FLAGS})
61 # by checking whether metis.h include parmetis.h
62 check_symbol_exists(PARMETIS_MAJOR_VERSION metis.h METIS_FROM_PARMETIS)
64 if(METIS_FROM_PARMETIS)
65 message(STATUS "NOTE: Metis is provided by ParMetis")
66 find_package(MPI REQUIRED)
67 list(APPEND METIS_INCLUDE_DIRS ${MPI_INCLUDE_PATH})
68 list(APPEND METIS_LIBRARIES ${MPI_LIBRARIES})
69 set(METIS_COMPILE_FLAGS ${MPI_COMPILE_FLAGS})
70 set(METIS_LINK_FLAGS ${MPI_LINK_FLAGS})
74 # now check whether the Metis found has the new API
75 if(METIS_INCLUDE_DIR AND METIS_LIBRARY)
76 include(CheckFunctionExists)
77 set(CMAKE_REQUIRED_INCLUDES ${METIS_INCLUDE_DIRS})
78 set(CMAKE_REQUIRED_LIBRARIES ${METIS_LIBRARIES})
79 set(CMAKE_REQUIRED_FLAGS ${METIS_COMPILE_FLAGS})
80 check_function_exists(METIS_WPartGraphRecursive HAVE_METIS_WPARTGRAPHRECURSIVE)
82 if(HAVE_METIS_WPARTGRAPHRECURSIVE)
83 set(METIS_NEW_API FALSE)
85 set(METIS_NEW_API TRUE)
94 include(FindPackageHandleStandardArgs)
95 find_package_handle_standard_args(Metis
101 set(CMAKE_REQUIRED_FLAGS)
102 set(CMAKE_REQUIRED_LIBRARIES)
103 set(CMAKE_REQUIRED_INCLUDES)
105 # ------------------------- vim: set sw=2 sts=2 et: --------------- end-of-file