ThirdPartyScotch.cmake 2.87 KB
Newer Older
1 2 3 4 5 6 7 8 9
OPTION(NEKTAR_USE_SCOTCH
    "Use Scotch library for performing mesh partitioning." OFF)

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

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

        SET(SCOTCH_SRC ${TPSRC}/src/scotch-6.0.0/src)

Dave Moxey's avatar
Dave Moxey committed
19 20 21
        IF (APPLE)
            SET(SCOTCH_MAKE Makefile.inc.i686_mac_darwin8)
            SET(SCOTCH_LDFLAGS "")
Dave Moxey's avatar
Dave Moxey committed
22
            SET(SCOTCH_CFLAGS "-O3 -Drestrict=__restrict -DCOMMON_PTHREAD -DCOMMON_RANDOM_FIXED_SEED -DCOMMON_TIMING_OLD -DSCOTCH_PTHREAD -DSCOTCH_RENAME -DCOMMON_PTHREAD_BARRIER")
23
        ELSE ()
Dave Moxey's avatar
Dave Moxey committed
24 25
            IF (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
                SET(SCOTCH_MAKE Makefile.inc.x86-64_pc_linux2)
Dave Moxey's avatar
Dave Moxey committed
26
                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
27 28
            ELSE ()
                SET(SCOTCH_MAKE Makefile.inc.i686_pc_linux2)
Dave Moxey's avatar
Dave Moxey committed
29
                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
30 31
            ENDIF ()
            SET(SCOTCH_LDFLAGS "-lz -lm -lrt -lpthread")
32 33
        ENDIF ()

34 35 36 37 38
        INCLUDE(ExternalProject)
        EXTERNALPROJECT_ADD(
            scotch-6.0.0
            PREFIX ${TPSRC}
            URL ${TPURL}/scotch_6.0.0.tar.gz
39
            URL_MD5 "ba117428c0a6cd97d0c93e8b872bb3fe"
40
            DOWNLOAD_DIR ${TPSRC}
41 42 43 44 45
            CONFIGURE_COMMAND rm -f ${SCOTCH_SRC}/Makefile.inc
                COMMAND ln -s
                ${SCOTCH_SRC}/Make.inc/${SCOTCH_MAKE}
                ${SCOTCH_SRC}/Makefile.inc
            BUILD_COMMAND $(MAKE) -C ${TPSRC}/src/scotch-6.0.0/src
Dave Moxey's avatar
Dave Moxey committed
46
                "CFLAGS=${SCOTCH_CFLAGS}"
Dave Moxey's avatar
Dave Moxey committed
47
                "LDFLAGS=${SCOTCH_LDFLAGS}"
48
                "CLIBFLAGS=-fPIC" scotch
49 50
            INSTALL_COMMAND $(MAKE) -C ${TPSRC}/src/scotch-6.0.0/src
                prefix=${TPSRC}/dist install
51 52 53
        )
        SET(SCOTCH_LIB scotch CACHE FILEPATH
            "Scotch library" FORCE)
54 55
        SET(SCOTCHERR_LIB scotcherr CACHE FILEPATH
            "Scotch error library" FORCE)
56 57 58
        SET(SCOTCHMETIS_LIB scotchmetis CACHE FILEPATH
            "Scotch Metis interface library" FORCE)
        MARK_AS_ADVANCED(SCOTCH_LIB)
59
        MARK_AS_ADVANCED(SCOTCHERR_LIB)
60 61 62 63 64 65 66 67
        MARK_AS_ADVANCED(SCOTCHMETIS_LIB)
        LINK_DIRECTORIES(${TPSRC}/dist/lib)
        INCLUDE_DIRECTORIES(${TPSRC}/dist/include)
        MESSAGE(STATUS "Build Scotch: ${TPSRC}/dist/lib/lib${SCOTCH_LIB}.a")
    ELSE (THIRDPARTY_BUILD_SCOTCH)
        INCLUDE (FindScotch)
    ENDIF (THIRDPARTY_BUILD_SCOTCH)
ENDIF( NEKTAR_USE_SCOTCH )