You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.0 KiB

  1. # Pastix requires METIS or METIS (partitioning and reordering tools)
  2. if (METIS_INCLUDES AND METIS_LIBRARIES)
  3. set(METIS_FIND_QUIETLY TRUE)
  4. endif (METIS_INCLUDES AND METIS_LIBRARIES)
  5. find_path(METIS_INCLUDES
  6. NAMES
  7. metis.h
  8. PATHS
  9. $ENV{METISDIR}
  10. ${INCLUDE_INSTALL_DIR}
  11. PATH_SUFFIXES
  12. .
  13. metis
  14. include
  15. )
  16. macro(_metis_check_version)
  17. file(READ "${METIS_INCLUDES}/metis.h" _metis_version_header)
  18. string(REGEX MATCH "define[ \t]+METIS_VER_MAJOR[ \t]+([0-9]+)" _metis_major_version_match "${_metis_version_header}")
  19. set(METIS_MAJOR_VERSION "${CMAKE_MATCH_1}")
  20. string(REGEX MATCH "define[ \t]+METIS_VER_MINOR[ \t]+([0-9]+)" _metis_minor_version_match "${_metis_version_header}")
  21. set(METIS_MINOR_VERSION "${CMAKE_MATCH_1}")
  22. string(REGEX MATCH "define[ \t]+METIS_VER_SUBMINOR[ \t]+([0-9]+)" _metis_subminor_version_match "${_metis_version_header}")
  23. set(METIS_SUBMINOR_VERSION "${CMAKE_MATCH_1}")
  24. if(NOT METIS_MAJOR_VERSION)
  25. message(STATUS "Could not determine Metis version. Assuming version 4.0.0")
  26. set(METIS_VERSION 4.0.0)
  27. else()
  28. set(METIS_VERSION ${METIS_MAJOR_VERSION}.${METIS_MINOR_VERSION}.${METIS_SUBMINOR_VERSION})
  29. endif()
  30. if(${METIS_VERSION} VERSION_LESS ${Metis_FIND_VERSION})
  31. set(METIS_VERSION_OK FALSE)
  32. else()
  33. set(METIS_VERSION_OK TRUE)
  34. endif()
  35. if(NOT METIS_VERSION_OK)
  36. message(STATUS "Metis version ${METIS_VERSION} found in ${METIS_INCLUDES}, "
  37. "but at least version ${Metis_FIND_VERSION} is required")
  38. endif(NOT METIS_VERSION_OK)
  39. endmacro(_metis_check_version)
  40. if(METIS_INCLUDES AND Metis_FIND_VERSION)
  41. _metis_check_version()
  42. else()
  43. set(METIS_VERSION_OK TRUE)
  44. endif()
  45. find_library(METIS_LIBRARIES metis PATHS $ENV{METISDIR} ${LIB_INSTALL_DIR} PATH_SUFFIXES lib)
  46. include(FindPackageHandleStandardArgs)
  47. find_package_handle_standard_args(METIS DEFAULT_MSG
  48. METIS_INCLUDES METIS_LIBRARIES METIS_VERSION_OK)
  49. mark_as_advanced(METIS_INCLUDES METIS_LIBRARIES)