ThirdPartyMPI.cmake 2.04 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
            gsmpi-1.2
33
            PREFIX ${TPSRC}
Chris Cantwell's avatar
Chris Cantwell committed
34 35
            URL ${TPURL}/gsmpi-1.2.tar.bz2
            URL_MD5 35901be16791bfdeafa9c4d0e06d189b
36 37
            DOWNLOAD_DIR ${TPSRC}
            CONFIGURE_COMMAND 
38
                ${CMAKE_COMMAND}
39 40 41 42
                -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
                -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
                -DCMAKE_BUILD_TYPE:STRING=Debug
                -DCMAKE_INSTALL_PREFIX:PATH=${TPSRC}/dist
Chris Cantwell's avatar
Chris Cantwell committed
43
                ${TPSRC}/src/gsmpi-1.2
44
        )
45
        SET(GSMPI_LIBRARY gsmpi CACHE FILEPATH
46
            "GSMPI path" FORCE)
47
        MARK_AS_ADVANCED(GSMPI_LIBRARY)
Chris Cantwell's avatar
Chris Cantwell committed
48 49
        SET(XXT_LIBRARY xxt CACHE FILEPATH
            "XXT path" FORCE)
50
        MARK_AS_ADVANCED(XXT_LIBRARY)
51 52
        MESSAGE(STATUS "Build GSMPI: ${TPSRC}/dist/lib/lib${GSMPI_LIBRARY}.a")
        MESSAGE(STATUS "Build XXT: ${TPSRC}/dist/lib/lib${XXT_LIBRARY}.a")
53 54
    ELSE (THIRDPARTY_BUILD_GSMPI)
        INCLUDE (FindGSMPI)
Chris Cantwell's avatar
Chris Cantwell committed
55
        INCLUDE (FindXXT)
56 57 58
    ENDIF (THIRDPARTY_BUILD_GSMPI)
ENDIF( NEKTAR_USE_MPI )