enable_hypre.cmake 1.6 KB
Newer Older
1 2 3 4 5 6
macro(enable_hypre _FLAGS_ _INC_DIRS_ _LIBS_)
    if (${ARGC} GREATER 3)
      set(LINK_EXECUTABLE ON)
    else ()
      set(LINK_EXECUTABLE OFF)
    endif ()
7

8 9 10 11 12 13 14 15 16 17 18 19
    # MPI is required
    if (LINK_EXECUTABLE)
      enable_mpi(${_FLAGS_} ${_INC_DIRS_} ${_LIBS_} ON)
    else ()
      enable_mpi(${_FLAGS_} ${_INC_DIRS_} ${_LIBS_})
    endif (LINK_EXECUTABLE)


    find_file(_HYPRE_H HYPRE.h
      HINTS ${PETSC_INCLUDE_DIRS})

    if (_HYPRE_H)
Praetorius, Simon's avatar
Praetorius, Simon committed
20
      get_filename_component(HYPRE_INCLUDE_DIRECTORIES ${_HYPRE_H} PATH)
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
      list(APPEND ${_INC_DIRS_} ${HYPRE_INCLUDE_DIRECTORIES})
    endif (_HYPRE_H)

    if (LINK_EXECUTABLE)
      find_library(_HYPRE_LIB HYPRE
        HINTS ${PETSC_LIBRARY_DIRS})

      if(_HYPRE_LIB)
        get_filename_component(HLIB_PATH ${_HYPRE_LIB} PATH)
        file(GLOB HYPRE_OTHER ${HLIB_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}HYPRE*${CMAKE_SHARED_LIBRARY_SUFFIX})
        list(APPEND ${_LIBS_} ${_HYPRE_LIB} ${HYPRE_OTHER})
      endif (_HYPRE_LIB)

      # lapack library is required
      find_library(LAPACK_LIB
        NAMES lapack flapack
        HINTS ${LAPACK_DIR}/lib ${PETSC_LIBRARY_DIRS} ${PETSC_DIR}/lib)
      if (LAPACK_LIB)
        set(LAPACK_LIBRARIES ${LAPACK_LIB})
      else (LAPACK_LIB)
        find_package(LAPACK REQUIRED)
      endif (LAPACK_LIB)
      list(APPEND ${_LIBS_} ${LAPACK_LIBRARIES})
    endif (LINK_EXECUTABLE)


    if (_HYPRE_H AND (NOT LINK_EXECUTABLE OR _HYPRE_LIB))
      set(HAVE_HYPRE ON)
      list(APPEND ${_FLAGS_} "-DMTL_HAS_HYPRE")
    else ()
      set(HAVE_HYPRE OFF)
    endif ()

endmacro(enable_hypre)