2 # Find the native FFTW2 includes and library, double precision
4 # FFTW2_INCLUDE_DIR - where to find [d]fftw.h
5 # FFTW2_LIBRARIES - List of libraries when using FFTW.
6 # FFTW2_FOUND - True if FFTW found.
8 # The FFTW2 root installation directory can be provided in the FFTW2_ROOT_DIR
10 if (FFTW2_INCLUDE_DIR)
11 # Already in cache, be silent
12 set (FFTW2_FIND_QUIETLY TRUE)
13 endif (FFTW2_INCLUDE_DIR)
17 file(TO_CMAKE_PATH "$ENV{FFTW2_ROOT_DIR}" _env_FFTW2_ROOT_DIR)
19 foreach(fftw2_name dfftw fftw)
20 string(TOUPPER ${fftw2_name} fftw2_uname)
21 string(REPLACE "fftw" "rfftw" rfftw2_name ${fftw2_name})
23 find_path (FFTW2_INCLUDE_DIR
24 PATHS "${_env_FFTW2_ROOT_DIR}/include"
26 CACHE STRING "Path to double precision FFTW2 headers")
27 find_library (CFFTW2_LIBRARIES ${fftw2_name}
28 PATHS "${_env_FFTW2_ROOT_DIR}/lib"
29 CACHE STRING "Double precision CFFTW2 libraries")
30 find_library (RFFTW2_LIBRARIES ${rfftw2_name}
31 PATHS "${_env_FFTW2_ROOT_DIR}/lib"
32 CACHE STRING "Double precision RFFTW2 libraries")
33 TRY_COMPILE(FFTW2_FOUND "${CMAKE_BINARY_DIR}"
34 "${CMAKE_SOURCE_DIR}/cmake/TestFFTW2.c"
35 COMPILE_DEFINITIONS "-I${FFTW2_INCLUDE_DIR} -DDOUBLE -D${fftw2_uname}" )
36 endif(NOT FFTW2_FOUND)
37 endforeach(fftw2_name dfftw fftw)
40 set(FFTW2_LIBRARIES "${RFFTW2_LIBRARIES} ${CFFTW2_LIBRARIES}" CACHE STRING "Result of FFTW2 library check" FORCE)
42 set(FFTW2_INCLUDE_DIR 0)
43 set(FFTW2_LIBRARIES 0)
46 # handle the QUIETLY and REQUIRED arguments and set FFTW_FOUND to TRUE if
47 # all listed variables are TRUE
48 include (FindPackageHandleStandardArgs)
49 set(__MSG "Could not find FFTW2. Provide the fftw2 install directory in the FFTW2_ROOT_DIR environment variable.")
50 find_package_handle_standard_args (FFTW2 ${__MSG} FFTW2_LIBRARIES FFTW2_INCLUDE_DIR)
52 mark_as_advanced (RFFTW2_LIBRARIES CFFTW2_LIBRARIES FFTW2_LIBRARIES FFTW2_INCLUDE_DIR)