Commit caf2954c authored by Andrew J. Burns (Cont's avatar Andrew J. Burns (Cont

Improving the auto detection for MPI4PY and HDF5

parent 09136d04
# - FindMPI4PY
# Find mpi4py includes and library
# This module defines:
# MPI4PY_INCLUDE_DIR, where to find mpi4py.h, etc.
# MPI4PY_FOUND
# https://compacc.fnal.gov/projects/repositories/entry/synergia2/CMake/FindMPI4PY.cmake?rev=c147eafb60728606af4fe7b1b161a660df142e9a
if(NOT MPI4PY_INCLUDE_DIR)
execute_process(COMMAND
"${PYTHON_EXECUTABLE}" "-c" "import mpi4py; print mpi4py.get_include()"
OUTPUT_VARIABLE MPI4PY_INCLUDE_DIR
RESULT_VARIABLE MPI4PY_COMMAND_RESULT
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(MPI4PY_COMMAND_RESULT)
message("jfa: mpi4py not found")
set(MPI4PY_FOUND FALSE)
else(MPI4PY_COMMAND_RESULT)
if (MPI4PY_INCLUDE_DIR MATCHES "Traceback")
message("jfa: mpi4py matches traceback")
## Did not successfully include MPI4PY
set(MPI4PY_FOUND FALSE)
else (MPI4PY_INCLUDE_DIR MATCHES "Traceback")
## successful
set(MPI4PY_FOUND TRUE)
set(MPI4PY_INCLUDE_DIR ${MPI4PY_INCLUDE_DIR} CACHE STRING "mpi4py include path")
endif (MPI4PY_INCLUDE_DIR MATCHES "Traceback")
endif(MPI4PY_COMMAND_RESULT)
else(NOT MPI4PY_INCLUDE_DIR)
set(MPI4PY_FOUND TRUE)
endif(NOT MPI4PY_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MPI4PY DEFAULT_MSG MPI4PY_INCLUDE_DIR)
......@@ -53,6 +53,13 @@ option(XDMF_WRAP_JAVA OFF)
option(XDMF_BUILD_DSM OFF)
if(XDMF_BUILD_DSM)
find_package(MPI REQUIRED)
if(MPI_FOUND)
include_directories(${MPI_INCLUDE_PATH})
set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY})
get_filename_component(MPI_LIBRARY_DIR ${MPI_LIBRARY} PATH)
set(XDMF_LIBRARY_DIRS ${XDMF_LIBRARY_DIRS} ${MPI_LIBRARY_DIR})
endif(MPI_FOUND)
option(XDMF_BUILD_DSM_THREADS ON)
if (XDMF_WRAP_PYTHON)
mark_as_advanced(FORCE PYTHON_INCLUDE_MPI4PY_DIR)
......
......@@ -35,6 +35,16 @@ if(Boost_FOUND)
mark_as_advanced(FORCE Boost_INCLUDE_DIR)
endif(Boost_FOUND)
# Find HDF5_ROOT if not set
if ("$ENV{HDF5_ROOT}" STREQUAL "")
find_file (HDF5_LIB libhdf5.so HINTS ENV LD_LIBRARY_PATH)
if (NOT "${HDF5_LIB}" STREQUAL "")
get_filename_component(HDF5_LIBRARY_DIR "${HDF5_LIB}" PATH)
get_filename_component(HDF5_ROOT "${HDF5_LIBRARY_DIR}/../" ABSOLUTE)
set(ENV{HDF5_ROOT} ${HDF5_ROOT})
endif (NOT "${HDF5_LIB}" STREQUAL "")
endif ("$ENV{HDF5_ROOT}" STREQUAL "")
mark_as_advanced(CLEAR HDF5_C_INCLUDE_DIR)
mark_as_advanced(CLEAR HDF5_hdf5_LIBRARY_DEBUG)
mark_as_advanced(CLEAR HDF5_hdf5_LIBRARY_RELEASE)
......@@ -51,16 +61,21 @@ if(HDF5_FOUND)
# FIXME: Would like to get this info from HDF5 so we don't have conflicting
# MPI versions
if(HDF5_IS_PARALLEL)
find_package(MPI REQUIRED)
if(MPI_FOUND)
include_directories(${MPI_INCLUDE_PATH})
set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY})
get_filename_component(MPI_LIBRARY_DIR ${MPI_LIBRARY} PATH)
set(XDMF_LIBRARY_DIRS ${XDMF_LIBRARY_DIRS} ${MPI_LIBRARY_DIR})
endif(MPI_FOUND)
if (NOT MPI_FOUND)
find_package(MPI REQUIRED)
if(MPI_FOUND)
include_directories(${MPI_INCLUDE_PATH})
set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY})
get_filename_component(MPI_LIBRARY_DIR ${MPI_LIBRARY} PATH)
set(XDMF_LIBRARY_DIRS ${XDMF_LIBRARY_DIRS} ${MPI_LIBRARY_DIR})
endif(MPI_FOUND)
endif (NOT MPI_FOUND)
endif(HDF5_IS_PARALLEL)
get_filename_component(HDF5_ROOT "${HDF5_INCLUDE_DIR}/../" REALPATH)
set(HDF5_BINARY_DIRS ${HDF5_ROOT}/bin ${HDF5_ROOT}/dll)
if (NOT HDF5_LIBRARIES)
find_library (HDF5_LIBRARIES hdf5 HINTS ${HDF5_ROOT} ENV LD_LIBRARY_PATH)
endif (NOT HDF5_LIBRARIES)
set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${HDF5_LIBRARIES})
set(XDMF_HDF5_BINARY_DIRS ${HDF5_BINARY_DIRS} PARENT_SCOPE)
set(XDMF_BINARIES ${XDMF_BINARIES} ${HDF5_BINARY_DIRS})
......
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