Commit 9e76c8dc authored by PRUVOST Florent's avatar PRUVOST Florent
Browse files

add libraries parmetis depends on for the check, required when parmetis is static

parent cd0d395d
......@@ -3,7 +3,7 @@
# @copyright (c) 2009-2014 The University of Tennessee and The University
# of Tennessee Research Foundation.
# All rights reserved.
# @copyright (c) 2012-2014 Inria. All rights reserved.
# @copyright (c) 2012-2017 Inria. All rights reserved.
# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
#
###
......@@ -14,6 +14,10 @@
# [REQUIRED] # Fail with error if parmetis is not found
# )
#
# PARMETIS depends on the following libraries:
# - METIS
# - MPI
#
# This module finds headers and parmetis library.
# Results are reported in variables:
# PARMETIS_FOUND - True if headers and requested libraries were found
......@@ -23,9 +27,12 @@
#
# The user can give specific paths where to find the libraries adding cmake
# options at configure (ex: cmake path/to/project -DPARMETIS_DIR=path/to/parmetis):
# PARMETIS_DIR - Where to find the base directory of parmetis
# PARMETIS_INCDIR - Where to find the header files
# PARMETIS_LIBDIR - Where to find the library files
# PARMETIS_DIR - Where to find the base directory of parmetis
# PARMETIS_INCDIR - Where to find the header files
# PARMETIS_LIBDIR - Where to find the library files
# PARMETIS_INCLUDE_DIRS_DEP - parmetis + dependencies include directories
# PARMETIS_LIBRARY_DIRS_DEP - parmetis + dependencies link directories
# PARMETIS_LIBRARIES_DEP - parmetis libraries + dependencies
# The module can also look for the following environment variables if paths
# are not given as cmake variable: PARMETIS_DIR, PARMETIS_INCDIR, PARMETIS_LIBDIR
......@@ -34,7 +41,7 @@
# Copyright 2012-2013 Emmanuel Agullo
# Copyright 2012-2013 Mathieu Faverge
# Copyright 2012 Cedric Castagnede
# Copyright 2013 Florent Pruvost
# Copyright 2017 Florent Pruvost
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file MORSE-Copyright.txt for details.
......@@ -53,6 +60,23 @@ if (NOT PARMETIS_FOUND)
endif()
endif()
# PARMETIS depends on METIS, try to find it
if (NOT METIS_FOUND)
if(PARMETIS_FIND_REQUIRED)
find_package(METIS REQUIRED)
else()
find_package(METIS)
endif()
endif()
# PARMETIS depends on MPI, try to find it
if (NOT MPI_FOUND)
if(PARMETIS_FIND_REQUIRED)
find_package(MPI REQUIRED)
else()
find_package(MPI)
endif()
endif()
# Looking for include
# -------------------
......@@ -205,6 +229,31 @@ if(PARMETIS_LIBRARIES)
set(REQUIRED_LIBDIRS "${PARMETIS_LIBRARY_DIRS}")
endif()
set(REQUIRED_LIBS "${PARMETIS_LIBRARIES}")
# METIS
if (METIS_FOUND)
if (METIS_INCLUDE_DIRS)
list(APPEND REQUIRED_INCDIRS "${METIS_INCLUDE_DIRS}")
endif()
foreach(libdir ${METIS_LIBRARY_DIRS})
if (libdir)
list(APPEND REQUIRED_LIBDIRS "${libdir}")
endif()
endforeach()
list(APPEND REQUIRED_LIBS "${METIS_LIBRARIES}")
endif()
# MPI
if (MPI_FOUND)
if (MPI_C_INCLUDE_PATH)
list(APPEND REQUIRED_INCDIRS "${MPI_C_INCLUDE_PATH}")
endif()
if (MPI_C_LINK_FLAGS)
if (${MPI_C_LINK_FLAGS} MATCHES " -")
string(REGEX REPLACE " -" "-" MPI_C_LINK_FLAGS ${MPI_C_LINK_FLAGS})
endif()
list(APPEND REQUIRED_LDFLAGS "${MPI_C_LINK_FLAGS}")
endif()
list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}")
endif()
# m
find_library(M_LIBRARY NAMES m)
mark_as_advanced(M_LIBRARY)
......@@ -227,7 +276,16 @@ if(PARMETIS_LIBRARIES)
check_function_exists(ParMETIS_V3_NodeND PARMETIS_WORKS)
mark_as_advanced(PARMETIS_WORKS)
if(NOT PARMETIS_WORKS)
if(PARMETIS_WORKS)
# save link with dependencies
set(PARMETIS_LIBRARIES_DEP "${REQUIRED_LIBS}")
set(PARMETIS_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
set(PARMETIS_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
set(PARMETIS_LINKER_FLAGS "${REQUIRED_LDFLAGS}")
list(REMOVE_DUPLICATES PARMETIS_LIBRARY_DIRS_DEP)
list(REMOVE_DUPLICATES PARMETIS_INCLUDE_DIRS_DEP)
list(REMOVE_DUPLICATES PARMETIS_LINKER_FLAGS)
else()
if(NOT PARMETIS_FIND_QUIETLY)
message(STATUS "Looking for PARMETIS : test of ParMETIS_V3_NodeND with PARMETIS library fails")
message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
......
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