ThirdPartyBlasLapack.cmake 2.29 KB
Newer Older
Michael Turner's avatar
Michael Turner committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
########################################################################
#
# ThirdParty configuration for Nektar++
#
# BLAS/LAPACK
#
########################################################################


INCLUDE(FindNativeBlasLapack)

IF(NATIVE_BLAS_LAPACK_FOUND)
    SET(BUILD_BLAS_LAPACK OFF)
ELSE()
Michael Turner's avatar
Michael Turner committed
15 16
    IF(CMAKE_Fortran_COMPILER)
        SET(BUILD_BLAS_LAPACK ON)
Michael Turner's avatar
fix  
Michael Turner committed
17
    ELSE()
Michael Turner's avatar
typo  
Michael Turner committed
18
        MESSAGE(SEND_ERROR "No blas installation or fortran compiler found")
Michael Turner's avatar
Michael Turner committed
19
    ENDIF()
Michael Turner's avatar
Michael Turner committed
20 21 22 23 24 25 26 27 28 29 30 31
ENDIF()

OPTION(THIRDPARTY_BUILD_BLAS_LAPACK "Build blas and lapack libraries from ThirdParty."
    ${BUILD_BLAS_LAPACK})

IF(THIRDPARTY_BUILD_BLAS_LAPACK)
    INCLUDE(ExternalProject)

    EXTERNALPROJECT_ADD(
        lapack-3.7.0
        PREFIX ${TPSRC}
        URL http://www.netlib.org/lapack/lapack-3.7.0.tgz
Michael Turner's avatar
fix  
Michael Turner committed
32
        URL_MD5 "697bb8d67c7d336a0f339cc9dd0fa72f"
Michael Turner's avatar
Michael Turner committed
33 34 35 36 37 38 39 40 41 42
        STAMP_DIR ${TPBUILD}/stamp
        DOWNLOAD_DIR ${TPSRC}
        SOURCE_DIR ${TPSRC}/lapack-3.7.0
        BINARY_DIR ${TPBUILD}/lapack-3.7.0
        TMP_DIR ${TPBUILD}/lapack-3.7.0-tmp
        INSTALL_DIR ${TPDIST}
        CONFIGURE_COMMAND ${CMAKE_COMMAND}
            -G ${CMAKE_GENERATOR}
            -DCMAKE_Fortran_COMPILER:FILEPATH=${CMAKE_Fortran_COMPILER}
            -DCMAKE_INSTALL_PREFIX:PATH=${TPDIST}
43
            -DCMAKE_INSTALL_LIBDIR:PATH=${TPDIST}/lib
Michael Turner's avatar
Michael Turner committed
44 45 46 47 48 49 50
            -DBUILD_SHARED_LIBS:STRING=ON
            -DBUILD_TESTING:STRING=OFF
            ${TPSRC}/lapack-3.7.0
        )

    SET(NATIVE_BLAS blas CACHE FILEPATH "BLAS library" FORCE)
    SET(NATIVE_LAPACK lapack CACHE FILEPATH "LAPACK library" FORCE)
51 52
    SET(NATIVE_BLAS_LIB_DIR ${TPDIST}/lib CACHE FILEPATH "BLAS library dir" FORCE)
    SET(NATIVE_LAPACK_LIB_DIR ${TPDIST}/lib CACHE FILEPATH "LAPACK library dir" FORCE)
Michael Turner's avatar
Michael Turner committed
53 54
    MARK_AS_ADVANCED(NATIVE_BLAS)
    MARK_AS_ADVANCED(NATIVE_LAPACK)
55 56
    MARK_AS_ADVANCED(NATIVE_BLAS_LIB_DIR)
    MARK_AS_ADVANCED(NATIVE_LAPACK_LIB_DIR)
Michael Turner's avatar
Michael Turner committed
57 58 59 60 61 62 63 64 65 66 67 68

    LINK_DIRECTORIES(${TPDIST}/lib)
    INCLUDE_DIRECTORIES(${TPDIST}/include)

    IF (WIN32)
        MESSAGE(STATUS "Build blas: ${TPDIST}/${LIB_DIR}/${NATIVE_BLAS}.dll")
        MESSAGE(STATUS "Build lapack: ${TPDIST}/${LIB_DIR}/${NATIVE_LAPACK}.dll")
    ELSE ()
        MESSAGE(STATUS "Build blas: ${TPDIST}/${LIB_DIR}/lib${NATIVE_BLAS}.a")
        MESSAGE(STATUS "Build lapack: ${TPDIST}/${LIB_DIR}/${NATIVE_LAPACK}.a")
    ENDIF()
ENDIF()