scivision / mumps

MUMPS via CMake
http://mumps-solver.org
MIT License
115 stars 46 forks source link

How to compile with parmetis? #75

Closed miaodi closed 6 months ago

miaodi commented 8 months ago

I tried to compile mumps with parmetis. I have installed parmetis to a folder ($PARMETIS_ROOT) and tried to configure the cmake project with: cmake .. -Dparmetis=1 -Dparallel=1 -DMETIS_LIBRARY=${PARMETIS_ROOT}/libparmetis.so -DMETIS_INCLUDE_DIR=${PARMETIS_ROOT}/include

and i got the following error:

CMake Error at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message): Could NOT find METIS (missing: parallel) Call Stack (most recent call first): /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE) cmake/FindMETIS.cmake:59 (find_package_handle_standard_args) CMakeLists.txt:85 (find_package)

miaodi commented 8 months ago

My parmetis version is 4.0.3. It seems that when parmetis is enable, mumps needs both metis and parmetis to finish the compilation.

I modified FindMETIS.cmake:

if("parallel" IN_LIST METIS_FIND_COMPONENTS)
  find_library(PARMETIS_LIBRARY
    NAMES parmetis
    PATH_SUFFIXES METIS libmetis
    DOC "ParMETIS library"
    )
  if(PARMETIS_LIBRARY)
    set(METIS_parallel_FOUND true)

    find_path(PARMETIS_INCLUDE_DIR
    NAMES parmetis.h
    PATH_SUFFIXES METIS openmpi-x86_64 mpich-x86_64 
    DOC "METIS include directory"
    )
  endif()
endif()

find_library(METIS_LIBRARY
  NAMES metis
  PATH_SUFFIXES METIS libmetis
  DOC "METIS library"
  )

find_path(METIS_INCLUDE_DIR
NAMES metis.h
PATH_SUFFIXES METIS openmpi-x86_64 mpich-x86_64
DOC "METIS include directory"
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(METIS
REQUIRED_VARS METIS_LIBRARY METIS_INCLUDE_DIR
HANDLE_COMPONENTS
)

if(METIS_FOUND)

set(METIS_LIBRARIES ${PARMETIS_LIBRARY} ${METIS_LIBRARY})
set(METIS_INCLUDE_DIRS ${METIS_INCLUDE_DIR} ${PARMETIS_INCLUDE_DIR})

message(VERBOSE "METIS libraries: ${METIS_LIBRARIES}
METIS include directories: ${METIS_INCLUDE_DIRS}")

if(NOT TARGET METIS::METIS)
  add_library(METIS::METIS INTERFACE IMPORTED)
  set_property(TARGET METIS::METIS PROPERTY INTERFACE_LINK_LIBRARIES "${METIS_LIBRARIES}")
  set_property(TARGET METIS::METIS PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${METIS_INCLUDE_DIRS}")
endif()
endif(METIS_FOUND)

mark_as_advanced(METIS_INCLUDE_DIR METIS_LIBRARY PARMETIS_LIBRARY)

and now it can compile mumps with parmetis (cmake .. -Dparmetis=1 -Dparallel=1 -DMETIS_ROOT=/home/dimiao/installed/metis -DPARMETIS_LIBRARY=/home/dimiao/installed/parmetis/lib/libparmetis.so -DPARMETIS_INCLUDE_DIR=/home/dimiao/installed/parmetis/include/).