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

9 10 11
OPTION(NEKTAR_USE_FFTW
    "Use FFTW routines for performing the Fast Fourier Transform." OFF)

Dave Moxey's avatar
Dave Moxey committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
IF (NEKTAR_USE_FFTW)
    # Set some common FFTW search paths.
    SET(FFTW_SEARCH_PATHS $ENV{LD_LIBRARY_PATH} $ENV{FFTW_HOME}/lib)
    FIND_LIBRARY(FFTW_LIBRARY NAMES fftw3 fftw3f PATHS ${FFTW_SEARCH_PATHS})

    IF (FFTW_LIBRARY)
        GET_FILENAME_COMPONENT(FFTW_PATH ${FFTW_LIBRARY} PATH)
        SET(FFTW_INCLUDE_DIR ${FFTW_PATH}/../include CACHE FILEPATH "FFTW include directory.")
        SET(BUILD_FFTW OFF)
    ELSE()
        SET(BUILD_FFTW ON)
    ENDIF ()

    CMAKE_DEPENDENT_OPTION(THIRDPARTY_BUILD_FFTW
        "Build FFTW from ThirdParty" ${BUILD_FFTW}
        "NEKTAR_USE_FFTW" OFF)
28 29 30 31 32 33 34

    IF (THIRDPARTY_BUILD_FFTW)
        INCLUDE(ExternalProject)
        EXTERNALPROJECT_ADD(
            fftw-3.2.2
            URL ${TPURL}/fftw-3.2.2.tar.gz
            URL_MD5 "b616e5c91218cc778b5aa735fefb61ae"
35
            STAMP_DIR ${TPBUILD}/stamp
36
            DOWNLOAD_DIR ${TPSRC}
37 38 39 40
            SOURCE_DIR ${TPSRC}/fftw-3.2.2
            BINARY_DIR ${TPBUILD}/fftw-3.2.2
            TMP_DIR ${TPBUILD}/fftw-3.2.2-tmp
            INSTALL_DIR ${TPDIST}
41
            CONFIGURE_COMMAND CC=${CMAKE_C_COMPILER} ${TPSRC}/fftw-3.2.2/configure --prefix=${TPDIST} --quiet --enable-shared --disable-dependency-tracking
42
        )
Dave Moxey's avatar
Dave Moxey committed
43

44
        SET(FFTW_LIBRARY fftw3 CACHE FILEPATH
Dave Moxey's avatar
Dave Moxey committed
45 46 47 48 49 50 51 52
            "FFTW library" FORCE)
        SET(FFTW_INCLUDE_DIR ${TPDIST}/include CACHE FILEPATH
            "FFTW include" FORCE)

        LINK_DIRECTORIES(${TPDIST}/lib)

        MESSAGE(STATUS "Build FFTW: ${TPDIST}/lib/lib${FFTW_LIBRARY}.so")
        SET(FFTW_CONFIG_INCLUDE_DIR ${TPINC})
53
    ELSE ()
54
        ADD_CUSTOM_TARGET(fftw-3.2.2 ALL)
Dave Moxey's avatar
Dave Moxey committed
55 56
        MESSAGE(STATUS "Found FFTW: ${FFTW_LIBRARY}")
        SET(FFTW_CONFIG_INCLUDE_DIR ${FFTW_INCLUDE_DIR})
57 58
    ENDIF()
ENDIF( NEKTAR_USE_FFTW )
Dave Moxey's avatar
Dave Moxey committed
59 60 61 62 63

INCLUDE_DIRECTORIES(SYSTEM ${FFTW_INCLUDE_DIR})

MARK_AS_ADVANCED(FFTW_LIBRARY)
MARK_AS_ADVANCED(FFTW_INCLUDE_DIR)