Commit 6cb3992f authored by Markus Blatt's avatar Markus Blatt

[release] Find METIS even if it is actually the static Scotch library.

The Scotch library on Debian is rather broken. There are several libraries
missing for the version with long, int32, int64 support. If one
wants to use them, then one needs to use the static libraries and provide
the correct library with the metis bindings. Unfortunately, our METIS test
assumes that the library is self contained which breaks on Debian Jessie.

This commit fixes this. If METIS_PartGraphKway is not found with the METIS
library alone then we try to find the corresponding Scotch helper libraries
and try to find the function again.
parent b28d5acf
......@@ -42,6 +42,7 @@
# library, that should be used by :ref:`FindMETIS`.
#
# search metis header
find_path(METIS_INCLUDE_DIR metis.h
PATHS ${METIS_DIR} ${METIS_ROOT}
......@@ -74,14 +75,33 @@ find_library(METIS_LIBRARY ${METIS_LIB_NAME}
# we need to check whether we need to link m, copy the lazy solution from FindBLAS and FindLAPACK here.
if(METIS_LIBRARY AND NOT WIN32)
list(APPEND METIS_LIBRARY "-lm")
set(_METIS_LM_LIBRARY "-lm")
endif()
# check metis library
if(METIS_LIBRARY)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${METIS_LIBRARY})
set(_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") # do a backup
list(APPEND CMAKE_REQUIRED_LIBRARIES ${METIS_LIBRARY} ${_METIS_LM_LIBRARY})
include(CheckFunctionExists)
check_function_exists(METIS_PartGraphKway HAVE_METIS_PARTGRAPHKWAY)
if(NOT HAVE_METIS_PARTGRAPHKWAY)
# Maybe we are using static scotch libraries. In this case we need to link
# the other scotch libraries too. Let's make a best effort.
# Get the path eher METIS_LIBRARY resides
get_filename_component(_lib_root ${METIS_LIBRARY} DIRECTORY)
find_library(SCOTCH_LIBRARY scotch PATHS ${_lib_root} "The Scotch library.")
find_library(SCOTCHERR_LIBRARY scotcherr PATHS ${_lib_root} "The Scotch error library.")
if(SCOTCH_LIBRARY AND SCOTCHERR_LIBRARY)
set(_METIS_SCOTCH_LIBRARIES ${SCOTCH_LIBRARY} ${SCOTCHERR_LIBRARY} "${_METIS_LIBRARIES}")
set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES} ${METIS_LIBRARY} ${_METIS_SCOTCH_LIBRARIES} ${_METIS_LM_LIBRARY})
# unset HAVE_METIS_PARTGRAPHKWAY to force another
# run of check_function_exists(METIS_PartGraphKway
unset(HAVE_METIS_PARTGRAPHKWAY CACHE)
check_function_exists(METIS_PartGraphKway HAVE_METIS_PARTGRAPHKWAY)
endif()
endif()
set(CMAKE_REQUIRED_LIBRARIES "${_CMAKE_REQUIRED_LIBRARIES}")
endif(METIS_LIBRARY)
# behave like a CMake module is supposed to behave
......@@ -101,7 +121,10 @@ mark_as_advanced(METIS_INCLUDE_DIR METIS_LIBRARIES METIS_LIB_NAME)
# if both headers and library are found, store results
if(METIS_FOUND)
set(METIS_INCLUDE_DIRS ${METIS_INCLUDE_DIR})
set(METIS_LIBRARIES ${METIS_LIBRARY})
# We need to cache METIS_LIBRARIES as for subsequent runs
# The scotch stuff will not be set again!!!
set(METIS_LIBRARIES ${METIS_LIBRARY} ${_METIS_SCOTCH_LIBRARIES} ${_METIS_LM_LIBRARY}
CACHE STRING "List of all libraries needed to link to METIS")
set(HAVE_METIS ${METIS_FOUND})
# log result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment