ThirdPartyScotch.cmake 3.28 KB
Newer Older
1 2 3 4
IF (NOT WIN32)
    OPTION(NEKTAR_USE_SCOTCH
        "Use Scotch library for performing mesh partitioning." OFF)
ENDIF(NOT WIN32)
5 6 7 8 9 10 11

CMAKE_DEPENDENT_OPTION(THIRDPARTY_BUILD_SCOTCH
    "Build Scotch library from ThirdParty" OFF
    "NEKTAR_USE_SCOTCH" OFF)

IF( NEKTAR_USE_SCOTCH )
    IF (THIRDPARTY_BUILD_SCOTCH)
12 13 14 15 16 17
        UNSET(FLEX CACHE)
        FIND_PROGRAM(FLEX flex)
        IF(NOT FLEX)
            MESSAGE(FATAL_ERROR
                "'flex' lexical parser not found. Cannot build scotch.")
        ENDIF(NOT FLEX)
18
        MARK_AS_ADVANCED(FLEX)
19

20 21 22
        # Note that scotch is compiled in the source-tree, so we unpack the
        # source code in the ThirdParty builds directory.
        SET(SCOTCH_SRC ${TPBUILD}/scotch-6.0.0/src)
23

Dave Moxey's avatar
Dave Moxey committed
24 25 26
        IF (APPLE)
            SET(SCOTCH_MAKE Makefile.inc.i686_mac_darwin8)
            SET(SCOTCH_LDFLAGS "")
Dave Moxey's avatar
Dave Moxey committed
27
            SET(SCOTCH_CFLAGS "-O3 -Drestrict=__restrict -DCOMMON_PTHREAD -DCOMMON_RANDOM_FIXED_SEED -DCOMMON_TIMING_OLD -DSCOTCH_PTHREAD -DSCOTCH_RENAME -DCOMMON_PTHREAD_BARRIER")
28
        ELSE ()
Dave Moxey's avatar
Dave Moxey committed
29 30
            IF (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
                SET(SCOTCH_MAKE Makefile.inc.x86-64_pc_linux2)
Dave Moxey's avatar
Dave Moxey committed
31
                SET(SCOTCH_CFLAGS "-O3 -DCOMMON_FILE_COMPRESS_GZ -DCOMMON_PTHREAD -DCOMMON_RANDOM_FIXED_SEED -DSCOTCH_RENAME -DSCOTCH_PTHREAD -Drestrict=__restrict -DIDXSIZE64")
Dave Moxey's avatar
Dave Moxey committed
32 33
            ELSE ()
                SET(SCOTCH_MAKE Makefile.inc.i686_pc_linux2)
Dave Moxey's avatar
Dave Moxey committed
34
                SET(SCOTCH_CFLAGS "-O3 -DCOMMON_FILE_COMPRESS_GZ -DCOMMON_PTHREAD -DCOMMON_RANDOM_FIXED_SEED -DSCOTCH_RENAME -DSCOTCH_PTHREAD -Drestrict=__restrict")
Dave Moxey's avatar
Dave Moxey committed
35 36
            ENDIF ()
            SET(SCOTCH_LDFLAGS "-lz -lm -lrt -lpthread")
37 38
        ENDIF ()

39 40 41 42 43
        INCLUDE(ExternalProject)
        EXTERNALPROJECT_ADD(
            scotch-6.0.0
            PREFIX ${TPSRC}
            URL ${TPURL}/scotch_6.0.0.tar.gz
44
            URL_MD5 "ba117428c0a6cd97d0c93e8b872bb3fe"
45
            STAMP_DIR ${TPBUILD}/stamp
46
            DOWNLOAD_DIR ${TPSRC}
47 48 49 50
            SOURCE_DIR ${TPBUILD}/scotch-6.0.0
            BINARY_DIR ${TPBUILD}/scotch-6.0.0
            TMP_DIR ${TPBUILD}/scotch-6.0.0-tmp
            INSTALL_DIR ${TPDIST}
51 52 53 54
            CONFIGURE_COMMAND rm -f ${SCOTCH_SRC}/Makefile.inc
                COMMAND ln -s
                ${SCOTCH_SRC}/Make.inc/${SCOTCH_MAKE}
                ${SCOTCH_SRC}/Makefile.inc
55
            BUILD_COMMAND $(MAKE) -C ${SCOTCH_SRC}
Dave Moxey's avatar
Dave Moxey committed
56
                "CFLAGS=${SCOTCH_CFLAGS}"
Dave Moxey's avatar
Dave Moxey committed
57
                "LDFLAGS=${SCOTCH_LDFLAGS}"
58
                "CLIBFLAGS=-fPIC" scotch
59 60
            INSTALL_COMMAND $(MAKE) -C ${SCOTCH_SRC}
                prefix=${TPDIST} install
61 62 63
        )
        SET(SCOTCH_LIB scotch CACHE FILEPATH
            "Scotch library" FORCE)
64 65
        SET(SCOTCHERR_LIB scotcherr CACHE FILEPATH
            "Scotch error library" FORCE)
66 67 68
        SET(SCOTCHMETIS_LIB scotchmetis CACHE FILEPATH
            "Scotch Metis interface library" FORCE)
        MARK_AS_ADVANCED(SCOTCH_LIB)
69
        MARK_AS_ADVANCED(SCOTCHERR_LIB)
70
        MARK_AS_ADVANCED(SCOTCHMETIS_LIB)
71 72 73
        LINK_DIRECTORIES(${TPDIST}/lib)
        INCLUDE_DIRECTORIES(${TPDIST}/include)
        MESSAGE(STATUS "Build Scotch: ${TPDIST}/lib/lib${SCOTCH_LIB}.a")
74
    ELSE (THIRDPARTY_BUILD_SCOTCH)
75
        ADD_CUSTOM_TARGET(scotch-6.0.0 ALL)
76 77 78
        INCLUDE (FindScotch)
    ENDIF (THIRDPARTY_BUILD_SCOTCH)
ENDIF( NEKTAR_USE_SCOTCH )