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 FFTW2F root installation directory can be provided in the FFTW2F_ROOT_DIR
11 if (FFTW2_INCLUDE_DIR)
12 # Already in cache, be silent
13 set (FFTW2_FIND_QUIETLY TRUE)
14 endif (FFTW2_INCLUDE_DIR)
18 file(TO_CMAKE_PATH "$ENV{FFTW2F_ROOT_DIR}" _env_FFTW2F_ROOT_DIR)
20 foreach(fftw2_name sfftw fftw)
21 string(TOUPPER ${fftw2_name} fftw2_uname)
22 string(REPLACE "fftw" "rfftw" rfftw2_name ${fftw2_name})
24 find_path (FFTW2_INCLUDE_DIR
25 PATHS "${_env_FFTW2F_ROOT_DIR}/include"
27 CACHE STRING "Path single precision FFTW2 headers")
28 find_library (CFFTW2_LIBRARIES ${fftw2_name}
29 PATHS "${_env_FFTW2F_ROOT_DIR}/lib"
30 CACHE STRING "Single precision CFFTW2 libraries")
31 find_library (RFFTW2_LIBRARIES ${rfftw2_name}
32 PATHS "${_env_FFTW2F_ROOT_DIR}/lib"
33 CACHE STRING "Single precision RFFTW2 libraries")
34 TRY_COMPILE(FFTW2_FOUND "${CMAKE_BINARY_DIR}"
35 "${CMAKE_SOURCE_DIR}/cmake/TestFFTW2.c"
36 COMPILE_DEFINITIONS "-I${FFTW2_INCLUDE_DIR} -D${fftw2_uname}" )
37 endif(NOT FFTW2_FOUND)
38 endforeach(fftw2_name sfftw fftw)
41 set(FFTW2_LIBRARIES "${RFFTW2_LIBRARIES} ${CFFTW2_LIBRARIES}" CACHE STRING "Result of FFTW2 library check" FORCE)
43 set(FFTW2_INCLUDE_DIR 0)
44 set(FFTW2_LIBRARIES 0)
47 # handle the QUIETLY and REQUIRED arguments and set FFTW_FOUND to TRUE if
48 # all listed variables are TRUE
49 include (FindPackageHandleStandardArgs)
50 set(__MSG "Could not find FFTW2F. Provide the fftw2 install directory in the FFTW2F_ROOT_DIR environment variable.")
51 find_package_handle_standard_args (FFTW2 ${__MSG} FFTW2_LIBRARIES FFTW2_INCLUDE_DIR)
53 mark_as_advanced (RFFTW2_LIBRARIES CFFTW2_LIBRARIES FFTW2_LIBRARIES FFTW2_INCLUDE_DIR)