Merge pull request #1 from jorgekva/linsolver_petsc
Improvements to FindPetsc.cmake module
This commit is contained in:
commit
ad7b064556
@ -20,36 +20,46 @@ if (CMAKE_SIZEOF_VOID_P)
|
|||||||
math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}")
|
math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}")
|
||||||
endif (CMAKE_SIZEOF_VOID_P)
|
endif (CMAKE_SIZEOF_VOID_P)
|
||||||
|
|
||||||
# look for a system-wide BLAS library
|
# if PETSC_ROOT is set, then this is the only place searched for petsc headers
|
||||||
find_package(BLAS QUIET)
|
# and includes
|
||||||
set(PETSC_BLAS_LIBRARY "")
|
set(_no_default_path "")
|
||||||
if (BLAS_FOUND)
|
if(PETSC_ROOT)
|
||||||
list(APPEND PETSC_BLAS_LIBRARY "${BLAS_LIBRARIES}")
|
set (_no_default_path "NO_DEFAULT_PATH")
|
||||||
elseif(PETSC_ROOT)
|
|
||||||
find_library(PETST_BLAS_LIBRARY
|
|
||||||
NAME "blas"
|
|
||||||
PATH ${PETSC_ROOT}
|
|
||||||
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
|
||||||
NO_DEFAULT_PATH)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# look for a system-wide BLAS library
|
||||||
|
set(PETSC_BLAS_LIBRARY "")
|
||||||
|
find_package(BLAS QUIET)
|
||||||
|
list(APPEND PETSC_BLAS_LIBRARY "${BLAS_LIBRARIES}")
|
||||||
|
|
||||||
|
# if BLAS wasn't found, look for it in PETSC_ROOT. Won't search if
|
||||||
|
# PETSC_BLAS_LIBRARY is set.
|
||||||
|
find_library(PETSC_BLAS_LIBRARY
|
||||||
|
NAME "blas"
|
||||||
|
PATH ${PETSC_ROOT}
|
||||||
|
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||||
|
${_no_default_path}
|
||||||
|
)
|
||||||
|
|
||||||
# print message if there was still no blas found!
|
# print message if there was still no blas found!
|
||||||
if(NOT BLAS_FOUND AND NOT PETSC_BLAS_LIBRARY)
|
if(NOT BLAS_FOUND AND NOT PETSC_BLAS_LIBRARY)
|
||||||
message(STATUS "BLAS not found but required for PETSC")
|
message(STATUS "BLAS not found but required for PETSC")
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
list(APPEND CMAKE_REQUIRED_LIBRARIES "${PETSC_BLAS_LIBRARY}")
|
list(APPEND CMAKE_REQUIRED_LIBRARIES "${PETSC_BLAS_LIBRARY}")
|
||||||
find_package(LAPACK QUIET)
|
|
||||||
|
|
||||||
set(PETSC_LAPACK_LIBRARY "")
|
set(PETSC_LAPACK_LIBRARY "")
|
||||||
if (LAPACK_FOUND)
|
find_package(LAPACK QUIET)
|
||||||
list(APPEND PETSC_LAPACK_LIBRARY "${LAPACK_LIBRARIES}")
|
list(APPEND PETSC_LAPACK_LIBRARY "${LAPACK_LIBRARIES}")
|
||||||
elseif(PETSC_ROOT)
|
|
||||||
find_library(PETST_LAPACK_LIBRARY
|
# if LAPACK wasn't found, look for it in PETSC_ROOT
|
||||||
NAME "lapack"
|
find_library(PETSC_LAPACK_LIBRARY
|
||||||
PATH ${PETSC_ROOT}
|
NAME "lapack"
|
||||||
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
PATH ${PETSC_ROOT}
|
||||||
NO_DEFAULT_PATH)
|
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||||
endif()
|
${_no_default_path}
|
||||||
|
)
|
||||||
|
|
||||||
# print message if there was still no blas found!
|
# print message if there was still no blas found!
|
||||||
if(NOT LAPACK_FOUND AND NOT PETSC_LAPACK_LIBRARY)
|
if(NOT LAPACK_FOUND AND NOT PETSC_LAPACK_LIBRARY)
|
||||||
message(STATUS "LAPACK not found but required for PETSC")
|
message(STATUS "LAPACK not found but required for PETSC")
|
||||||
@ -62,47 +72,70 @@ if (X11_FOUND)
|
|||||||
list(APPEND PETSC_X11_LIBRARY "${X11_LIBRARIES}")
|
list(APPEND PETSC_X11_LIBRARY "${X11_LIBRARIES}")
|
||||||
endif()
|
endif()
|
||||||
list(APPEND CMAKE_REQUIRED_LIBRARIES "${PETSC_X11_LIBRARY}")
|
list(APPEND CMAKE_REQUIRED_LIBRARIES "${PETSC_X11_LIBRARY}")
|
||||||
|
|
||||||
# only probe if we haven't a path in our cache
|
# only probe if we haven't a path in our cache
|
||||||
if (Petsc_ROOT)
|
if (Petsc_ROOT)
|
||||||
set (PETSC_ROOT "${Petsc_ROOT}")
|
set (PETSC_ROOT "${Petsc_ROOT}")
|
||||||
endif (Petsc_ROOT)
|
endif (Petsc_ROOT)
|
||||||
if (NOT PETSC_NORMAL_INCLUDE_DIR)
|
|
||||||
if (PETSC_ROOT)
|
find_path (PETSC_NORMAL_INCLUDE_DIR
|
||||||
find_path (PETSC_NORMAL_INCLUDE_DIR
|
NAMES "petsc.h"
|
||||||
NAMES "petsc.h"
|
PATHS ${PETSC_ROOT}
|
||||||
PATHS ${PETSC_ROOT}
|
PATH_SUFFIXES "petsc-3.4.4" "include" "petsc"
|
||||||
PATH_SUFFIXES "petsc-3.4.4" "include"
|
${_no_default_path}
|
||||||
NO_DEFAULT_PATH
|
)
|
||||||
)
|
|
||||||
endif (PETSC_ROOT)
|
# if parallel computing is explicitly enabled - reuse the paths and links from
|
||||||
endif (NOT PETSC_NORMAL_INCLUDE_DIR)
|
# OpmMainLib + OpmFind
|
||||||
if (NOT PETSC_MPIUNI_INCLUDE_DIR)
|
# this needs to be called explicitly as FindPetsc runs before OpmMainLib starts
|
||||||
if (PETSC_ROOT)
|
# looking for MPI (for some reason). Ideally this isn't necessary
|
||||||
find_path (PETSC_MPIUNI_INCLUDE_DIR
|
if(USE_MPI)
|
||||||
NAMES "mpi.h"
|
find_package(MPI)
|
||||||
PATHS ${PETSC_ROOT}/include
|
endif()
|
||||||
PATH_SUFFIXES "mpiuni"
|
|
||||||
NO_DEFAULT_PATH
|
set(PETSC_MPI_FOUND ${MPI_FOUND})
|
||||||
)
|
set(PETSC_MPI_INCLUDE_DIRS ${MPI_INCLUDE_PATH})
|
||||||
endif (PETSC_ROOT)
|
set(PETSC_MPI_LIBRARIES ${MPI_LIBRARIES})
|
||||||
endif (NOT PETSC_MPIUNI_INCLUDE_DIR)
|
|
||||||
|
# fallback - use the petsc provided implementation of serial MPI.
|
||||||
|
if (NOT PETSC_MPI_INCLUDE_DIRS)
|
||||||
|
message(STATUS "Building without MPI support - looking for PETSc provided serial implementation")
|
||||||
|
find_path (PETSC_MPI_INCLUDE_DIRS
|
||||||
|
NAMES "mpi.h"
|
||||||
|
PATHS ${PETSC_ROOT}/include
|
||||||
|
PATH_SUFFIXES "mpiuni"
|
||||||
|
${_no_default_path}
|
||||||
|
)
|
||||||
|
|
||||||
|
if(PETSC_MPI_INCLUDE_DIRS)
|
||||||
|
set(PETSC_MPI_FOUND 1)
|
||||||
|
endif(PETSC_MPI_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
endif(NOT PETSC_MPI_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
# couldn't find any usable mpi implementation - abort
|
||||||
|
if(NOT PETSC_MPI_FOUND)
|
||||||
|
message(STATUS "Could not find any suitable MPI implementation.")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
# look for actual Petsc library
|
# look for actual Petsc library
|
||||||
if (NOT PETSC_LIBRARY)
|
find_library(PETSC_LIBRARY
|
||||||
find_library(PETSC_LIBRARY
|
|
||||||
NAMES "petsc-3.4.3" "petsc-3.4.4" "petsc"
|
NAMES "petsc-3.4.3" "petsc-3.4.4" "petsc"
|
||||||
PATHS ${PETSC_ROOT}
|
PATHS ${PETSC_ROOT}
|
||||||
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||||
NO_DEFAULT_PATH
|
${_no_default_path}
|
||||||
)
|
)
|
||||||
endif()
|
|
||||||
if(NOT PETSC_LIBRARY)
|
if(NOT PETSC_LIBRARY)
|
||||||
message(STATUS "Directory with the SuperLU library not found")
|
message(STATUS "Could not find the PETSc library")
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
list(APPEND CMAKE_REQUIRED_LIBRARIES "${PETSC_LIBRARY}")
|
|
||||||
|
|
||||||
if (PETSC_MPIUNI_INCLUDE_DIR AND PETSC_NORMAL_INCLUDE_DIR)
|
list(APPEND CMAKE_REQUIRED_LIBRARIES "${PETSC_LIBRARY}" "${PETSC_MPI_LIBRARIES}")
|
||||||
list (APPEND PETSC_INCLUDE_DIR ${PETSC_MPIUNI_INCLUDE_DIR} ${PETSC_NORMAL_INCLUDE_DIR})
|
|
||||||
|
if (PETSC_MPI_INCLUDE_DIRS AND PETSC_NORMAL_INCLUDE_DIR)
|
||||||
|
list (APPEND PETSC_INCLUDE_DIR ${PETSC_MPI_INCLUDE_DIRS} ${PETSC_NORMAL_INCLUDE_DIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
@ -111,18 +144,10 @@ mark_as_advanced(PETSC_INCLUDE_DIR PETSC_LIBRARY)
|
|||||||
|
|
||||||
# if both headers and library are found, store results
|
# if both headers and library are found, store results
|
||||||
if(PETSC_FOUND)
|
if(PETSC_FOUND)
|
||||||
set(PETSC_INCLUDE_DIRS ${PETSC_INCLUDE_DIR})
|
set(PETSC_INCLUDE_DIRS ${PETSC_INCLUDE_DIR})
|
||||||
|
set(PETSC_LIBRARIES ${PETSC_LIBRARY})
|
||||||
|
|
||||||
set(PETSC_LIBRARIES ${PETSC_LIBRARY})
|
|
||||||
|
|
||||||
if (PETSC_BLAS_LIBRARY)
|
|
||||||
list(APPEND PETSC_LIBRARIES ${PETSC_BLAS_LIBRARY})
|
list(APPEND PETSC_LIBRARIES ${PETSC_BLAS_LIBRARY})
|
||||||
endif()
|
|
||||||
if (PETSC_LAPACK_LIBRARY)
|
|
||||||
list(APPEND PETSC_LIBRARIES ${PETSC_LAPACK_LIBRARY})
|
list(APPEND PETSC_LIBRARIES ${PETSC_LAPACK_LIBRARY})
|
||||||
endif()
|
|
||||||
if (PETSC_X11_LIBRARY)
|
|
||||||
list(APPEND PETSC_LIBRARIES ${PETSC_X11_LIBRARY})
|
list(APPEND PETSC_LIBRARIES ${PETSC_X11_LIBRARY})
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user