Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: FFTW Search w/ CMake Install #553

Merged
merged 1 commit into from
Jul 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions cmake/dependencies/FFT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ function(fftw_add_define HAS_FFTW_OMP_LIB)
endif()
endfunction()

# Check if the PkgConfig target location has an _omp library, e.g.,
# libfftw3(f)_omp.a shipped and if yes, set the HIPACE_FFTW_OMP=1 define.
# Check if the found FFTW install location has an _omp library, e.g.,
# libfftw3(f)_omp.(a|so) shipped and if yes, set the HIPACE_FFTW_OMP=1 define.
#
function(fftw_check_omp library_paths fftw_precision_suffix)
if(HiPACE_FFTW_IGNORE_OMP)
fftw_add_define(FALSE)
return()
endif()

find_library(HAS_FFTW_OMP_LIB fftw3${fftw_precision_suffix}_omp
PATHS ${library_paths}
# this is intentional, so we don't mix different FFTW installs
# and only check what is in the location hinted by the
# "library_paths" variable
NO_DEFAULT_PATH
NO_PACKAGE_ROOT_PATH
NO_CMAKE_PATH
Expand Down Expand Up @@ -87,9 +85,17 @@ elseif(NOT HiPACE_COMPUTE STREQUAL CUDA)

if(HiPACE_FFTW_SEARCH STREQUAL CMAKE)
find_package(FFTW3${HFFTWp} CONFIG REQUIRED)
set(HiPACE_FFTW_LIBRARY_DIRS "${FFTW3${HFFTWp}_LIBRARY_DIRS}")
message(STATUS "Found FFTW: ${FFTW3${HFFTWp}_DIR} (found version \"${FFTW3${HFFTWp}_VERSION}\")")
else()
find_package(PkgConfig REQUIRED QUIET)
pkg_check_modules(fftw3${HFFTWp} REQUIRED IMPORTED_TARGET fftw3${HFFTWp})
message(STATUS "Found FFTW: ${fftw3${HFFTWp}_PREFIX}")
if(fftw3${HFFTWp}_LIBRARY_DIRS)
set(HiPACE_FFTW_LIBRARY_DIRS "${fftw3${HFFTWp}_LIBRARY_DIRS}")
else()
set(HiPACE_FFTW_LIBRARY_DIRS "${fftw3${HFFTWp}_LIBDIR}")
endif()
endif()
endif()

Expand All @@ -100,24 +106,18 @@ if(HiPACE_COMPUTE STREQUAL CUDA)
elseif(HiPACE_COMPUTE STREQUAL HIP)
make_third_party_includes_system(roc::rocfft FFT)
else()
if(FFTW3_FOUND)
# subtargets: fftw3(p), fftw3(p)_threads, fftw3(p)_omp
if(HiPACE_COMPUTE STREQUAL OMP AND
TARGET FFTW3::fftw3${HFFTWp}_omp AND
NOT HiPACE_FFTW_IGNORE_OMP)
make_third_party_includes_system(FFTW3::fftw3${HFFTWp}_omp FFT)
fftw_add_define(TRUE)
else()
make_third_party_includes_system(FFTW3::fftw3${HFFTWp} FFT)
fftw_add_define(FALSE)
endif()
if(HiPACE_FFTW_SEARCH STREQUAL CMAKE)
make_third_party_includes_system(FFTW3::fftw3${HFFTWp} FFT)
else()
make_third_party_includes_system(PkgConfig::fftw3${HFFTWp} FFT)
if(HiPACE_COMPUTE STREQUAL OMP AND
NOT HiPACE_FFTW_IGNORE_OMP)
fftw_check_omp("${fftw3${HFFTWp}_LIBRARY_DIRS}" "${HFFTWp}")
endif()
if(HiPACE_COMPUTE STREQUAL OMP)
if(HiPACE_FFTW_IGNORE_OMP)
message(STATUS "FFTW: Requested to IGNORE OpenMP support")
else()
fftw_add_define(FALSE)
fftw_check_omp("${HiPACE_FFTW_LIBRARY_DIRS}" "${HFFTWp}")
endif()
else()
message(STATUS "FFTW: Did NOT search for OpenMP support (HiPACE_COMPUTE!=OMP)")
endif()
endif()