ThirdPartyMPI.cmake 2.9 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 )
Dave Moxey's avatar
Dave Moxey committed
16 17
    # First check to see if our compiler has MPI built in to avoid linking
    # libraries etc.
18 19 20 21 22
    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
23
    SET(MPI_BUILTIN OFF CACHE INTERNAL
Dave Moxey's avatar
Dave Moxey committed
24
        "Determines whether MPI is built into the compiler")
25
    IF (NOT "${HAVE_MPI_H}" OR NOT "${HAVE_MPI_SEND}")
Kilian Lackhove's avatar
Kilian Lackhove committed
26
        FIND_PACKAGE(MPI REQUIRED)
Dave Moxey's avatar
Dave Moxey committed
27

28
        INCLUDE_DIRECTORIES(SYSTEM ${MPI_CXX_INCLUDE_PATH} )
Kilian Lackhove's avatar
Kilian Lackhove committed
29
        MESSAGE(STATUS "Found MPI: ${MPI_CXX_LIBRARIES}")
30
    ELSE()
Dave Moxey's avatar
Dave Moxey committed
31
        SET(MPI_BUILTIN ON)
32
        MESSAGE(STATUS "Found MPI: built in")
33 34 35 36
	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
37 38
	    SET(MPIEXEC_NUMPROC_FLAG "-n" CACHE STRING
                "MPI job launcher flag to specify number of processes")
39 40
	ELSE()
            SET(MPIEXEC "mpirun" CACHE STRING "MPI job launching command")
Dave Moxey's avatar
Dave Moxey committed
41 42
	    SET(MPIEXEC_NUMPROC_FLAG "-np" CACHE STRING
                "MPI job launcher flag to specify number of processes")
43 44 45 46
	ENDIF()
	MARK_AS_ADVANCED(MPIEXEC)
	MARK_AS_ADVANCED(MPIEXEC_NUMPROC_FLAG)
	UNSET(HAVE_APRUN CACHE)
47 48
    ENDIF()

49
    ADD_DEFINITIONS(-DNEKTAR_USE_MPI)
50

51 52
    IF (THIRDPARTY_BUILD_GSMPI)
        EXTERNALPROJECT_ADD(
53
            gsmpi-1.2.1
Dave Moxey's avatar
Dave Moxey committed
54 55
            URL ${TPURL}/gsmpi-1.2.1_1.tar.bz2
            URL_MD5 c247ed68134a65b8033c639277e46825
56
            STAMP_DIR ${TPBUILD}/stamp
57
            DOWNLOAD_DIR ${TPSRC}
58 59 60
            SOURCE_DIR ${TPSRC}/gsmpi-1.2.1
            BINARY_DIR ${TPBUILD}/gsmpi-1.2.1
            TMP_DIR ${TPBUILD}/gsmpi-1.2.1-tmp
61
            INSTALL_DIR ${TPDIST}
Dave Moxey's avatar
Dave Moxey committed
62
            CONFIGURE_COMMAND
63
                ${CMAKE_COMMAND}
64
                -G ${CMAKE_GENERATOR}
65 66 67
                -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
                -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
                -DCMAKE_BUILD_TYPE:STRING=Debug
68
                -DCMAKE_INSTALL_PREFIX:PATH=${TPDIST}
69
                ${TPSRC}/gsmpi-1.2.1
70
        )
71 72
        THIRDPARTY_LIBRARY(GSMPI_LIBRARY STATIC gsmpi DESCRIPTION "GSMPI Library")
        THIRDPARTY_LIBRARY(XXT_LIBRARY STATIC xxt DESCRIPTION "XXT Library")
73 74
        MARK_AS_ADVANCED(GSMPI_LIBRARY)
        MARK_AS_ADVANCED(XXT_LIBRARY)
75 76
        MESSAGE(STATUS "Build GSMPI: ${GSMPI_LIBRARY}")
        MESSAGE(STATUS "Build XXT: ${XXT_LIBRARY}")
77
    ELSE (THIRDPARTY_BUILD_GSMPI)
78
        MESSAGE(FATAL_ERROR "Must build GSMPI and XXT")
79 80 81
    ENDIF (THIRDPARTY_BUILD_GSMPI)
ENDIF( NEKTAR_USE_MPI )