ThirdPartyMPI.cmake 2.19 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 26 27
        MESSAGE(STATUS "Found MPI: built in")
    ENDIF()

28
    ADD_DEFINITIONS(-DNEKTAR_USE_MPI)
29

30 31
    IF (THIRDPARTY_BUILD_GSMPI)
        EXTERNALPROJECT_ADD(
Chris Cantwell's avatar
Chris Cantwell committed
32 33 34
            gsmpi-1.2
            URL ${TPURL}/gsmpi-1.2.tar.bz2
            URL_MD5 35901be16791bfdeafa9c4d0e06d189b
35
            STAMP_DIR ${TPSRC}/stamp
36
            DOWNLOAD_DIR ${TPSRC}
37 38 39 40
            SOURCE_DIR ${TPSRC}/gsmpi-1.2
            BINARY_DIR ${TPBUILD}/gsmpi-1.2
            TMP_DIR ${TPBUILD}/gsmpi-1.2-tmp
            INSTALL_DIR ${TPDIST}
41
            CONFIGURE_COMMAND 
42
                ${CMAKE_COMMAND}
43 44 45
                -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
                -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
                -DCMAKE_BUILD_TYPE:STRING=Debug
46 47
                -DCMAKE_INSTALL_PREFIX:PATH=${TPDIST}
                ${TPSRC}/gsmpi-1.2
48
        )
49
        SET(GSMPI_LIBRARY gsmpi CACHE FILEPATH
50
            "GSMPI path" FORCE)
51
        MARK_AS_ADVANCED(GSMPI_LIBRARY)
Chris Cantwell's avatar
Chris Cantwell committed
52 53
        SET(XXT_LIBRARY xxt CACHE FILEPATH
            "XXT path" FORCE)
54
        MARK_AS_ADVANCED(XXT_LIBRARY)
55 56
        MESSAGE(STATUS "Build GSMPI: ${TPDIST}/lib/lib${GSMPI_LIBRARY}.a")
        MESSAGE(STATUS "Build XXT: ${TPDIST}/lib/lib${XXT_LIBRARY}.a")
57 58
    ELSE (THIRDPARTY_BUILD_GSMPI)
        INCLUDE (FindGSMPI)
Chris Cantwell's avatar
Chris Cantwell committed
59
        INCLUDE (FindXXT)
60 61 62
    ENDIF (THIRDPARTY_BUILD_GSMPI)
ENDIF( NEKTAR_USE_MPI )