ThirdPartyMPI.cmake 3.05 KB
Newer Older
Dave Moxey's avatar
Dave Moxey committed
1 2 3 4 5 6 7 8 9
########################################################################
#
# ThirdParty configuration for Nektar++
#
# MPI
#
########################################################################

OPTION(NEKTAR_USE_MPI "Use MPI for parallelisation." OFF)
10 11 12 13

CMAKE_DEPENDENT_OPTION(THIRDPARTY_BUILD_GSMPI
    "Build GSMPI if needed" ON
    "NEKTAR_USE_MPI" OFF)
14 15

IF( NEKTAR_USE_MPI )
16 17 18 19 20 21
    # First check to see if our compiler has MPI built in to avoid linking libraries etc.
    INCLUDE (CheckIncludeFiles)
    INCLUDE (CheckFunctionExists)
    CHECK_INCLUDE_FILES  (mpi.h    HAVE_MPI_H)
    CHECK_FUNCTION_EXISTS(MPI_Send HAVE_MPI_SEND)

Dave Moxey's avatar
Dave Moxey committed
22
    SET(MPI_BUILTIN OFF CACHE INTERNAL
Dave Moxey's avatar
Dave Moxey committed
23
        "Determines whether MPI is built into the compiler")
24 25 26 27 28 29 30 31
    IF (NOT "${HAVE_MPI_H}" OR NOT "${HAVE_MPI_SEND}")
        INCLUDE (FindMPI)
        MARK_AS_ADVANCED(MPI_LIBRARY)
        MARK_AS_ADVANCED(MPI_EXTRA_LIBRARY)
        MARK_AS_ADVANCED(file_cmd)
        INCLUDE_DIRECTORIES( ${MPI_INCLUDE_PATH} )
        MESSAGE(STATUS "Found MPI: ${MPI_LIBRARY}")
    ELSE()
Dave Moxey's avatar
Dave Moxey committed
32
        SET(MPI_BUILTIN ON)
33
        MESSAGE(STATUS "Found MPI: built in")
34 35 36 37
	FIND_PROGRAM(HAVE_APRUN aprun)
	IF (HAVE_APRUN)
	    # Probably on Cray
            SET(MPIEXEC "aprun" CACHE STRING "MPI job launching command")
Dave Moxey's avatar
Dave Moxey committed
38 39
	    SET(MPIEXEC_NUMPROC_FLAG "-n" CACHE STRING
                "MPI job launcher flag to specify number of processes")
40 41
	ELSE()
            SET(MPIEXEC "mpirun" CACHE STRING "MPI job launching command")
Dave Moxey's avatar
Dave Moxey committed
42 43
	    SET(MPIEXEC_NUMPROC_FLAG "-np" CACHE STRING
                "MPI job launcher flag to specify number of processes")
44 45 46 47
	ENDIF()
	MARK_AS_ADVANCED(MPIEXEC)
	MARK_AS_ADVANCED(MPIEXEC_NUMPROC_FLAG)
	UNSET(HAVE_APRUN CACHE)
48 49
    ENDIF()

50
    ADD_DEFINITIONS(-DNEKTAR_USE_MPI)
51

52 53
    IF (THIRDPARTY_BUILD_GSMPI)
        EXTERNALPROJECT_ADD(
54
            gsmpi-1.2.1
Dave Moxey's avatar
Dave Moxey committed
55
            URL ${TPURL}/gsmpi-1.2.1.tar.bz2
Dave Moxey's avatar
Dave Moxey committed
56
            URL_MD5 18dcb4cd1dcc7876173465c404b1142d
57
            STAMP_DIR ${TPBUILD}/stamp
58
            DOWNLOAD_DIR ${TPSRC}
59 60 61
            SOURCE_DIR ${TPSRC}/gsmpi-1.2.1
            BINARY_DIR ${TPBUILD}/gsmpi-1.2.1
            TMP_DIR ${TPBUILD}/gsmpi-1.2.1-tmp
62
            INSTALL_DIR ${TPDIST}
Dave Moxey's avatar
Dave Moxey committed
63
            CONFIGURE_COMMAND
64
                ${CMAKE_COMMAND}
65
                -G ${CMAKE_GENERATOR}
66 67 68
                -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
                -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
                -DCMAKE_BUILD_TYPE:STRING=Debug
69
                -DCMAKE_INSTALL_PREFIX:PATH=${TPDIST}
70
                ${TPSRC}/gsmpi-1.2.1
71
        )
72
        SET(GSMPI_LIBRARY gsmpi CACHE FILEPATH
73
            "GSMPI path" FORCE)
74
        MARK_AS_ADVANCED(GSMPI_LIBRARY)
Chris Cantwell's avatar
Chris Cantwell committed
75 76
        SET(XXT_LIBRARY xxt CACHE FILEPATH
            "XXT path" FORCE)
77
        MARK_AS_ADVANCED(XXT_LIBRARY)
78 79
        MESSAGE(STATUS "Build GSMPI: ${TPDIST}/lib/lib${GSMPI_LIBRARY}.a")
        MESSAGE(STATUS "Build XXT: ${TPDIST}/lib/lib${XXT_LIBRARY}.a")
80
    ELSE (THIRDPARTY_BUILD_GSMPI)
81
        ADD_CUSTOM_TARGET(gsmpi-1.2.1 ALL)
82
        INCLUDE (FindGSMPI)
Chris Cantwell's avatar
Chris Cantwell committed
83
        INCLUDE (FindXXT)
84 85 86
    ENDIF (THIRDPARTY_BUILD_GSMPI)
ENDIF( NEKTAR_USE_MPI )