ThirdPartyScotch.cmake 2.09 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 19 20 21 22 23 24
        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)

        IF (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
            SET(SCOTCH_MAKE Makefile.inc.x86-64_pc_linux2.shlib)
        ELSE ()
            SET(SCOTCH_MAKE Makefile.inc.i686_pc_linux2.shlib)
        ENDIF ()

25 26 27 28 29
        INCLUDE(ExternalProject)
        EXTERNALPROJECT_ADD(
            scotch-6.0.0
            PREFIX ${TPSRC}
            URL ${TPURL}/scotch_6.0.0.tar.gz
30
            URL_MD5 "ba117428c0a6cd97d0c93e8b872bb3fe"
31
            DOWNLOAD_DIR ${TPSRC}
32 33 34 35 36 37 38 39
            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
                "LDFLAGS=-lz -lm -lrt -lpthread" scotch
            INSTALL_COMMAND $(MAKE) -C ${TPSRC}/src/scotch-6.0.0/src
                prefix=${TPSRC}/dist install
40 41 42
        )
        SET(SCOTCH_LIB scotch CACHE FILEPATH
            "Scotch library" FORCE)
43 44
        SET(SCOTCHERR_LIB scotcherr CACHE FILEPATH
            "Scotch error library" FORCE)
45 46 47
        SET(SCOTCHMETIS_LIB scotchmetis CACHE FILEPATH
            "Scotch Metis interface library" FORCE)
        MARK_AS_ADVANCED(SCOTCH_LIB)
48
        MARK_AS_ADVANCED(SCOTCHERR_LIB)
49 50 51 52 53 54 55 56
        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 )