Debian Codegraph @

cmake_modules/FindMETIS.cmake

raw
1 #
2 # Copyright (c) 2022 Sergiu Deitsch
3 #
4 # Permission is hereby granted, free of charge, to any person obtaining a copy
5 # of this software and associated documentation files (the "Software"), to deal
6 # in the Software without restriction, including without limitation the rights
7 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 # copies of the Software, and to permit persons to whom the Software is
9 # furnished to do so, subject to the following conditions:
10 #
11 # The above copyright notice and this permission notice shall be included in all
12 # copies or substantial portions of the Software.
13 #
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 # FITNESS FOR A PARTMETISLAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 # SOFTWARE.
21 #
22 #[=======================================================================[.rst:
23 Module for locating METIS
24 =========================
25
26 Read-only variables:
27
28 ``METIS_FOUND``
29 Indicates whether the library has been found.
30
31 ``METIS_VERSION``
32 Indicates library version.
33
34 Targets
35 -------
36
37 ``METIS::METIS``
38 Specifies targets that should be passed to target_link_libararies.
39 ]=======================================================================]
40
41 include (FindPackageHandleStandardArgs)
42
43 find_path (METIS_INCLUDE_DIR NAMES metis.h
44 PATH_SUFFIXES include
45 DOC "METIS include directory")
46 find_library (METIS_LIBRARY_DEBUG NAMES metis
47 PATH_SUFFIXES Debug
48 DOC "METIS debug library")
49 find_library (METIS_LIBRARY_RELEASE NAMES metis
50 PATH_SUFFIXES Release
51 DOC "METIS release library")
52
53 if (METIS_LIBRARY_RELEASE)
54 if (METIS_LIBRARY_DEBUG)
55 set (METIS_LIBRARY debug ${METIS_LIBRARY_DEBUG} optimized
56 ${METIS_LIBRARY_RELEASE} CACHE STRING "METIS library")
57 else (METIS_LIBRARY_DEBUG)
58 set (METIS_LIBRARY ${METIS_LIBRARY_RELEASE} CACHE FILEPATH "METIS library")
59 endif (METIS_LIBRARY_DEBUG)
60 elseif (METIS_LIBRARY_DEBUG)
61 set (METIS_LIBRARY ${METIS_LIBRARY_DEBUG} CACHE FILEPATH "METIS library")
62 endif (METIS_LIBRARY_RELEASE)
63
64 set (_METIS_VERSION_HEADER ${METIS_INCLUDE_DIR}/metis.h)
65
66 if (EXISTS ${_METIS_VERSION_HEADER})
67 file (READ ${_METIS_VERSION_HEADER} _METIS_VERSION_CONTENTS)
68
69 string (REGEX REPLACE ".*#define METIS_VER_MAJOR[ \t]+([0-9]+).*" "\\1"
70 METIS_VERSION_MAJOR "${_METIS_VERSION_CONTENTS}")
71 string (REGEX REPLACE ".*#define METIS_VER_MINOR[ \t]+([0-9]+).*" "\\1"
72 METIS_VERSION_MINOR "${_METIS_VERSION_CONTENTS}")
73 string (REGEX REPLACE ".*#define METIS_VER_SUBMINOR[ \t]+([0-9]+).*" "\\1"
74 METIS_VERSION_PATCH "${_METIS_VERSION_CONTENTS}")
75
76 set (METIS_VERSION
77 ${METIS_VERSION_MAJOR}.${METIS_VERSION_MINOR}.${METIS_VERSION_PATCH})
78 set (METIS_VERSION_COMPONENTS 3)
79 endif (EXISTS ${_METIS_VERSION_HEADER})
80
81 mark_as_advanced (METIS_INCLUDE_DIR METIS_LIBRARY_DEBUG METIS_LIBRARY_RELEASE
82 METIS_LIBRARY)
83
84 if (NOT TARGET METIS::METIS)
85 if (METIS_INCLUDE_DIR OR METIS_LIBRARY)
86 add_library (METIS::METIS IMPORTED UNKNOWN)
87 endif (METIS_INCLUDE_DIR OR METIS_LIBRARY)
88 endif (NOT TARGET METIS::METIS)
89
90 if (METIS_INCLUDE_DIR)
91 set_property (TARGET METIS::METIS PROPERTY INTERFACE_INCLUDE_DIRECTORIES
92 ${METIS_INCLUDE_DIR})
93 endif (METIS_INCLUDE_DIR)
94
95 if (METIS_LIBRARY_RELEASE)
96 set_property (TARGET METIS::METIS PROPERTY IMPORTED_LOCATION_RELEASE
97 ${METIS_LIBRARY_RELEASE})
98 set_property (TARGET METIS::METIS APPEND PROPERTY IMPORTED_CONFIGURATIONS
99 RELEASE)
100 endif (METIS_LIBRARY_RELEASE)
101
102 if (METIS_LIBRARY_DEBUG)
103 set_property (TARGET METIS::METIS PROPERTY IMPORTED_LOCATION_DEBUG
104 ${METIS_LIBRARY_DEBUG})
105 set_property (TARGET METIS::METIS APPEND PROPERTY IMPORTED_CONFIGURATIONS
106 DEBUG)
107 endif (METIS_LIBRARY_DEBUG)
108 if(WIN32)
109 find_package_handle_standard_args (metis REQUIRED_VARS
110 METIS_INCLUDE_DIR METIS_LIBRARY VERSION_VAR METIS_VERSION)
111 else(WIN32)
112 find_package_handle_standard_args (METIS REQUIRED_VARS
113 METIS_INCLUDE_DIR METIS_LIBRARY VERSION_VAR METIS_VERSION)
114 endif(WIN32)