ThirdPartyPETSc.cmake 2.85 KB
Newer Older
Dave Moxey's avatar
Dave Moxey committed
1
2
3
4
5
6
7
8
########################################################################
#
# ThirdParty configuration for Nektar++
#
# PETSc
#
########################################################################

Dave Moxey's avatar
Dave Moxey committed
9
10
11
OPTION(NEKTAR_USE_PETSC
    "Enable PETSc parallel matrix solver support." OFF)

12
IF (NEKTAR_USE_PETSC)
Dave Moxey's avatar
Dave Moxey committed
13
14
15
16
17
18
19
20
21
22
23
24
    SET(PETSC_FIND_QUIETLY ON)
    INCLUDE(FindPETSc)

    IF (PETSC_FOUND)
        SET(BUILD_PETSC OFF)
    ELSE()
        SET(BUILD_PETSC ON)
    ENDIF()

    CMAKE_DEPENDENT_OPTION(THIRDPARTY_BUILD_PETSC
        "Build PETSc if needed" ${BUILD_PETSC}
        "NEKTAR_USE_PETSC" OFF)
25
26
27
28

    IF (THIRDPARTY_BUILD_PETSC)
        INCLUDE(ExternalProject)

Dave Moxey's avatar
Dave Moxey committed
29
        SET(PETSC_C_COMPILER   "${CMAKE_C_COMPILER}")
30
31
32
33
        SET(PETSC_CXX_COMPILER "${CMAKE_CXX_COMPILER}")

        IF (NEKTAR_USE_MPI)
            IF (NOT MPI_BUILTIN)
Dave Moxey's avatar
Dave Moxey committed
34
                SET(PETSC_C_COMPILER   "${MPI_C_COMPILER}")
35
36
37
38
39
40
41
                SET(PETSC_CXX_COMPILER "${MPI_CXX_COMPILER}")
            ENDIF (NOT MPI_BUILTIN)
        ELSE (NEKTAR_USE_MPI)
            SET(PETSC_NO_MPI "--with-mpi=0")
        ENDIF (NEKTAR_USE_MPI)

        EXTERNALPROJECT_ADD(
42
            petsc-3.5.2
43
            PREFIX ${TPSRC}
44
            STAMP_DIR ${TPBUILD}/stamp
45
            DOWNLOAD_DIR ${TPSRC}
46
47
            SOURCE_DIR ${TPBUILD}/petsc-3.5.2
            TMP_DIR ${TPBUILD}/petsc-3.5.2-tmp
48
            INSTALL_DIR ${TPDIST}
49
            BINARY_DIR ${TPBUILD}/petsc-3.5.2
50
            URL http://www.nektar.info/thirdparty/petsc-lite-3.5.2.tar.gz
51
            URL_MD5 "d707336a98d7cb31d843804d020edc94"
52
53
54
            CONFIGURE_COMMAND ./configure
                --with-cc=${PETSC_C_COMPILER}
                --with-cxx=${PETSC_CXX_COMPILER}
55
56
57
                --with-shared-libraries=0
                --with-pic=1
                --with-x=0
58
                --with-ssl=0
59
                --prefix=${TPDIST}
60
61
62
                --with-petsc-arch=c-opt
                --with-fc=0
                ${PETSC_NO_MPI}
Dave Moxey's avatar
Dave Moxey committed
63
            BUILD_COMMAND MAKEFLAGS= make)
64

Dave Moxey's avatar
Dave Moxey committed
65
66
67
68
69
70
        SET(PETSC_LIBRARIES petsc CACHE FILEPATH
            "PETSc library" FORCE)
        SET(PETSC_INCLUDES ${TPDIST}/include CACHE FILEPATH
            "PETSc includes" FORCE)

        LINK_DIRECTORIES(${TPDIST}/lib)
71
        MESSAGE(STATUS "Build PETSc: ${TPDIST}/${LIB_DIR}/lib${PETSC_LIBRARIES}.a")
Dave Moxey's avatar
Dave Moxey committed
72
        SET(PETSC_CONFIG_INCLUDE_DIR ${TPINC})
73
74
75
76
77
78
79
    ELSE (THIRDPARTY_BUILD_PETSC)
        INCLUDE(FindPETSc)
        IF (NOT PETSC_FOUND)
            MESSAGE(FATAL_ERROR "Could not find PETSc")
        ELSE (NOT PETSC_FOUND)
            MESSAGE(STATUS "Found PETSc: ${PETSC_LIBRARIES}")
        ENDIF (NOT PETSC_FOUND)
Dave Moxey's avatar
Dave Moxey committed
80
        SET(PETSC_CONFIG_INCLUDE_DIR ${PETSC_INCLUDES})
81
        INCLUDE_DIRECTORIES(${PETSC_INCLUDES})
82
        ADD_CUSTOM_TARGET(petsc-3.5.2 ALL)
83
    ENDIF (THIRDPARTY_BUILD_PETSC)
Dave Moxey's avatar
Dave Moxey committed
84

Dave Moxey's avatar
Dave Moxey committed
85
86
87
    ADD_DEFINITIONS(-DNEKTAR_USING_PETSC)
    INCLUDE_DIRECTORIES(SYSTEM ${PETSC_INCLUDES})
ENDIF( NEKTAR_USE_PETSC )