Skip to content

Commit bbd1b58

Browse files
authored
CMake: FFTW Search w/ CMake Install (#2059)
This adds support for FFTW search with OpenMP support if FFTW was installed with CMake. This is, for instance, the case with EasyBuild based installs on Juelich's JUWELS Booster cluster. Fixes: - the FFTW install does NOT define CMake targets for their sub- targets, so we need to manually find and link the `_omp` lib - the library dir hint with CMake was empty because of a differing spelling (upper vs lowercase of FFTW from pkg-config check module) Tested: - installed with pkg-config, SP and DP, picked up with `*.pc` - installed with CMake, SP and DP, picked up with `*config.cmake` - installed with CMake, SP and DP, picked up with `*.pc`
1 parent d9f911b commit bbd1b58

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

cmake/dependencies/FFT.cmake

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,15 @@ if(WarpX_PSATD)
1616
endif()
1717
endfunction()
1818

19-
# Check if the PkgConfig target location has an _omp library, e.g.,
20-
# libfftw3(f)_omp.a shipped and if yes, set the WarpX_FFTW_OMP=1 define.
19+
# Check if the found FFTW install location has an _omp library, e.g.,
20+
# libfftw3(f)_omp.(a|so) shipped and if yes, set the WarpX_FFTW_OMP=1 define.
2121
#
2222
function(fftw_check_omp library_paths fftw_precision_suffix)
23-
if(WarpX_FFTW_IGNORE_OMP)
24-
fftw_add_define(FALSE)
25-
return()
26-
endif()
27-
2823
find_library(HAS_FFTW_OMP_LIB fftw3${fftw_precision_suffix}_omp
2924
PATHS ${library_paths}
25+
# this is intentional, so we don't mix different FFTW installs
26+
# and only check what is in the location hinted by the
27+
# "library_paths" variable
3028
NO_DEFAULT_PATH
3129
NO_PACKAGE_ROOT_PATH
3230
NO_CMAKE_PATH
@@ -88,9 +86,17 @@ if(WarpX_PSATD)
8886

8987
if(WarpX_FFTW_SEARCH STREQUAL CMAKE)
9088
find_package(FFTW3${HFFTWp} CONFIG REQUIRED)
89+
set(WarpX_FFTW_LIBRARY_DIRS "${FFTW3${HFFTWp}_LIBRARY_DIRS}")
90+
message(STATUS "Found FFTW: ${FFTW3${HFFTWp}_DIR} (found version \"${FFTW3${HFFTWp}_VERSION}\")")
9191
else()
9292
find_package(PkgConfig REQUIRED QUIET)
9393
pkg_check_modules(fftw3${HFFTWp} REQUIRED IMPORTED_TARGET fftw3${HFFTWp})
94+
message(STATUS "Found FFTW: ${fftw3${HFFTWp}_PREFIX}")
95+
if(fftw3${HFFTWp}_LIBRARY_DIRS)
96+
set(WarpX_FFTW_LIBRARY_DIRS "${fftw3${HFFTWp}_LIBRARY_DIRS}")
97+
else()
98+
set(WarpX_FFTW_LIBRARY_DIRS "${fftw3${HFFTWp}_LIBDIR}")
99+
endif()
94100
endif()
95101
endif()
96102

@@ -101,25 +107,19 @@ if(WarpX_PSATD)
101107
elseif(WarpX_COMPUTE STREQUAL HIP)
102108
make_third_party_includes_system(roc::rocfft FFT)
103109
else()
104-
if(FFTW3_FOUND)
105-
# subtargets: fftw3(p), fftw3(p)_threads, fftw3(p)_omp
106-
if(WarpX_COMPUTE STREQUAL OMP AND
107-
TARGET FFTW3::fftw3${HFFTWp}_omp AND
108-
NOT WarpX_FFTW_IGNORE_OMP)
109-
make_third_party_includes_system(FFTW3::fftw3${HFFTWp}_omp FFT)
110-
fftw_add_define(TRUE)
111-
else()
112-
make_third_party_includes_system(FFTW3::fftw3${HFFTWp} FFT)
113-
fftw_add_define(FALSE)
114-
endif()
110+
if(WarpX_FFTW_SEARCH STREQUAL CMAKE)
111+
make_third_party_includes_system(FFTW3::fftw3${HFFTWp} FFT)
115112
else()
116113
make_third_party_includes_system(PkgConfig::fftw3${HFFTWp} FFT)
117-
if(WarpX_COMPUTE STREQUAL OMP AND
118-
NOT WarpX_FFTW_IGNORE_OMP)
119-
fftw_check_omp("${fftw3${HFFTWp}_LIBRARY_DIRS}" "${HFFTWp}")
114+
endif()
115+
if(WarpX_COMPUTE STREQUAL OMP)
116+
if(WarpX_FFTW_IGNORE_OMP)
117+
message(STATUS "FFTW: Requested to IGNORE OpenMP support")
120118
else()
121-
fftw_add_define(FALSE)
119+
fftw_check_omp("${WarpX_FFTW_LIBRARY_DIRS}" "${HFFTWp}")
122120
endif()
121+
else()
122+
message(STATUS "FFTW: Did NOT search for OpenMP support (WarpX_COMPUTE!=OMP)")
123123
endif()
124124
endif()
125125
endif(WarpX_PSATD)

0 commit comments

Comments
 (0)