Skip to content
Snippets Groups Projects
Commit c8580cd0 authored by Markus Blatt's avatar Markus Blatt
Browse files

Adds a find module for PT-Scotch.

This is e.g. needed for dune-alugrid and might be a first step for
getting rid off the ParMETIS dependency.
parent 5439c28e
No related branches found
No related tags found
No related merge requests found
# Module providing convenience functions for using PT-Scotch
#
# Provides the following functions:
#
# add_dune_parmetis_flags(target1 target2 ...)
#
# Adds the necessary flags to compile and link the targets with PT-Scotch support.
#
function(add_dune_ptscotch_flags _targets)
if(PTSCOTCH_FOUND)
foreach(_target ${_targets})
message("pt-scotch target_link_libraries(${_target} ${PTSCOTCH_LIBRARY} ${PTSCOTCHERR_LIBRARY}")
target_link_libraries(${_target} ${PTSCOTCH_LIBRARY} ${PTSCOTCHERR_LIBRARY})
GET_TARGET_PROPERTY(_props ${_target} INCLUDE_DIRECTORIES)
string(REPLACE "_props-NOTFOUND" "" _props "${_props}")
SET_TARGET_PROPERTIES(${_target} PROPERTIES INCLUDE_DIRECTORIES
"${_props};${PTSCOTCH_INCLUDE_DIRS}")
GET_TARGET_PROPERTY(_props ${_target} COMPILE_DEFINITIONS)
string(REPLACE "_props-NOTFOUND" "" _props "${_props}")
SET_TARGET_PROPERTIES(${_target} PROPERTIES COMPILE_DEFINITIONS
"${_props};")
endforeach(_target ${_targets})
add_dune_mpi_flags(${_targets})
endif(PTSCOTCH_FOUND)
endfunction(add_dune_ptscotch_flags)
...@@ -2,6 +2,7 @@ set(modules ...@@ -2,6 +2,7 @@ set(modules
AddGMPFlags.cmake AddGMPFlags.cmake
AddMETISFlags.cmake AddMETISFlags.cmake
AddParMETISFlags.cmake AddParMETISFlags.cmake
AddPTScotchFlags.cmake
AddUMFPackFlags.cmake AddUMFPackFlags.cmake
CheckCXX11Features.cmake CheckCXX11Features.cmake
DuneBoost.cmake DuneBoost.cmake
...@@ -22,6 +23,7 @@ set(modules ...@@ -22,6 +23,7 @@ set(modules
FindMETIS.cmake FindMETIS.cmake
FindMProtect.cmake FindMProtect.cmake
FindParMETIS.cmake FindParMETIS.cmake
FindPTScotch.cmake
FindUMFPack.cmake FindUMFPack.cmake
Headercheck.cmake Headercheck.cmake
LanguageSupport.cmake LanguageSupport.cmake
......
# Module that checks whether PT-Scotch is available.
#
# Accepts the following variables:
#
# PTSCOTCH_ROOT: Prefix where PT-Scotch is installed.
# PTSCOTCH_SUFFIX: Scotch might be compiled using different
# integer sizes (int32, int32, long). When
# this is is set the headers and libaries
# are search under the suffix
# include/scotch-${PTSCOTCH_SUFFIX, and
# lib/scotch-${PTSCOTCH_SUFFIX}, respectively.
# Sets the following variables:
# PTSCOTCH_INCLUDE_DIRS: All include directories needed to compile PT-Scotch programs.
# PTSCOTCH_LIBRARIES: Alle libraries needed to link PT-Scotch programs.
# PTSCOTCH_FOUND: True if PT-Scotch was found.
#
# Provides the following macros:
#
# find_package(PTScotch)
include(DuneMPI)
macro(_search_pt_lib libvar libname doc)
find_library(${libvar} ${libname}
PATHS${PTSCOTCH_ROOT} PATH_SUFFIXES ${PATH_SUFFIXES}
NO_DEFAULT_PATH
DOC "${doc}")
find_library(${libvar} ${libname})
endmacro(_search_pt_lib)
if(PTSCOTCH_SUFFIX)
set(PATH_SUFFIXES "scotch-${PTSCOTCH_SUFFIX}")
else(PTSCOTCH_SUFFIX)
set(PATH_SUFFIXES "scotch")
endif(PTSCOTCH_SUFFIX)
include(CMakePushCheckState)
cmake_push_check_state() # Save variables
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${MPI_DUNE_INCLUDE_PATH})
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${MPI_DUNE_COMPILE_FLAGS}")
find_path(PTSCOTCH_INCLUDE_DIR ptscotch.h
PATHS ${PTSCOTCH_ROOT}
PATH_SUFFIXES ${PATH_SUFFIXES}
NO_DEFAULT_PATH
DOC "Include directory of PT-Scotch")
find_path(PTSCOTCH_INCLUDE_DIR ptscotch.h
PATH_SUFFIXES ${PATH_SUFFIXES})
_search_pt_lib(PTSCOTCH_LIBRARY ptscotch "The main PT-Scotch library.")
_search_pt_lib(PTSCOTCHERR_LIBRARY ptscotcherr "The PT-Scotch error library.")
# behave like a CMake module is supposed to behave
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
"PTScotch"
DEFAULT_MSG
PTSCOTCH_INCLUDE_DIR
PTSCOTCH_LIBRARY
PTSCOTCHERR_LIBRARY
)
#restore old values
cmake_pop_check_state()
if(PTSCOTCH_FOUND)
set(PTSCOTCH_INCLUDE_DIRS ${PTSCOTCH_INCLUDE_DIR})
set(PTSCOTCH_LIBRARIES ${PTSCOTCH_LIBRARY} ${PTSCOTCHERR_LIBRARY} ${MPI_DUNE_LIBRARIES}
CACHE FILEPATH "All libraries needed to link programs using PT-Scotch")
set(PTSCOCH_LINK_FLAGS "${DUNE_MPI_LINK_FLAGS}"
CACHE STRING "PT-Scotch link flags")
set(HAVE_PTSCOTCH 1)
# log result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determing location of PT-Scotch succeded:\n"
"Include directory: ${PTSCOTCH_INCLUDE_DIRS}\n"
"Library directory: ${PTSCOTCH_LIBRARIES}\n\n")
foreach(dir ${PTSCOCTH_INCLUDE_DIRS})
set_property(GLOBAL APPEND PROPERTY ALL_PKG_FLAGS "-I${dir}")
endforeach()
set_property(GLOBAL APPEND PROPERTY ALL_PKG_LIBS "${PTSCOTCH_LIBRARIES}")
endif(PTSCOTCH_FOUND)
mark_as_advanced(PTSCOTCH_INCLUDE_DIR PTSCOTCH_LIBRARIES HAVE_PTSCOTCH)
...@@ -2,6 +2,7 @@ MODULES = \ ...@@ -2,6 +2,7 @@ MODULES = \
AddGMPFlags.cmake \ AddGMPFlags.cmake \
AddMETISFlags.cmake \ AddMETISFlags.cmake \
AddParMETISFlags.cmake \ AddParMETISFlags.cmake \
AddPTScotchFlags.cmake \
AddUMFPackFlags.cmake \ AddUMFPackFlags.cmake \
CheckCXX11Features.cmake \ CheckCXX11Features.cmake \
DuneBoost.cmake \ DuneBoost.cmake \
...@@ -22,6 +23,7 @@ MODULES = \ ...@@ -22,6 +23,7 @@ MODULES = \
FindMETIS.cmake \ FindMETIS.cmake \
FindMProtect.cmake \ FindMProtect.cmake \
FindParMETIS.cmake \ FindParMETIS.cmake \
FindPTScotch.cmake \
FindUMFPack.cmake \ FindUMFPack.cmake \
Headercheck.cmake \ Headercheck.cmake \
LanguageSupport.cmake \ LanguageSupport.cmake \
......
...@@ -124,6 +124,9 @@ ...@@ -124,6 +124,9 @@
by configure _and_ if the application uses the PARMETIS_CPPFLAGS */ by configure _and_ if the application uses the PARMETIS_CPPFLAGS */
#cmakedefine HAVE_PARMETIS ENABLE_PARMETIS #cmakedefine HAVE_PARMETIS ENABLE_PARMETIS
/* Define to 1 if PT-Scotch is available */
#cmakedefine HAVE_PTSCOTCH 1
/* Include always useful headers */ /* Include always useful headers */
#include "FC.h" #include "FC.h"
#define FC_FUNC FC_GLOBAL_ #define FC_FUNC FC_GLOBAL_
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment