FindMetis.cmake 1.63 KB
Newer Older
1
2
3
#[=======================================================================[.rst:
FindMETIS
-------
4

5
Finds the METIS library.
6

7
8
Result Variables
^^^^^^^^^^^^^^^^
9

10
This will define the following variables:
11

12
13
14
15
16
17
``METIS_FOUND``
  True if the system has the METIS library.
``METIS_INCLUDE_DIRS``
  Include directories needed to use METIS.
``METIS_LIBRARIES``
  Libraries needed to link to METIS.
18

19
20
Cache Variables
^^^^^^^^^^^^^^^
21

22
The following cache variables may also be set:
23

24
25
26
27
``METIS_INCLUDE_DIR``
  The directory containing ``METIS.h``.
``METIS_LIBRARY``
  The path to the METIS library.
28

29
#]=======================================================================]
30

31
32
33
34
35
36
37
38
set(CMAKE_FIND_DEBUG_MODE TRUE)
find_path(METIS_INCLUDE_DIR
        NAMES metis.h
        )
     set(CMAKE_FIND_DEBUG_MODE FALSE)
find_library(METIS_LIBRARY
        NAMES metis
        )
39

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Metis
        FOUND_VAR METIS_FOUND
        REQUIRED_VARS
        METIS_LIBRARY
        METIS_INCLUDE_DIR
        VERSION_VAR METIS_VERSION
        )

if(METIS_FOUND)
    # Build and run test program
    try_compile(METIS_TEST_RUNS 
       "${CMAKE_BINARY_DIR}" 
       "${CMAKE_SOURCE_DIR}/cmake/TestMetis.cpp"
       CXX_STANDARD 14
       OUTPUT_VARIABLE METIS_ERROR
       CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${METIS_INCLUDE_DIR}")

    if (NOT METIS_TEST_RUNS)
       message(FATAL_ERROR "Metis not build with 64-bit integer and 64-bit float. (${METIS_INCLUDE_DIR})")
60
    endif()
61
    set(METIS_LIBRARIES ${METIS_LIBRARY})
62
63
64
65
    set(METIS_INCLUDE_DIRS ${METIS_INCLUDE_DIR})
endif()

mark_as_advanced(
66
67
68
        METIS_INCLUDE_DIR
        METIS_LIBRARY
)