FindMETIS.cmake 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. Read-only variables:
  26. ``METIS_FOUND``
  27. Indicates whether the library has been found.
  28. ``METIS_VERSION``
  29. Indicates library version.
  30. Targets
  31. -------
  32. ``METIS::METIS``
  33. Specifies targets that should be passed to target_link_libararies.
  34. ]=======================================================================]
  35. include (FindPackageHandleStandardArgs)
  36. find_path (METIS_INCLUDE_DIR NAMES metis.h
  37. PATH_SUFFIXES include
  38. DOC "METIS include directory")
  39. find_library (METIS_LIBRARY_DEBUG NAMES metis
  40. PATH_SUFFIXES Debug
  41. DOC "METIS debug library")
  42. find_library (METIS_LIBRARY_RELEASE NAMES metis
  43. PATH_SUFFIXES Release
  44. DOC "METIS release library")
  45. if (METIS_LIBRARY_RELEASE)
  46. if (METIS_LIBRARY_DEBUG)
  47. set (METIS_LIBRARY debug ${METIS_LIBRARY_DEBUG} optimized
  48. ${METIS_LIBRARY_RELEASE} CACHE STRING "METIS library")
  49. else (METIS_LIBRARY_DEBUG)
  50. set (METIS_LIBRARY ${METIS_LIBRARY_RELEASE} CACHE FILEPATH "METIS library")
  51. endif (METIS_LIBRARY_DEBUG)
  52. elseif (METIS_LIBRARY_DEBUG)
  53. set (METIS_LIBRARY ${METIS_LIBRARY_DEBUG} CACHE FILEPATH "METIS library")
  54. endif (METIS_LIBRARY_RELEASE)
  55. set (_METIS_VERSION_HEADER ${METIS_INCLUDE_DIR}/metis.h)
  56. if (EXISTS ${_METIS_VERSION_HEADER})
  57. file (READ ${_METIS_VERSION_HEADER} _METIS_VERSION_CONTENTS)
  58. string (REGEX REPLACE ".*#define METIS_VER_MAJOR[ \t]+([0-9]+).*" "\\1"
  59. METIS_VERSION_MAJOR "${_METIS_VERSION_CONTENTS}")
  60. string (REGEX REPLACE ".*#define METIS_VER_MINOR[ \t]+([0-9]+).*" "\\1"
  61. METIS_VERSION_MINOR "${_METIS_VERSION_CONTENTS}")
  62. string (REGEX REPLACE ".*#define METIS_VER_SUBMINOR[ \t]+([0-9]+).*" "\\1"
  63. METIS_VERSION_PATCH "${_METIS_VERSION_CONTENTS}")
  64. set (METIS_VERSION
  65. ${METIS_VERSION_MAJOR}.${METIS_VERSION_MINOR}.${METIS_VERSION_PATCH})
  66. set (METIS_VERSION_COMPONENTS 3)
  67. endif (EXISTS ${_METIS_VERSION_HEADER})
  68. mark_as_advanced (METIS_INCLUDE_DIR METIS_LIBRARY_DEBUG METIS_LIBRARY_RELEASE
  69. METIS_LIBRARY)
  70. if (NOT TARGET METIS::METIS)
  71. if (METIS_INCLUDE_DIR OR METIS_LIBRARY)
  72. add_library (METIS::METIS IMPORTED UNKNOWN)
  73. endif (METIS_INCLUDE_DIR OR METIS_LIBRARY)
  74. endif (NOT TARGET METIS::METIS)
  75. if (METIS_INCLUDE_DIR)
  76. set_property (TARGET METIS::METIS PROPERTY INTERFACE_INCLUDE_DIRECTORIES
  77. ${METIS_INCLUDE_DIR})
  78. endif (METIS_INCLUDE_DIR)
  79. if (METIS_LIBRARY_RELEASE)
  80. set_property (TARGET METIS::METIS PROPERTY IMPORTED_LOCATION_RELEASE
  81. ${METIS_LIBRARY_RELEASE})
  82. set_property (TARGET METIS::METIS APPEND PROPERTY IMPORTED_CONFIGURATIONS
  83. RELEASE)
  84. endif (METIS_LIBRARY_RELEASE)
  85. if (METIS_LIBRARY_DEBUG)
  86. set_property (TARGET METIS::METIS PROPERTY IMPORTED_LOCATION_DEBUG
  87. ${METIS_LIBRARY_DEBUG})
  88. set_property (TARGET METIS::METIS APPEND PROPERTY IMPORTED_CONFIGURATIONS
  89. DEBUG)
  90. endif (METIS_LIBRARY_DEBUG)
  91. find_package_handle_standard_args (METIS REQUIRED_VARS
  92. METIS_INCLUDE_DIR METIS_LIBRARY VERSION_VAR METIS_VERSION)