cmake: add FFT_SINGLE option

This commit is contained in:
Christoph Junghans 2018-05-10 12:52:04 -06:00
parent 4f762deff8
commit a25895d31d
2 changed files with 43 additions and 3 deletions

View File

@ -166,11 +166,26 @@ if(BUILD_OMP OR ENABLE_USER-OMP OR ENABLE_KOKKOS OR ENABLE_USER-INTEL)
endif()
if(ENABLE_KSPACE)
set(FFT "KISSFFT" CACHE STRING "FFT library for KSPACE package")
set_property(CACHE FFT PROPERTY STRINGS KISSFFT FFTW3 MKL)
option(FFT_SINGLE "Use single precision FFT instead of double" OFF)
set(FFTW "FFTW3")
if(FFT_SINGLE)
set(FFTW "FFTW3F")
add_definitions(-DFFT_SINGLE)
endif()
find_package(${FFTW} QUIET)
if(${FFTW}_FOUND)
set(FFT "${{FFTW}" CACHE STRING "FFT library for KSPACE package")
else()
set(FFT "KISSFFT" CACHE STRING "FFT library for KSPACE package")
endif()
set_property(CACHE FFT PROPERTY STRINGS KISSFFT ${FFTW} MKL)
if(NOT FFT STREQUAL "KISSFFT")
find_package(${FFT} REQUIRED)
add_definitions(-DFFT_${FFT})
if(NOT FFT STREQUAL "FFTW3F")
add_definitions(-DFFT_FFTW)
else()
add_definitions(-DFFT_${FFT})
endif()
include_directories(${${FFT}_INCLUDE_DIRS})
list(APPEND LAMMPS_LINK_LIBS ${${FFT}_LIBRARIES})
endif()

View File

@ -0,0 +1,25 @@
# - Find fftw3f
# Find the native FFTW3F headers and libraries.
#
# FFTW3F_INCLUDE_DIRS - where to find fftw3f.h, etc.
# FFTW3F_LIBRARIES - List of libraries when using fftw3f.
# FFTW3F_FOUND - True if fftw3f found.
#
find_package(PkgConfig)
pkg_check_modules(PC_FFTW3F fftw3f)
find_path(FFTW3F_INCLUDE_DIR fftw3f.h HINTS ${PC_FFTW3F_INCLUDE_DIRS})
find_library(FFTW3F_LIBRARY NAMES fftw3f HINTS ${PC_FFTW3F_LIBRARY_DIRS})
set(FFTW3F_LIBRARIES ${FFTW3F_LIBRARY})
set(FFTW3F_INCLUDE_DIRS ${FFTW3F_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set FFTW3F_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(FFTW3F DEFAULT_MSG FFTW3F_LIBRARY FFTW3F_INCLUDE_DIR)
mark_as_advanced(FFTW3F_INCLUDE_DIR FFTW3F_LIBRARY )