ThirdPartyMPI.cmake 2.76 KB
Newer Older
1 2 3 4 5
OPTION(NEKTAR_USE_MPI "Use MPICH2 for parallelisation." OFF)

CMAKE_DEPENDENT_OPTION(THIRDPARTY_BUILD_GSMPI
    "Build GSMPI if needed" ON
    "NEKTAR_USE_MPI" OFF)
6 7

IF( NEKTAR_USE_MPI )
8 9 10 11 12 13
    # 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
14 15
    SET(MPI_BUILTIN OFF CACHE INTERNAL
        "Determines whether MPI is built in")
16 17 18 19 20 21 22 23
    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
24
        SET(MPI_BUILTIN ON)
25
        MESSAGE(STATUS "Found MPI: built in")
26 27 28 29 30 31 32 33 34 35 36 37
	FIND_PROGRAM(HAVE_APRUN aprun)
	IF (HAVE_APRUN)
	    # Probably on Cray
            SET(MPIEXEC "aprun" CACHE STRING "MPI job launching command")
	    SET(MPIEXEC_NUMPROC_FLAG "-n" CACHE STRING "MPI job launcher flag to specify number of processes")
	ELSE()
            SET(MPIEXEC "mpirun" CACHE STRING "MPI job launching command")
	    SET(MPIEXEC_NUMPROC_FLAG "-np" CACHE STRING "MPI job launcher flag to specify number of processes")
	ENDIF()
	MARK_AS_ADVANCED(MPIEXEC)
	MARK_AS_ADVANCED(MPIEXEC_NUMPROC_FLAG)
	UNSET(HAVE_APRUN CACHE)
38 39
    ENDIF()

40
    ADD_DEFINITIONS(-DNEKTAR_USE_MPI)
41

42 43
    IF (THIRDPARTY_BUILD_GSMPI)
        EXTERNALPROJECT_ADD(
44 45 46
            gsmpi-1.2
            URL ${TPURL}/gsmpi-1.2.tar.bz2
            URL_MD5 35901be16791bfdeafa9c4d0e06d189b
47
            STAMP_DIR ${TPBUILD}/stamp
48
            DOWNLOAD_DIR ${TPSRC}
49 50 51 52
            SOURCE_DIR ${TPSRC}/gsmpi-1.2
            BINARY_DIR ${TPBUILD}/gsmpi-1.2
            TMP_DIR ${TPBUILD}/gsmpi-1.2-tmp
            INSTALL_DIR ${TPDIST}
53
            CONFIGURE_COMMAND 
54
                ${CMAKE_COMMAND}
55 56 57
                -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
                -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
                -DCMAKE_BUILD_TYPE:STRING=Debug
58 59
                -DCMAKE_INSTALL_PREFIX:PATH=${TPDIST}
                ${TPSRC}/gsmpi-1.2
60
        )
61
        SET(GSMPI_LIBRARY gsmpi CACHE FILEPATH
62
            "GSMPI path" FORCE)
63
        MARK_AS_ADVANCED(GSMPI_LIBRARY)
Chris Cantwell's avatar
Chris Cantwell committed
64 65
        SET(XXT_LIBRARY xxt CACHE FILEPATH
            "XXT path" FORCE)
66
        MARK_AS_ADVANCED(XXT_LIBRARY)
67 68
        MESSAGE(STATUS "Build GSMPI: ${TPDIST}/lib/lib${GSMPI_LIBRARY}.a")
        MESSAGE(STATUS "Build XXT: ${TPDIST}/lib/lib${XXT_LIBRARY}.a")
69
    ELSE (THIRDPARTY_BUILD_GSMPI)
70
        ADD_CUSTOM_TARGET(gsmpi-1.2 ALL)
71
        INCLUDE (FindGSMPI)
Chris Cantwell's avatar
Chris Cantwell committed
72
        INCLUDE (FindXXT)
73 74 75
    ENDIF (THIRDPARTY_BUILD_GSMPI)
ENDIF( NEKTAR_USE_MPI )