Commit 834efd97 authored by Steffen Müthing's avatar Steffen Müthing

Merge branch 'fixes-static-scotch-metis-bindings' into 'master'

[release] Fixes finding static scotch metis bindings

Using Scotch a replacement work on Debian only for the default shared
libraries. But to use the ones supporting larger integer types one needs
to use the static version (shared ones are missing!). This MR fixes
finding static Scotch/PT-Scotch instead of METIS/ParMETIS.

Please cherry-pick to the release.

See merge request !60
parents b28d5acf 47091ecd
......@@ -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,36 @@ 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 where METIS_LIBRARY resides
get_filename_component(_lib_root ${METIS_LIBRARY} DIRECTORY)
# Search for additional libs only in this directory.
# Otherwise we might find incompatible ones, e.g. for int instead of long
find_library(SCOTCH_LIBRARY scotch PATHS ${_lib_root} "The Scotch library." NO_DEFAULT_PATH)
find_library(SCOTCHERR_LIBRARY scotcherr PATHS ${_lib_root} "The Scotch error library."
NO_DEFAULT_PATH)
if(SCOTCH_LIBRARY AND SCOTCHERR_LIBRARY)
set(_METIS_SCOTCH_LIBRARIES ${SCOTCH_LIBRARY} ${SCOTCHERR_LIBRARY} ${STDTHREAD_LINK_FLAGS} )
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 +124,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
......
......@@ -94,12 +94,35 @@ if(PARMETIS_FOUND)
NO_DEFAULT_PATH)
find_library(PARMETIS_LIBRARY parmetis)
set(_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") # do a backup
# check ParMETIS library
if(PARMETIS_LIBRARY)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${PARMETIS_LIBRARY} ${METIS_LIBRARY} ${MPI_DUNE_LIBRARIES})
set(_PARMETIS_LIBRARIES ${PARMETIS_LIBRARY} ${METIS_LIBRARIES} ${MPI_DUNE_LIBRARIES})
set(CMAKE_REQUIRED_LIBRARIES ${_PARMETIS_LIBRARIES} ${_CMAKE_REQUIRED_LIBRARIES})
include(CheckFunctionExists)
check_function_exists(parmetis_v3_partkway HAVE_PARMETIS)
if(NOT HAVE_PARMETIS)
# 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 where ParMETIS_LIBRARY resides
get_filename_component(_lib_root ${METIS_LIBRARY} DIRECTORY)
# Search for additional libs only in this directory.
# Otherwise we might find incompatible ones, e.g. for int instead of long
find_library(PTSCOTCH_LIBRARY ptscotch PATHS ${_lib_root} "The PT-Scotch library."
NO_DEFAULT_PATH)
find_library(PTSCOTCHERR_LIBRARY ptscotcherr PATHS ${_lib_root} "The Scotch error library."
NO_DEFAULT_PATH)
if(PTSCOTCH_LIBRARY AND PTSCOTCHERR_LIBRARY)
set(_PARMETIS_LIBRARIES ${PARMETIS_LIBRARY} ${PTSCOTCH_LIBRARY}
${PTSCOTCHERR_LIBRARY} ${METIS_LIBRARIES} ${MPI_DUNE_LIBRARIES})
set(CMAKE_REQUIRED_LIBRARIES ${_PARMETIS_LIBRARIES}
${_CMAKE_REQUIRED_LIBRARIES})
unset(HAVE_PARMETIS CACHE)
check_function_exists(parmetis_v3_partkway HAVE_PARMETIS)
endif()
endif()
endif(PARMETIS_LIBRARY)
set(CMAKE_REQUIRED_LIBRARIES "${_CMAKE_REQUIRED_LIBRARIES}") # get backup
endif(PARMETIS_FOUND)
# behave like a CMake module is supposed to behave
......@@ -119,7 +142,7 @@ cmake_pop_check_state()
if(PARMETIS_FOUND)
set(PARMETIS_INCLUDE_DIRS ${PARMETIS_INCLUDE_DIR})
set(PARMETIS_LIBRARIES "${PARMETIS_LIBRARY};${METIS_LIBRARY};${MPI_DUNE_LIBRARIES}"
set(PARMETIS_LIBRARIES "${_PARMETIS_LIBRARIES}"
CACHE FILEPATH "ParMETIS libraries needed for linking")
set(PARMETIS_LINK_FLAGS "${DUNE_MPI_LINK_FLAGS}"
CACHE STRING "ParMETIS link flags")
......
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